using SQL statements…………..

45 pts.
Tags:
CLP
DB2 Universal Database
RPGLE
Hi All, I have a problem. I have a string variable STR which contains SQL statements...... Like insert into lib1/fil1 select * from lib2/fil2 variable STR is changable...means I update the values of library and files at run time...in the variable STR.. I want to execute the SQL statements contained in string STR... How can I please suggest some approach....
ASKED: January 4, 2007  9:52 AM
UPDATED: December 23, 2010  6:05 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.

I’m sure there are other options, but the RUNSQLSTM command can execute a statement from a souce file. which you could easily modify. I think there’s also inline SQL in RPG, but, I haven’t used that option before, so I have no idea on the specifics of how it works.

Discuss This Question: 4  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • JohndeCoville
    Runsqlstm works very nicely: UNSQLSTM SRCFILE(QSQLSRC) SRCMBR(NIGHTLYAP) for example. /*****************************************************/ /* */ /** Create View over OWN_MAS (Base data file) */ /*****************************************************/ CREATE VIEW OWN_MASLH BOOK, NAME_TYPE, R_TAX_YEAR AS SELECT PARCEL_ID, BOOK, MAP, SPLIT, FROM OWN_MAS -John just a simple example. You can select with "Where", crate new columns/fields by concatenation, etc, etc
    0 pointsBadges:
    report
  • Oli
    If you directly want to use your string variable try the following embedded sql-statement: C/EXEC SQL C+ Execute immediate C+ :STR C/END-EXEC
    0 pointsBadges:
    report
  • SteveCCNJ
    Create QSQLSRC in your library and then create source members (type SQL) containing the SQL. Execute the SQL with RUNSQLSTM, where you can specify the data library (Default Collection) on the command at run time, without having to put it in the SQL itself. You can include multiple SQL statements in a single source member if necessary by ending each statement with a semicolon. PS: The variable example above obviously only works with embedded SQL in RPG or COBOL.
    0 pointsBadges:
    report
  • TomLiotta
    The variable example above obviously only works with embedded SQL in RPG or COBOL. It also works in REXX, often easier and more flexible. Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following