IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Db2 error in Pl/1 program


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 1:41 pm
Reply with quote

For someone who doesn't know how to define an integer host-variable in PL/1 you are very persistent in trying something that will NEVER work.
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 1:42 pm
Reply with quote

Can you please tel me how do i resolve the issue ?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 1:47 pm
Reply with quote

I already told you.
Now take up a manual and search for how to define an integer host variable.

but because spring is in the air, I did it for you :
publib.boulder.ibm.com/infocenter/dzichelp/v2r2/topic/com.ibm.db29.doc.apsg/db2z_equivalentplidatatypes.htm
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 1:55 pm
Reply with quote

thnx for your help.
You mean TBL_DUR should be declared as FIXED BIN equivalent to INTEGER ?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 2:33 pm
Reply with quote

GuyC wrote:
You can not have a hv that contains '5 days' and expect it to work in static SQL.

so forget about TBL_DUR
try the suggestion I gave you :
GuyC wrote:
Code:
...B.Date BETWEEN DATE(:old_DATE) - :Daydur days - :yeardur years
                            AND DATE(:old_DATE) - 1 DAY;     

and define daydur and yeardur as integers
----------------------------------------------------------------------------------
OR:
Oops, I followed my own advice and went back to the manual, following the link Akatsukami posted.
Apparently there is such a thing as duration decimal(8,0) which you can subtract or add to a date.
so :

Code:
DCL DURATION         DEC FIXED(8,0);
..
DURATION  = 00010000; <== 1 year
or
DURATION  = 00000005; <== 5 days
...
B.Date BETWEEN DATE(:old_DATE) - :DURATION
                     AND DATE(:old_DATE) - 1 DAY;
..
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 4:17 pm
Reply with quote

i used first method and it is now getting bound properly. but facing -180 sqlcode with *N.

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.codes/n180.htm
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Wed Mar 16, 2011 5:06 pm
Reply with quote

venuhunev wrote:
i used first method and it is now getting bound properly. but facing -180 sqlcode with *N.

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.codes/n180.htm

As a SQLCODE of -180 indicates -- according to the manual -- that a date, time, or timestamp value is of incorrect format, don't you think that it would be a good idea to exhibit your code -- principally but not necessarily limited to your host variable declarations and embedded SQL -- and to add as many PUT EDIT statements immediately prior to execution as are needed to display those variable's values, and to also show that output?

I'm sorry if it is viewed as politically incorrect, but reading and understanding a few manual pages on the part of the querents would probably reduce the traffic on this site to a few percent of its present value.
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Wed Mar 16, 2011 5:09 pm
Reply with quote

Quote:
I'm sorry if it is viewed as politically incorrect, but reading and understanding a few manual pages on the part of the querents would probably reduce the traffic on this site to a few percent of its present value.

Yes, but that would reduce the laughs that I have had - particularly the thread about trying to compile a mix of COBOL and ForTran!!!!!!!!
Back to top
View user's profile Send private message
don.leahy

Active Member


Joined: 06 Jul 2010
Posts: 765
Location: Whitby, ON, Canada

PostPosted: Wed Mar 16, 2011 5:19 pm
Reply with quote

Akatsukami wrote:

I'm sorry if it is viewed as politically incorrect, but reading and understanding a few manual pages on the part of the querents would probably reduce the traffic on this site to a few percent of its present value.

And what was left would be *much* more interesting.

I sometimes wonder if some of the topic starters on this board are being willfully obtuse in the hope that someone will get impatient and just give them the code.
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 5:42 pm
Reply with quote

Hi all, thnx for your inputs.

i found why it is giving -180

Code:
DCL DATE1 CHAR(12);
DATE1 = "'" || INPUT.DATE || "'";
DATE(DATE1) - :dur1 year - :dur2 day --> since DATE1 is of 12 chars.


But when i run
Code:
DATE(INPUT.DATE)  - :dur1 year - :dur2 day

am not getting any error but not the desired output.


Quote:
DUMMY RUN:
Code:
select date(2011-02-13) - 1 year, date('2011-02-13') - 1 year
from sysibm.sysdummy1


it gives
Code:
0005-06-19, 2010-02-13


I need the latter so i used 12 CHARS but getting -180 *N.
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 5:57 pm
Reply with quote

plz help how to resolve..
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 6:20 pm
Reply with quote

wow, this is the first time i see someone counting the quotes as part of the length.
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 6:33 pm
Reply with quote

if it is not counted, DATE1 field - '2011-02-13' is getting truncated - '2011-02-1
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 6:35 pm
Reply with quote

this is the difference why Quotes are needed.

DUMMY RUN:
Code:
select [b]date(2011-02-13) - 1 year[/b], [u]date('2011-02-13') - 1 year[/u]
from sysibm.sysdummy1



it gives
Code:
[b]0005-06-19[/b], [u]2010-02-13[/u]
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 7:35 pm
Reply with quote

