KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Code which extracts all records from an Oracle table
PRODUCT: 4D Oracle | VERSION: | PLATFORM: Mac & Win
Published On: May 9, 2002
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

Compatibility: 6.5.x, 6.7.x, 6.8

If you are getting started with the 4D for Oracle plug-in and are having trouble getting data from Oracle, this sample method may just do the trick for you. This method uses low-level commands to log into the Oracle database, establishes a cursor ID, and then uses the cursor ID to bind to the 4D fields and execute the SQL command.



All you need to do is copy and paste the method into your own method and change the appropriate items.







C_LONGINT(ID_login;err)



$sServer:="oracleDB.PRIVATE.4D.COM"

ID_login:=OD Login ("username";"password";$sServer;1) `note the use of the 4th parameter

Cursor_ID:=OD Create cursor (ID_login)



err:=OD Set SQL in cursor (Cursor_ID;"SELECT * FROM MyOracleTable")

`Binds the Orable fields to the 4D fields

OD BIND TOWARDS 4D (Cursor_ID;1;->[Table1]My4DField1) `bind column 1 to My4DField1

OD BIND TOWARDS 4D (Cursor_ID;2;->[Table1]My4DField2) `bind column 2 to My4DField2

OD BIND TOWARDS 4D (Cursor_ID;3;->[Table1]My4DField3)

OD BIND TOWARDS 4D (Cursor_ID;4;->[Table1]My4Dfield4)



OD EXECUTE CURSOR (Cursor_ID) `Executes SQL statment

err:=OD Load rows cursor (Cursor_ID) `Loads results

OD DROP CURSOR (Cursor_ID)

OD LOGOUT (ID_login)