Selecting and inserting library names

pts.
Tags:
DB2 Universal Database
Jeremy wrote in with this question recently: "Within an /exec SQL statement, I want to select from a file in one library and insert into the same file in a second. How should I refer to the library names? The editor rejects my attempts to refer to the libraries as host variables as per the following 'insert into :tolib/file1 (select * from :fromlib/file1)." Can you offer Jeremy some advice? -- Debra Tart, associate editor, Search400.com

Answer Wiki

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

I inserted the following into a CLLE program. You then can use the eseq and substitute the variable for the SQL statement you just created:

CHGVAR VAR(&SQLSTMT) VALUE(‘CREATE TABLE +
QTEMP/INTHDR (MIQHFT CHAR (6 ) NOT NULL +
WITH DEFAULT, MIQUID CHAR (8 ) NOT NULL +
WITH DEFAULT)’)
ESQL SQLSTM(&SQLSTMT)

Discuss This Question: 2  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
  • JPLamontre
    You can uses sql ALIAS or clp OVRDBF to temporarily rename each file : this will provide a way to your code to work with two distinct "virtualized" files
    0 pointsBadges:
    report
  • TheQuigs
    It's really very simple. He won't need any host variables, alias, etc. Simply code the statement similar to the following: insert into lib1/filename select * from lib2/filename Selection criteria (where) can be applied to the select statement.
    0 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