Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.
Good morning! I have an RPG program that is creating a view. If I call the program it creates the view. I can then go into SQL and view the data. However, once I sign off and back on the view is gone.
I didn't create the view QTEMP, so my understanding is that it's like a logical and should stay. Does anyone have any suggestions where my problem might be? Here's my create command that is being called via QCMDEXC within the RPG program:
create view jda2dts/j_invaud as select * from invaud where itrdat >= 101227
Thanks for any input!
Chris
Here's the actual code from the program, just in case I have something wrong there:
// create views for invaud, invcal and trafhst
sqlstmt = 'create view jda2dts/j_invaud as select * from invaud -
where itrdat >= ' + %char(datbak) + '';
execsqlexecuteimmediate :sqlstmt;
The copy took the spaces out of the "execute immediate" statment
That's bizarre. Do a DPPFD before you sign off to see if anything weird shows up. Maybe the LF (View) is based on a PF (Table) in QTEMP? Not sure!
Chris Ringer
Hi Chris
Actually, I found it! The program had to be modified to do a COMMIT after the view is created, otherwise it disappears. I also compiled the program for COMMIT(*NONE). That took care of the issue. Another thing to store away in the gray matter!
Thanks for the recommendation!
Chris
Wow. I thought COMMIT was only for rows/records. Learned something new. Thanks.
Chris Ringer
Yes, I good habit to get into is making sure your first line of "Calc's" in the SQLRPGLE source member is:
/free EXEC SQL SET OPTION COMMIT = *NONE;
Or you could decide to start working with commitment control, and commit the pending changes.
EXEC SQL COMMIT;
...or you just do the commit in RPG...
Hmm... I've never tried mixing them like that. Does SQL do it's work (COMMITS and everything else) in the same commitment definition as the program in which it's embedded?