WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ODBC
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

How Does qBindCol Work???

Keywords: 	 qBindCol

Question:

I do extensive ODBC with inbound data, and am just getting started with WinBatch ODBC extender. I got the sample .wbt script to work, up until the point of the last message within this clip of code. The variable "columns" is always "" (blank).

My misunderstanding is coming from the 3 lines that read "retcode = qBindCol(hstmt, 4, "colname", 80)". I guess that I don't understand how they work, and where I should insert "a variable that I name here".

CODE:

;BINDS A COLUMN IN A RESULT SET TO A VARIABLE THAT YOU NAME HERE
retcode = qBindCol(hstmt, 4, "colname", 80) 
retcode = qBindCol(hstmt, 6, "coltype", 80)
retcode = qBindCol(hstmt, 8, "collength", 80)

If (retcode != @qSuccess) && (retcode != @qSuccessInfo)
Message("qBindCol failed", retcode)
Exit
Endif

columns = ""

While @TRUE
retcode = qFetch(hstmt)

If retcode == @qNoData Then Break

If (retcode != @qSuccess) && (retcode != @qSuccessInfo)
Message("qFetch failed", retcode)
Exit
Endif

columns = StrCat(columns, colname, @TAB, "(", coltype, ")", @TAB, "[",collength, "]", @LF)
EndWhile

;DISPLAY COLUMNS IN THE "SAMPLE" DATA SOURCE
Message("Columns in 'SAMPLE'", columns) 

Answer:

Now that you have executed the qColumns function, which filled the result set, we need to access that information using the function qBindCol.The qBindCol function is always called after using an SQL command that creates a result set (in this case, the qColumns function created the result set). qBindCol maps the column in the result set specified by the "col" parameter to a WIL variable specified by the "varname" parameter. You would call qBindCol once for each column you want to retrieve. Then, each time you call qFetch it will set each WIL "varname" variable with the corresponding value from the next row. The "varname" will be assigned a string value (and will be created if it does not already exist).

Notes: qBindCol "col" parameter must be a value between 1 and 50. The "max-size" parameter should be at least 20; if not, it will be set to 20. If the returned data is larger than "max-size", it will be truncated. The third parameter in the function qBindCol is the WIL variable name (This can be any variable name you choose), that you want to 'hold' the 'binded' information to.

~~~~~~~~~~~~~~~~~~~~

Try running the code in debug mode. You will probably see that retcode equals @qNoData, which possibly means there is simply no data to retrieve:

retcode = qFetch(hstmt)
If retcode == @qNoData Then Break 
~~~~~~~~~~~~~~~~~~~~
Article ID:   W12534
Filename:   How Does qBindCol Work.txt
File Created: 2001:01:09:15:40:36
Last Updated: 2001:01:09:15:40:36