Page 1 of 1
Solving SQLCODE= -303.
Posted: Wed Dec 16, 2015 2:51 pm
by Anushka Sharma
Hello,
I have written a test COBOL program. I am using SCALAR function YEAR in the program. Function is used to get the Year part from the date from DB2 table. The corresponding host variables are PIC X() The problem is my program abends at the FETCH statement with a SQL CODE OF -303.
How do I correct it and figure out what might be causing the problem? Please help.
TIA!
Re: Solving SQLCODE= -303.
Posted: Wed Dec 16, 2015 3:33 pm
by enrico-sorichetti
SQL CODE OF -303.
why not look at the manuals Yourself
and come back if there is something You do not understand ?
to save You some of Your precious time here is a link to the -303 explanation
https://www-01.ibm.com/support/knowledg ... /n303.html
Re: Solving SQLCODE= -303.
Posted: Fri Dec 18, 2015 2:16 pm
by Anushka Sharma
Thanks enrico.
A VALUE CANNOT BE ASSIGNED TO OUTPUT HOST VARIABLE NUMBER position-number BECAUSE THE DATA TYPES ARE NOT COMPARABLE
Explanation
A CALL, FETCH, SELECT, VALUES INTO, or SET statement with an output host variable could not be performed because the data type of a variable was not compatible with the data type of the corresponding SELECT, VALUES INTO, or SET statement list element.
position-numberLocation of the host variable value in the output SQLDA.
The values of the output host variable and the corresponding list element must be in one of the following categories:
•One value is numeric and one of the following conditions is true:◦The other value is also numeric.
◦The other value is a character string.
◦The other value is a graphic string and uses Unicode.
◦The statement has a subtype of FOR BIT DATA.
•Both must be character strings, unless you are using Unicode.
•Both must be graphic strings, unless you are using Unicode.
•Both must be row IDs.
•Both must be binary strings, or one can be BINARY or VARBINARY, and the other can be FOR BIT DATA.
• A variable is XML or binary XML and the corresponding statement list element is XML.
In addition, for datetime or timestamp values, the target host variable must be a character string variable with a correct length.
I looked at above alrady and changed the data type of the host variable to character but that did nto solve the problem and I asked here. Not sure what is causing this problem but I am working on it. Asking to seniors too.
Re: Solving SQLCODE= -303.
Posted: Fri Dec 18, 2015 5:38 pm
by Akatsukami
Are you using DSNTIAD to format the message? If not, do so and display to a suitable DDname.
Re: Solving SQLCODE= -303.
Posted: Sun Dec 20, 2015 5:19 pm
by Anuj Dhawan
The result of the function YEAR should be large integer (S9(09) COMP) and should be defined as binary of 4 bytes. Change the host variable definition and see if it works. And if it does, you should read back what Enrico has said initially and you'll realize that you had the answer right there.
Re: Solving SQLCODE= -303.
Posted: Mon May 09, 2016 3:28 pm
by Anushka Sharma
Anuj Dhawan wrote:The result of the function YEAR should be large integer (S9(09) COMP) and should be defined as binary of 4 bytes. Change the host variable definition and see if it works. And if it does, you should read back what Enrico has said initially and you'll realize that you had the answer right there.
Thanks. It did work with this change! Thanks enrico and Anuj!