• 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!

E9.1 JDB_InsertFromSelect API

LHoffman

Active Member
Does anyone have an example on how to call JDB_InsertFromSelect and/or JDB_InsertFromSelectExtended APIs?

Looking into db_proto.h it seems it receive two HREQUESTs (one for table to perform the set_selection and the other to the table to perform the insert) but the other parameters I couldn't figure out what to pass in(DBREF, LPDS_OBJ, etc).

Thanks for your help.
 

BOster

Legendary Poster
I have used quite a few of these "fringe" type JDBASE APIs but not this specific one. You can generally reverse engineer how to use them from the func signature, VS Intellisense, pristine code examples and finally looking at the SQL statements in the debug log, even before you get it working so you can at least see the SQL that various code changes generates. You should be able to find quite a few pristine code examples that use some form of the JDB_InsertFromSelect[xxxxxxxx] calls (most will probably be the aggregation form) and that should help you with the DS_OBJ struct. The DBREF is quite common across a lot of these APIs and is simply an array of table/column definitions, in this context it looks like it is used to define the target table structure.

The JDE Tools developers did an amazing job with all the C JDEBASE APIs. You can combine them in all sorts of ways to do some really creative things.
 

jdedwardsuser

Active Member
The other good way to learn JDE api and to code them is to search for them in Visual C++ . Go to find and the folder should be pointed to your source . Type is the JDE api you need and find . It will show you where it is used in which business function and you can open them and see how they are used what params , request handles , insert DSTR ,table name all of that .
 

LHoffman

Active Member
Hi BOster and jdedwarduser, thanks for your feeedback.

I had looked into E1/DV910/source folder before to searched in all .C files for a reference for JDB_InsertFromSelect, but I couldn't find any, unfortunately. (maybe it's the TR that I'm working, how knows).

Luckily the requirement that was working changed and I can handle it differently to not use this API.

Maybe I'll give it a shot again later.
 

BOster

Legendary Poster
You may not have found that exact one, but there are quite a few examples of the various aggregate form(s) of it. Which if you think about it makes more sense... that is a more likely use case - inserting the results of an aggregate SQL statement into a table.
 
Top