Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
Resolving -311 Sql code

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
Author Message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Sat May 03, 2008 2:45 pm    Post subject: Resolving -311 Sql code
Reply with quote

Hi,

There is already some posts in the forum regarding resolving of -311.
However, I could not get my error resolved....I am performing a Table UNLOAD which needs an additional column DT_BEGIN, basically a date field.
My code is
Code:

Select ........
        ,CASE
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=1 THEN CURRENT_DATE
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=2 THEN CURRENT_DATE - 1 DAYS
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=3 THEN CURRENT_DATE - 2 DAYS
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=4 THEN CURRENT_DATE - 3 DAYS
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=5 THEN CURRENT_DATE - 4 DAYS
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=6 THEN CURRENT_DATE - 5 DAYS
 WHEN DAYOFWEEK_ISO(CURRENT_DATE)=7 THEN CURRENT_DATE - 6 DAYS
 END
........


I am getting -311 when I run my job....Could any one please
throw some light on this ?

Thanks and Regards,
Puspojit
Back to top
View user's profile Send private message
References
PostPosted: Sat May 03, 2008 2:45 pm    Post subject: Re: Resolving -311 Sql code Reply with quote

Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 709
Location: Virginia, USA

PostPosted: Sat May 03, 2008 8:08 pm    Post subject:
Reply with quote

Have you looked up the meaning of -311? If you had you would know that the part of your sql statement you are showing is missing some important information.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Mon May 05, 2008 3:04 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Hi Craq,

I did go thru the error and its possible cause.The error was, I guess,
due to negative length of Input host variable as it is defined as a smallint.
However, I could not understand how do I change the length of this field because I get same error code when I try to cast it.....
Please note that I am performing an UNLOAD only
As of now,I simply used this code:
Code:

select....
dayofweek(current_date)
....

After downloading the table, I run a sort step to update the date in the required field by comparing the day of week.

Please suggest me a smarter way out thru DB2.
Thanks and Regards,
Puspojit
Back to top
View user's profile Send private message
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 903
Location: germany

PostPosted: Mon May 05, 2008 3:50 pm    Post subject:
Reply with quote

Code:

 SELECT
         CASE
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=1 THEN CURRENT_DATE
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=2 THEN CURRENT_DATE - 1 DAYS
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=3 THEN CURRENT_DATE - 2 DAYS
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=4 THEN CURRENT_DATE - 3 DAYS
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=5 THEN CURRENT_DATE - 4 DAYS
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=6 THEN CURRENT_DATE - 5 DAYS
  WHEN DAYOFWEEK_ISO(CURRENT_DATE)=7 THEN CURRENT_DATE - 6 DAYS
  END
         AS DT_BEGIN
FROM SYSIBM.SYSDUMMY1
;


i imagine had you used proper syntax you would have had an exceptable result.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Mon May 05, 2008 4:02 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Hello,

I did use the syntax which you had given but got the same error -311.
Please note that the query which I had posted earlier/and the one you had posted are running perfectly fine when I run them through QMF.
the problem crops up only when I try to use them in UNLOAD program.

Do let me know if there is something else I can try.

Regards,
Puspojit.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 903
Location: germany

PostPosted: Mon May 05, 2008 4:25 pm    Post subject:
Reply with quote

I don't believe you.

I just appended the above sql to an existing sql used in an unload using DSNTIAUL and it worked fine. The generated SYSREC00 looks good.

though, I can not reload this table because my destination table (the one to be loaded) does not have the date column, I am sure you have a good reason to appended this column (even though the value is the same for every row) to every row that you unload.

because you first post was incomplete, I simply do not trust your analysis.

leaving off the select and the from clause, you should be able to add the case statement (from my earlier post) to any unload thus adding an additional column.

Quote:

Do let me know if there is something else I can try


keep working until your syntax is correct.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Mon May 05, 2008 5:02 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Hi.....

