Solving SQLCODE= -303.
-
- Registered Member
- Posts: 28
- Joined: Sun Sep 01, 2013 4:56 pm
Solving SQLCODE= -303.
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!
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!
-
- Global Moderator
- Posts: 837
- Joined: Wed Sep 11, 2013 3:57 pm
Re: Solving SQLCODE= -303.
why not look at the manuals YourselfSQL CODE OF -303.
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
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
-
- Registered Member
- Posts: 28
- Joined: Sun Sep 01, 2013 4:56 pm
Re: Solving SQLCODE= -303.
Thanks enrico.
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.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.
- Akatsukami
- Global Moderator
- Posts: 122
- Joined: Tue Oct 20, 2015 3:20 am
- Location: Bloomington, IL
- Contact:
Re: Solving SQLCODE= -303.
Are you using DSNTIAD to format the message? If not, do so and display to a suitable DDname.
"I come to the conclusion that, men loving according to their own will and fearing according to that of the prince, a wise prince should establish himself on that which is in his own control and not in that of others." -- Niccolò Machiavelli
- Anuj Dhawan
- Founder
- Posts: 2816
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: Solving SQLCODE= -303.
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,
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
Anuj
Disclaimer: My comments on this website are my own and do not represent the opinions or suggestions of any other person or business entity, in any way.
-
- Registered Member
- Posts: 28
- Joined: Sun Sep 01, 2013 4:56 pm
Re: Solving SQLCODE= -303.
Thanks. It did work with this change! Thanks enrico and Anuj!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.
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute