11.04.2013 Views

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

UniBasic Commands Reference - Rocket Software

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

This example shows how you might use SQLParamOptions to load a simple table.<br />

Table TAB1 has two columns: an integer column and a CHAR(30) column.<br />

1-840 <strong>UniBasic</strong> <strong>Commands</strong> <strong>Reference</strong><br />

$include INCLUDE ODBC.H<br />

arrsize = 20<br />

dim p1(arrsize)<br />

dim p2(arrsize)<br />

SQLINS1 = "INSERT INTO TAB1 VALUES(?,?)"<br />

rowindex = 0<br />

status = SQLAllocEnv(henv)<br />

status = SQLAllocConnect(henv, hdbc)<br />

status = SQLConnect(hdbc, "odbcds", "dbuid", "dbpwd")<br />

status = SQLAllocStmt(hdbc, hstmt)<br />

status = SQLPrepare(hstmt, SQLINS1)<br />

status = SQLBindParameter(hstmt, 1, SQL.B.BASIC, SQL.INTEGER, 0,<br />

0, p1(1),<br />

SQL.PARAM.INPUT)<br />

status = SQLBindParameter(hstmt, 2, SQL.B.BASIC, SQL.CHAR, 30, 0,<br />

p2(1),<br />

SQL.PARAM.INPUT)<br />

status = SQLParamOptions(hstmt, SQL.PARAMOPTIONS.SET, arrsize)<br />

for index = 1 to arrsize<br />

p1(index) = index<br />

p2(index) = "This is row ":index<br />

next index<br />

* now execute, delivering 20 sets of parameters in one network<br />

operation<br />

stexec = SQLExecute(hstmt)<br />

status = SQLParamOptions(hstmt, SQL.PARAMOPTIONS.READ, rowindex)<br />

if stexec = SQL.ERROR then<br />

print "Error in parameter row number ":rowindex<br />

end else<br />

print rowindex:" parameter marker sets were processed"<br />

end

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!