NULL and SQLCODE -305.
-
- New Member
- Posts: 7
- Joined: Wed Jan 20, 2016 12:26 am
NULL and SQLCODE -305.
Hi,
In my program Ihave a select statemnet. In that select I am using a a null column. How can I know that I am selecting a null column. If I check only SQLCODE -305, will that be fine. If it is not, why it is not coded this way...
In my program Ihave a select statemnet. In that select I am using a a null column. How can I know that I am selecting a null column. If I check only SQLCODE -305, will that be fine. If it is not, why it is not coded this way...
-
- Global Moderator
- Posts: 588
- Joined: Wed Nov 20, 2013 11:53 am
- Location: Mars
Re: NULL and SQLCODE -305.
You might also need to follow your company standard procedure for all the validations that needs to be done.. Talk to your team or check the existing programs and that should answer your question
zprogrammer
Re: NULL and SQLCODE -305.
If NULL can be returned instead of a column value then you should be coding a Null indicator variable alongside the variable that would have the value returned in it if there was a value to return.
Regards
Nic
Nic
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: NULL and SQLCODE -305.
The short answer is - you can do that.Krishna singh wrote:Hi,
In my program Ihave a select statemnet. In that select I am using a a null column. How can I know that I am selecting a null column. If I check only SQLCODE -305, will that be fine. If it is not, why it is not coded this way...
The long answer is - it depends and it depends on multiple inputs; one of which is - does the short answer suffice to your needs? By definition SQLCODE -305 is:
Per the definition - if you consider this "the null value cannot be assigned to output host variable number position-number because no indicator variable is specified" and acceptable test-condition, well, you can show an appropriate message and terminate the program. However, in other world and the one which has been accepted by the larger group of programmer, we tend to take action based on the NULL indicator as nicc and Pandora-Box has also indicated to.-305
THE NULL VALUE CANNOT BE ASSIGNED TO OUTPUT HOST VARIABLE NUMBER position-number BECAUSE NO INDICATOR VARIABLE IS SPECIFIED
Explanation
A FETCH, SELECT, VALUES INTO, or SET assignment statement resulted in the retrieval of a null value to be inserted into the output host variable, designated by entry number 'position-number' of the output SQLDA, for which no indicator variable was provided. An indicator variable must be supplied if a column returns a null value.
System action
The statement cannot be processed. No data was retrieved.
Programmer response
Examine the definition of the table that is the object of the statement and correct the application program to provide indicator variables for all host variables into which null values can be retrieved. This includes host variables for columns which can contain null values and host variables which receive the results of aggregate functions whose result table could be empty.
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.
-
- New Member
- Posts: 7
- Joined: Wed Jan 20, 2016 12:26 am
- Anuj Dhawan
- Founder
- Posts: 2802
- Joined: Sun Apr 21, 2013 7:40 pm
- Location: Mumbai, India
- Contact:
Re: NULL and SQLCODE -305.
Glad, we were helpful.
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.
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