Does embedded SQL work in C the same as in RPG? Such as, running a DROP QTEMP/MYFILE statement. In RPG this just returns a negative SQLCODE. Don't have to capture the message.


On 2/15/13 3:07 AM, Jevgeni Astanovski wrote:
Hello,

Such a trivial operation and I understood that I do not see simple solution...
A program needs to use a temporary table, I assumed that QTEMP is the best place for it.
So I have a table with the same structure in MYLIB and program needs to create its copy, however, empty, and in QTEMP.

I shall issue a CL command CRTDUPOBJ from my C program, but I cannot gurantee, that the table does not exist there already.
I see two ways to protect myself from this situation:

1. Capture relevant error message (probably CPD2104, object already exist);

2. Issue unlink (Unix style API) to delete this file before making CRTDUPOBJ - but this will end in error if file does not exist.

Or I should rather attempt to open file using _Ropen with mode "wr" and if it ends in error, issue CRTDUPOBJ and make _Ropen again?

All these methods seem odd - that made me think that maybe there is some better way...

Thanks,

Jevgeni



This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2019 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact [javascript protected email address].