View previous topic :: View next topic |
Author |
Message |
pradeepg1 Beginner
Joined: 06 Jan 2003 Posts: 20 Topics: 7 Location: Columbus, OH
|
Posted: Thu Feb 27, 2003 4:39 pm Post subject: Host variables in SQL INSERT for mass data insert |
|
|
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 |
|
|
gotluru Beginner
Joined: 17 Dec 2002 Posts: 29 Topics: 6
|
Posted: Thu Feb 27, 2003 5:29 pm Post subject: |
|
|
Yes, you can use |
|
Back to top |
|
|
pradeepg1 Beginner
Joined: 06 Jan 2003 Posts: 20 Topics: 7 Location: Columbus, OH
|
Posted: Thu Feb 27, 2003 6:02 pm Post subject: |
|
|
Thanks Gotluru. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Thu Feb 27, 2003 7:05 pm Post subject: |
|
|
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 |
|
|
pradeepg1 Beginner
Joined: 06 Jan 2003 Posts: 20 Topics: 7 Location: Columbus, OH
|
Posted: Fri Feb 28, 2003 8:04 am Post subject: |
|
|
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 |
|
|
|
|