• Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

OneWorld API - SQL Help

ProjectRoom

Well Known Member
There are many API calls for OneWorld, JDE_OpenTable(), CloseTable, OpenForeignTable etc etc...

Im nto interesting in Opening Tables, unless I can open the table dynamically by Name (char * TableName). Is there an API for SELECT SQL? If so, how do I use it? Keeping in mind im using C++ ONLY! Unless you have a cunning way for my to call an SQL executor and get the returned SELECT data.

Need some guru help here ;)

p.s Sorry for all the posts laterly, im under a deadline :/

Cheers

PR

[ B7.3.3.2 ][ SP 11.3 ][ NT 4.0 ][ AS/400 co-existance ]
 

tpw_nz

Active Member
ProjectRoom,

I've done a similiar thing to open up any view and retrieve the data from it.

The steps you'd need to follow to do the same thing for a table would be.

1. JDBRS_GetTableSpecs - this will return all the table columns into a structure.

2. JDB_OpenTable - opens the table.

3. JDB_SelectAll - selects all rows.

4. while (JDB_Fetch == JDB_PASSED) - as long a row was found

4.1. For each column retrieved from JDBRS_GetTableSpecs

4.1.1. JDBRS_GetColumnSpecs - to determine what the column is, MATH_NUMERIC, string, date, character.

4.1.2. JDB_GetTableColValue - to retrieve the actual column value into an appropriate variable based on the type retrieved in 4.1.1.


As I said I've done the same thing for views so it should be possible. All of the API's that want a table name specify the table name as a NID datatype. NID is just a char[11] so you can just use a variable to hold your table name.

You could replace the SelectAll with a FetchKeyed. The tricky bit is
using JDBRS_GetColumnSpecs to determine the variable type for the JDB_GetTableColValue API.


Good luck.
 

ProjectRoom

Well Known Member
Thanks a lot :D
Should be just what I need :)
Is there a reference of how to use OneWorld API? Or is this a case
of learn by playing with it and hope it doesn't break.
JDB_SelectKeyed() does this one used?

Cheers

PR

[ B7.3.3.2 ][ SP 11.3 ][ NT 4.0 ][ AS/400 co-existance ]
 

Christian Audet

Moderator
Staff member
Project Room,

Look in the Archive for "SQL Chalenge" there is a reply from Whipping Boy that give how to do a SQL SELECT statement in 'C'.

Christian Audet

Implementing B7333 (Xe) SP14.1, SQL
(Support B732, B7331 and B7332)
 
Top