Page 1 of 2

Dynamic sql with cobol(-313 error)

PostPosted: Fri Aug 13, 2010 2:51 pm
by ballaravi
hi, i am getting -313 error when doing dynamic sql through cobol,
i am putting screen shot,just check that and jcl code.

Re: Dynamic sql with cobol(-313 error)

PostPosted: Fri Aug 13, 2010 2:58 pm
by NicC
Why have you quoted the second ? ?

Re: Dynamic sql with cobol(-313 error)

PostPosted: Fri Aug 13, 2010 3:20 pm
by ballaravi
second one is char type,thats why i quated

Re: Dynamic sql with cobol(-313 error)

PostPosted: Fri Aug 13, 2010 3:48 pm
by NicC
Did you read the manual? It says to use ? for each variable it makes no mention of quoting. It does mention using CAST if you want to bind a type to a particular ?

Re: Dynamic sql with cobol(-313 error)

PostPosted: Fri Aug 13, 2010 4:10 pm
by ballaravi
ok, tomo i will check in my lab and give reply to u

Re: Dynamic sql with cobol(-313 error)

PostPosted: Sat Aug 14, 2010 12:10 am
by dick scherrer
Hello,

When posting information from a terminal, you should use copy/paste and the "Code" tag. "Screenshots" only waste space for no additional value.

Thanks,

d

Re: Dynamic sql with cobol(-313 error)

PostPosted: Sat Aug 14, 2010 6:15 pm
by ballaravi
hi,
The problem is sloved after removing the quote, it executed successfully.

but other problem came when modified code.

BEFORE:(CHECK THE SCREEN SHOT)
000023 MOVE 3 TO TESTNO.
000024 MOVE "TEST3" TO TESTNAME.


AFTER CODE CHANGED:
000023 ACCEPT TESTNO.
000024 ACCEPT TESTNAME.


JCL:
//SYSIN DD *
4
TEST4
/*


THE ERROR IS:
AT "ACCEPT TESTNO" -- IDENTIFIER TESTNO(BINARY INTEGER) WAS GIVEN IN ACCEPT.
THE STATEMENT IS DISCARDED.

HOW TO SLOVE THIS ?

Re: Dynamic sql with cobol(-313 error)

PostPosted: Sat Aug 14, 2010 7:31 pm
by NicC
Accept it into a compatible format, 'PIC 9'?, and move it to TESTNO. Or change your input to Binary Integer

Re: Dynamic sql with cobol(-313 error)

PostPosted: Sat Aug 14, 2010 11:54 pm
by dick scherrer
Hello,

ACCEPT is not usually permitted in programs that are to be promoted to Production. Multiple accepts is an even bigger no-no. A file should be defined and read to get these values into the code.

When bringing in data from "outside", PIC X(n) fields should be used and after the data has been validated, the values moved to the desired internal formats. The mainframe is rather picky about having valid numbers in fields that are to be used in numeric instructions (including move).

Or change your input to Binary Integer
You probably do not want to define the SYSIN data in binary. . . Simply do as suggested and move the character data to the binary field after the character value is validated.

Re: Dynamic sql with cobol(-313 error)

PostPosted: Sun Aug 15, 2010 2:59 pm
by ballaravi
who to change INPUT to BINARY INTEGER
(i.e for 4 to 0100) like this or any other way.