Source code for the CONNECT verb is supplied.  Track it down and take a look at 
it.

The steps are as follows.  You should check for, and clear, errors at every 
step.  Seriously.  ODBC simply does not function with "dirty handles".

1.  Allocate ODBC environment (SQLAllocEnv)
2.  Allocate connection environment (SQLAllocConnect)
3.  Connect to Oracle database (SQLConnect)
    (optional) discover information about connection (SQLTables, etc.)
4.  Construct SELECT statement.  
5.  If SELECT statement includes parameter markers (?) bind variables to each 
(SQLBindParameter).
6.  Allocate statement environment (SQLAllocStmt)
7.  Either:
    (a) send SQL statement to be prepared (SQLPrepare) and executed (SQLExecute)
    (b) send SQL statement to be executed directly (SQLExecDirect)
8.  If you don't already know how many columns there are in the result set 
(e.g. SELECT * FROM ...)
    find out (SQLNumResultCols).
9.  Bind a variable to each result set column (SQLBindCol).
10. Loop calling (SQLFetch), which returns one result row, until its status is 
SQL.NO.DATA.FOUND.
11. The value from each column is in the relevant bound variable.  Do whatever 
with these.
12. Now that the loop's finished:
    (a) Free the statement environment (SQLFreeStmt)
    (b) Disconnect from the Oracle server (SQLDisconnect)
    (c) Free the connection environment (SQLFreeConnect)
    (d) Free the ODBC environment (SQLFreeEnv)

Simple, innit?


----- Original Message -----
From: [EMAIL PROTECTED]
To: [email protected]
Subject: [U2] BCI Connect 
Date: Thu, 30 Dec 2004 13:30:39 -0000

> 
> Hello all
> 
> I am trying to extract data from an Oracle Database from Unidata. I have read
> through the BCI Connect manual and it looks fairly simple using the Connect
> command, but much more complicated using directly within Unibasic. Does
> anyone have a simple example of executing a SQL statement and returning the
> results into either a Unidata file or reading each row?
> 
> If I do not want to update should I just datastack and use the CONNECT
> command?
> 
> Thanks
> 
> Graham
> 
> 
> 
> Graham Forbes
> Trading Systems
> BT Consulting & Systems Integration
> 
> 
> 
> 
> ********************************************************************
> 
> This email may contain information which is privileged or confidential. If you
> are not the intended recipient of this email, please notify the sender
> immediately and delete it without reading, copying, storing, forwarding or
> disclosing its contents to any other person
> Thank you
> 
> Check us out at http://www.bt.com/consulting
> 
> ********************************************************************
> -------
> u2-users mailing list
> [email protected]
> To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to