View previous topic :: View next topic
|
Author |
Message |
Furor
New User
Joined: 04 Jun 2009 Posts: 30 Location: Bangalore
|
|
|
|
Hi,
Is it possible to code multiple-row-insert in COBOL using a Dynamic SQL?
Has anyone attempted it in past.
Code: |
STRING
'INSERT INTO TABLE.ABC VALUES'
DELIMITED BY SIZE
WS-VARIABLE(I)
DELIMITED BY SIZE
INTO
SAMPLE-TEST
EXEC SQL
PREPARE STMT1 FROM :SAMPLE-TEST
END-EXEC |
This way i can get only ONE OCCURENCE using the subscript to get inserted.
Let me know if there is a way possible for multiple-row-insert in COBOL using a Dynamic SQL
Thanks |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
Back to top |
|
|
Furor
New User
Joined: 04 Jun 2009 Posts: 30 Location: Bangalore
|
|
|
|
Thanks...I did go through these links before... But they don't work in COBOL on those lines. Say while PREPARE if I use '?' For a host variable it doesn't work. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
"it doesn't work" is synonym for "I don't know how" ? |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Furor wrote: |
Thanks...I did go through these links before... But they don't work in COBOL on those lines. Say while PREPARE if I use '?' For a host variable it doesn't work. |
Please show what you've tried and possibly you might get some close answers to your problem. |
|
Back to top |
|
|
Furor
New User
Joined: 04 Jun 2009 Posts: 30 Location: Bangalore
|
|
|
|
So true...and therefore I asked is there a way.... I showed what I am trying to do.. Which is not working.. U can take it as another synonym.. |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
ffs:
stating something "doesn't work" is not a very useful starting point for us to help you. I can point you to the codes & messages manual. I'm sure one of the 10.000 "programmers responses" in it might help you.
google "db2 multi row insert"
google "db2 parameter markers cobol"
Post some errorcodes you are receiving |
|
Back to top |
|
|
Furor
New User
Joined: 04 Jun 2009 Posts: 30 Location: Bangalore
|
|
|
|
Code: |
01 STRING-VARIABLE.
49 STRING-VAR-LEN PIC S9(4) COMP VALUE +200.
49 STRING-VAR-TXT PIC X(200).
01 I PIC S9(04) COMP VALUE ZEROES.
01 WS-ACT-NO PIC X(9) OCCURS 100 TIMES. |
Code: |
MOVE +47 TO STRING-VAR-LEN
MOVE SPACES TO STRING-VAR-TXT |
Code: |
STRING 'INSERT INTO TABLE_ABC (ACT_NO) VALUES ? '
DELIMITED BY SIZE
INTO STRING-VAR-TXT |
Code: |
EXEC SQL
PREPARE STMT1 FROM :STRING-VARIABLE
END-EXEC. |
Code: |
EXEC SQL
EXECUTE STMT1 USING :WS-ACT-NO FOR :I ROWS
END-EXEC. |
Prepare runs fine. Execute error give SQL code -313
Quote: |
-313
THE NUMBER OF HOST VARIABLES SPECIFIED IS NOT EQUAL TO THE NUMBER OF PARAMETER MARKERS |
I have tried other permutations and combinations ... this is the last one i coded.
So, just wanted to know that has anyone coded "multiple-row-insert in COBOL using a Dynamic SQL " before. |
|
Back to top |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
Well, just for starters WS-ACT-NO is 100 variables (OCCURS 100). Have you tried various permutations around that fact? |
|
Back to top |
|
|
Furor
New User
Joined: 04 Jun 2009 Posts: 30 Location: Bangalore
|
|
|
|
Just finished my main course -
Code: |
MOVE +19 TO ATT-VAR-LEN
STRING ' FOR MULTIPLE ROWS '
DELIMITED BY SIZE
INTO ATT-VAR-TXT
EXEC SQL
PREPARE STMT1 ATTRIBUTES :WS-ATT
FROM :STRING-VARIABLE
END-EXEC. |
Thanks |
|
Back to top |
|
|
|