I'm glad you take the time to explain me why the quotes are needed and why it should be char(12) . But unfortenately you have no idea what you are talking about.

a literal '2011-02-13' is equivalent to a char variable containing 2011-02-13
a literal 2011-02-13 is actually not a literal but a computation 2011 - 02 - 13 which is equivalent to 1996

don.leahy wrote:
I sometimes wonder if some of the topic starters on this board are being willfully obtuse in the hope that someone will get impatient and just give them the code.


Code:
   DCL OLD_DATE CHAR(10);
   DCL OUTPUT_DATE CHAR(10);
   DCL WORK_DAYS  FIXED BIN(15);

   OLD_DATE = '2011-02-13';
   WORK_DAYS  = 5;
   EXEC SQL
       SELECT DATE(:OLD_DATE) - :WORK_DAYS DAYS
          INTO :OUTPUT_DATE FROM SYSIBM.SYSDUMMY1;
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 7:59 pm
Reply with quote

you mean to say the above code is same as below. i dont think so.
considering INP_DATE from input file or SYSIN = 2011-02-13


Code:
   
DCL INP_DATE CHAR(10);
DCL OLD_DATE CHAR(10);
   DCL OUTPUT_DATE CHAR(10);
   DCL WORK_DAYS  FIXED BIN(15);

   OLD_DATE = INP_DATE;
   WORK_DAYS  = 5;
   EXEC SQL
       SELECT DATE(:OLD_DATE) - :WORK_DAYS DAYS
          INTO :OUTPUT_DATE FROM SYSIBM.SYSDUMMY1;



DUMMY RUN:
Code:
select [b]date(2011-02-13) - 1 year[/b], [u]date('2011-02-13') - 1 year[/u]
from sysibm.sysdummy1

it gives
[b]0005-06-19[/b], [u]2010-02-13[/u]
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Wed Mar 16, 2011 8:25 pm
Reply with quote

2011 minus 2 minus 13 is 1996.

Day 1996, counting from 01/01/01:
Year 1901 has 365 days
Year 1902 has 365 days
Year 1903 has 365 days
Year 1904 has 366 days
Year 1905 has 365 days
This totals 1826 days. 1996 minus 1826 is 170.

June 19 is Julian day 170. So 2011-02-13 in DB2 converts to 0005/06/19.
Quote:
i dont think so.
You need to stop that -- you don't do it very well.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Wed Mar 16, 2011 9:03 pm
Reply with quote

good luck
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Wed Mar 16, 2011 10:22 pm
Reply with quote

Hi..


Code:
select [b]date(2011-02-13) - 1 year[/b], [u]date('2011-02-13') - 1 year[/u]
from sysibm.sysdummy1

it gives
[b]0005-06-19[/b], [u]2010-02-13[/u]


I understand the arithmetic involved in date(2011-02-13) - 1 year. thnx for that.
but my requirement is date('2011-02-13') - 1 year and date being passed from JCL.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Thu Mar 17, 2011 3:13 pm
Reply with quote

Can you repeat the question ? I still don't like the answers already given , I think they are wrong so I don't even want to try them.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Thu Mar 17, 2011 4:22 pm
Reply with quote

I believe that the duration needs to be declared as FIXED DEC (15,0), not as FIXED BIN (15) (the DB2 SQL reference appears to support this).

With this change, I have taken GuyC's code, successfully pre-compiled and compiled it, successfully link-edited it, successfully bound the package and the plan, and have written and successfully run JCL that executes that program via background TSO, taking the date as a parameter. I repeat "successfully" to emphasize that I had no problem in doing these things.
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Sat Mar 19, 2011 9:00 am
Reply with quote

Hi..

select date(2011-02-13) - 1 year, date('2011-02-13') - 1 year
from sysibm.sysdummy1

it gives
0005-06-19, 2010-02-13


I understand the arithmetic involved in date(2011-02-13) - 1 year. thnx for that.
but my requirement is date('2011-02-13') - 1 year and date being passed from JCL.

Bolded is the problem now which gives the abend as the value is passed from the input file

Input file: 2011-02-13
I want to have the value in query as date('2011-02-13')
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Sat Mar 19, 2011 11:27 am
Reply with quote

Have you tried having '2011-02-13' in your input file instead of just 2011-02-13??
Back to top
View user's profile Send private message
venuhunev

New User


Joined: 26 May 2007
Posts: 70
Location: chennai

PostPosted: Sat Mar 19, 2011 12:34 pm
Reply with quote

Nope. cant change the input field as per the requirements.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Sat Mar 19, 2011 8:31 pm
Reply with quote

You don't know PL/I, do you?

You have been given the exact solution. You cannot understand it. You do not know how to test it. You do not know how to implement it. You can only repeat nonsense that reveals your ignorance, and have wasted three days doing so.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2 Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts Error to read log with rexx CLIST & REXX 11
No new posts Error when install DB2 DB2 2
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts DB2 Event passed to the Application P... DB2 1
Search our Forums:

Back to Top