View previous topic :: View next topic
|
Author |
Message |
lanand_hps
New User
Joined: 05 Dec 2007 Posts: 82 Location: chennai
|
|
|
|
Hi,
The below query is resulting in -303 sqlcode.
SELECT MAX(A.PAPER_ONLY_DLVY)
INTO :WS-PAPER-ONLY-DLVY:WS-NULL-IND
FROM PAY_CAL_DETL A
WHERE A.OWNING_CARRIER = 'MU'
AND A.PAY_CALENDAR_ID = 'MU-MONTHLY'
AND A.PAPER_ONLY_DLVY <= CURRENT DATE
The field PAPER_ONLY_DLVY is DATE NOT NULL in database.
I've defined the host variable WS-PAPER-ONLY-DLVY as X(10)
I read the description for -303. It says mismatch in pic clause of host variable and table variable. But it is correct.
Your views please.. |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Quote: |
I read the description for -303. It says mismatch in pic clause of host variable and table variable. But it is correct.
Your views please..
|
i have found that db2 does not make that many mistakes. i imagine that the definition of the column is not as you think.
go to the ibm sys tables to get the definition of this column. do not rely on dclgen. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
If it's NOT NULL, then why are you giving a NULL INDICATOR for it? That seems kind of silly. Also, why aren't you using the DCLGEN? It usually helps to eliminate things like this. |
|
Back to top |
|
|
lanand_hps
New User
Joined: 05 Dec 2007 Posts: 82 Location: chennai
|
|
|
|
Mr.Steve, I have used MAX function that made me use null indicator, even if the field itself is NOT NULL by definition. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
The only way MAX can return NULL is as follows (from the manual):
If the function is applied to an empty set, the result is the null value. Otherwise, the result is the maximum value in the set.
Because the field is defined NOT NULL, that would mean your whole table would have to be empty in order for you to get a NULL back from the MAX function.
However, if you still feel you need the null indicator defined, you should get the syntax on the command correct. See below.
Code: |
SELECT MAX(A.PAPER_ONLY_DLVY)
INTO :WS-PAPER-ONLY-DLVY.WS-NULL-IND
FROM PAY_CAL_DETL A
WHERE A.OWNING_CARRIER = 'MU'
AND A.PAY_CALENDAR_ID = 'MU-MONTHLY'
AND A.PAPER_ONLY_DLVY <= CURRENT DATE
|
You put a . between a ws field and the null indicator for it, not a : |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Steve,
normally you are right on.
but, if the result set is Null (due to the where clause), he will indeed have a Null returned.
and his syntax works in my world. actually, you have created a qualifier 'ws-paper-only-dlvy for element ws-null-ind. |
|
Back to top |
|
|
stodolas
Active Member
Joined: 13 Jun 2007 Posts: 632 Location: Wisconsin
|
|
|
|
Early morning reading is not always recommended.
I had never seen the :wsvar:ws-null-ind used anywhere in my world, only the . notation... |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
Steve,
as I was preparing an answer to you, it occured to me to ask the OP,
what is the picture clause for WS-NULL-IND?
back to Steve;
normally i code :Host-var :Null-ind space inbetween - but the db2 precompiler for vsn 6 & 7 also allow for no space. I have always used a period to separate the qualifier from the element. |
|
Back to top |
|
|
lanand_hps
New User
Joined: 05 Dec 2007 Posts: 82 Location: chennai
|
|
|
|
The picture clause i use for null indicators is S9(04) COMP.
We always use :Host-var notation and not "." |
|
Back to top |
|
|
|