May be you do not believe my analysis but I got the same error code....once again.The only thing I got from your post is you executed the query through DSNTIAUL and I used a high performance utility to achieve the same. I checked it with DSNTIAUL and it gives the expected results(it works with DSNTIAUL).
I am not sure whether the High Performance Utility has some
Limitation but as far as syntax error is concerned, chances are bleak
because the whole of day of mine was dedicated to this but still now it has been an exercise of futility.

Do let me know if DSNTIAUL is the only way out to meet this requirement or High Performance utility can be used ?


Regards,
Puspojit.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 903
Location: germany

PostPosted: Mon May 05, 2008 5:12 pm    Post subject:
Reply with quote

well, you have 'high performance utlity', which only you know, which only you have access to documentation, because no one else knows this 'high performance utility'.

Since DSNTIAUL works and your 'high performance utlity' utilty does not, either:

1.) tell us the name of the high performance utility

2.) RTFM about your 'high performance utlity'.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Mon May 05, 2008 5:31 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Sorry.......Its INZUTILB.
Please check if its working with this utility....

Regards,
Puspojit.
Back to top
View user's profile Send private message
acevedo

Active User


Joined: 11 May 2005
Posts: 252
Location: Spain

PostPosted: Mon May 05, 2008 5:47 pm    Post subject: Re: Reply to: Resolving -311 Sql code
Reply with quote

Puspojit wrote:
Sorry.......Its INZUTILB.
Please check if its working with this utility....

Regards,
Puspojit.


Puspojit not all the shops has INZUTILB.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 903
Location: germany

PostPosted: Mon May 05, 2008 5:56 pm    Post subject:
Reply with quote

I have no experience with INZUTILB. I did a quick google and read a little:

INZUTILB, a DB2 utility, seems to only work with tables (does not work with views) and since you can add columns, why don't you add a date column and populate it?


again, why do you need this date column? which will be the same for every row?

you could include in you jcl a step that would unload the date (as the sql would generate it) into a 1 record unload file. then you will have two unload files: 1) the date, 2) the rows unloaded.
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Tue May 06, 2008 5:54 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Hi,

Is'nt there any solution of this problem through INZUTLIB ?
Please advice.

Thanks,
Puspojit
Back to top
View user's profile Send private message
dbzTHEdinosauer

Senior Member


Joined: 20 Oct 2006
Posts: 903
Location: germany

PostPosted: Tue May 06, 2008 6:59 pm    Post subject:
Reply with quote

why do you need the date? please advise....................
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Tue May 06, 2008 9:15 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Hi,
[/code]why do you need the date? please advise
Code:


There are quite a number of tables needed to be downloaded and this is a weekly job as I had said....Now the task requires to have a field in the O/P file which shall identify which date did the process actually start which essentially has to be the first day of the week,Monday.
Thus for a particular day when the table is unloaded, I need to populate the date of Monday in the O/P file...hence my question arises.
Since,I am able to fetch the DAYOFWEEK through INZUTLIB,
The only thing I could think of till now is to populate the DAYOFWEEK in the DT_BEGIN field and then through a sort card/program pick that value from the field and overlay it with appropriate date by using the conversion
    DT_BEGIN=Current Date - DAYOFWEEK.

But this shall require another file to be created which is what I want to avoid............Please suggest a way out.

Thanks,
Puspojit
[/quote]
Back to top
View user's profile Send private message
Puspojit

New User


Joined: 10 Mar 2008
Posts: 26
Location: Pune

PostPosted: Wed May 07, 2008 3:42 pm    Post subject: Reply to: Resolving -311 Sql code
Reply with quote

Hi,

I found an intresting discovery in my problem :

The query is working fine when I download a table having less than 100 columns but it abends as soon as columns downloaded are more than 100.
Earlier, I was downloading a table having 122 cols and another having197 cols. The job was abending. But when I used the same query to download tables having less than 100 cols, it was working perfectly........I do not know whether it is a mere co-incidence or is it any limitation of INZUTLIB?

Any Comments...........
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1