MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Host variables in SQL INSERT for mass data insert

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
pradeepg1
Beginner


Joined: 06 Jan 2003
Posts: 20
Topics: 7
Location: Columbus, OH

PostPosted: Thu Feb 27, 2003 4:39 pm    Post subject: Host variables in SQL INSERT for mass data insert Reply with quote

Hi All,

Can I use host variables in SQL INSERT statement when I am selecting records from other table. Here is the code please advice me.

TABLE-A has FOLLOWING COLUMNS

COLUMN1-A, COLUMN2-A, COLUMN3-A, COLUMN4-A

And I am inserting the records into TABLE-B by selecting records from TABLE-A

Here is my INSERT statement

MOVE 'USA' TO WS-VALUE2
MOVE 'COLUMBUS' TO WS-VALUE4

INSERT INTO TABLE-A
SELECT COLUMN1-B, :WS-VALUE2, COLUMN3-B, :WS-VALUE4
FROM TABLE-B;

Any body has used like above. Please share your thoughts

Thanks,
Pradeep
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
gotluru
Beginner


Joined: 17 Dec 2002
Posts: 29
Topics: 6

PostPosted: Thu Feb 27, 2003 5:29 pm    Post subject: Reply with quote

Yes, you can use
Back to top
View user's profile Send private message
pradeepg1
Beginner


Joined: 06 Jan 2003
Posts: 20
Topics: 7
Location: Columbus, OH

PostPosted: Thu Feb 27, 2003 6:02 pm    Post subject: Reply with quote

Thanks Gotluru.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Feb 27, 2003 7:05 pm    Post subject: Reply with quote

pradeepg1,

It is always a good idea to use the host variables. It eliminates the errors of defining the working storage fields correctly( viz..size and type). Most shops have the standard of using host variables in the sql statements.

Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pradeepg1
Beginner


Joined: 06 Jan 2003
Posts: 20
Topics: 7
Location: Columbus, OH

PostPosted: Fri Feb 28, 2003 8:04 am    Post subject: Reply with quote

Kolusu,

I agree 100% with you about usage of host variables. My question is specific to mass insert into table A by selecting records from table B. While doing that if I don't have one to one column raltion b/w 2 tables then I would have to use constant values for those columns which are not coming from table A. I was told that I can use constants in SELECT statement with combinaiton of INSERT statement. But not sure wether I can use host varaibles, just want to make sure.

Thanks again.

Pradeep
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group