odbc column 32 characters

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf odbc column 32 characters

  • Creator
    Topic
  • #53404
    Todd Horst
    Participant

      When binding to a column using the odbc it only returns the first 32 characters of the column

      odbc SQLBindCol $StatementHandle 2 SQL_TEXT “email” 10 pcbValue1

      Any Ideas?

      Ive also tried

      odbc SQLBindCol $SH 2 SQL_VARCHAR “email” 10 pcbValue1

      Instead of returning

      saddddsadklsadljklasdhklasjdklasjdklasjdkljaslkdjsakldjklasjdklasjdk

      I get

      saddddsadklsadljklasdhklasjdkla[[(

    Viewing 5 reply threads
    • Author
      Replies
      • #77573
        Elisha Gould
        Participant

          odbc SQLBindCol $StatementHandle 2 SQL_TEXT “email”  10 pcbValue1

          Try updating the buffer size to a larger value. You should be only getting 10 bytes with this value. I would say to set it to 2000. or use SQLDescribeCol to get the size of the field.

          Check the parameters for the initialisation as well. I think you will need SQL_NTS if you dont want to see data from another buffer in your variable.

          Have to also be carefull not to select a null value. put something in your select to change it to a space or something, otherwise it will error.

        • #77574
          Todd Horst
          Participant

            I tried changing to 2000. Same thing.

            I tried changing to sql_nts and now it outputs:

            saddddsadklsadljklasdhklasjdkla Ÿ-

          • #77575
            Elisha Gould
            Participant

              There are a couple of modes for the sql to be performed.

              I can’t remember the exact details, but for one case it will put whatever is in the buffer in the variable, as seen in your case where there is garbage data at the end.

              You can use SQL_NTS to overcome this, but you have to make sure the data is not NULL, otherwise it will fail.

              Most of what I have is something along the lines of the following:

              set mySql “select nvl( field,’ ‘) from table”

              odbc SQLExecDirect $HSTMT $mySql SQL_NTS

              nvl sets the result to a space if it is null.

              For the initialisation, I’m using an oracle database, and have something along the lines of:

              odbc SQLAllocHandle SQL_HANDLE_ENV SQL_NULL_HANDLE HENV

              odbc SQLSetEnvAttr $HENV SQL_ATTR_ODBC_VERSION  SQL_OV_ODBC3 0

              odbc SQLAllocHandle SQL_HANDLE_DBC $HENV HDBC

              odbc SQLDriverConnect $HDBC NULL

                     “DSN=Oracle Wire Protocol; HostName=$aHost; PortNumber=$aPort; LogonID=$aLogin; Password=$aPasswd; SID=$aSid;” SQL_NTS

                     OutConnectionString 246 StringLengthPtr SQL_DRIVER_NOPROMPT

            • #77576
              Todd Horst
              Participant

                oh, I thought you meant:

                odbc SQLBindCol $SH 2 SQL_NTS “email” 2000 pcbValue1

                I didnt know you were talking about the line to execute the query.

                odbc SQLExecDirect $HSTMT $mySql SQL_NTS

                I was using nts already. All your other code looks the same as mine.

                Still no luck.

              • #77577
                Charlie Bursell
                Participant

                  I think your bind is wrong.  Here is one of mine

                  odbc SQLBindCol $hstmt $cnt SQL_C_CHAR data($cnt) 500000 SQL_NTS

                • #77578
                  Todd Horst
                  Participant

                    That was it.

                    Change

                    odbc SQLBindCol $SH 2 SQL_TEXT “email” 2000 pcbValue1

                    To

                    odbc SQLBindCol $SH 2 SQL_C_CHAR “email” 500000 SQL_NTS

                Viewing 5 reply threads
                • The forum ‘Cloverleaf’ is closed to new topics and replies.