Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Passing timstamp from input file to select statement
Goto page 1, 2  Next
 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 9:52 pm    Post subject: Passing timstamp from input file to select statement
Reply with quote

i am writing a new cobol-db2 program, i am passing timstamp from input file to select statement, i need to compare the timestamp in the table with
the timestamp from the input file.

From the input file i am getting time and date as separate
time x(6) date x(8), what i am doing is i am combining this time and date
by moving to working storage ws-timestamp.

In the select query in the where clause when i specify timestamp from table > timestamp from working storage , i am getting error.
how should i specify this ,

SELECT XXX

FROM XXX
WHERE XXXX = :XXXX
AND XXX = :XXXX
AND XXX = :XXXX
AND XXX = :XXXX
AND XXXX IN ('XXXX',
'XXXX',
'XXXX',
'XXXX',
'XXXX',
'XXXX')
AND (XXX_XXX__TS > :WS-TIMESTAMP )

I am getting error as WS-TIMESTAMP undefined host-variable

Please suggest as early as possible

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

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 08, 2009 10:00 pm    Post subject:
Reply with quote

Hello,

Quote:
I am getting error as WS-TIMESTAMP undefined host-variable
Suggest this needs to be defined. . .

Not much we can help with when the system says a variable is not defined icon_confused.gif
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Jul 08, 2009 10:01 pm    Post subject:
Reply with quote

What is the definition of WS-TIMESTAMP?
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 10:11 pm    Post subject: I declared Ws-timestamp
Reply with quote

I declared ws-timestamp in my working storage as

Code:
05  WS-TIMESTAMP.                                   
    10  WS-CCYY         PIC X(04).                   
    10  FILLER              PIC X        VALUE '-'. 
    10  WS-MONTH        PIC X(02).                   
    10  FILLER              PIC X        VALUE '-'. 
    10  WS-DAY          PIC X(02).                   
    10  FILLER              PIC X        VALUE '-'. 
    10  WS-HR           PIC X(02).                   
    10  FILLER              PIC X        VALUE '.'. 
    10  WS-MIN          PIC X(02).                   
    10  WS-MIN-9        REDEFINES                   
        WS-MIN          PIC 9(02).                   
    10  FILLER              PIC X        VALUE '.'. 
    10  WS-SEC          PIC X(02).                   
    10  WS-SEC-9        REDEFINES                   
        WS-SEC          PIC 9(02).                   
    10  WS-MILLI        PIC X(07)    VALUE '.000000'.

"Code"d
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 10:15 pm    Post subject:
Reply with quote

we had a question like this a few weeks ago.

what is the level 01 definition?

or is it in a copybook?
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 10:21 pm    Post subject: 01 WS-MISC
Reply with quote

01 WS-MISC

i tried ws-timestamp as 01 level also, but i am getting error,please
suggest


thanks
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 08, 2009 10:23 pm    Post subject:
Reply with quote

Hello,

It may help if you post the "real" sql from the program rather than the many xxx's . . .
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Jul 08, 2009 10:24 pm    Post subject: Re: I declared Ws-timestamp
Reply with quote

sree reddy wrote:
I declared ws-timestamp in my working storage as

Code:
05  WS-TIMESTAMP.                                   
    10  WS-CCYY         PIC X(04).                   
    10  FILLER              PIC X        VALUE '-'. 
    10  WS-MONTH        PIC X(02).                   
    10  FILLER              PIC X        VALUE '-'. 
    10  WS-DAY          PIC X(02).                   
    10  FILLER              PIC X        VALUE '-'. 
    10  WS-HR           PIC X(02).                   
    10  FILLER              PIC X        VALUE '.'. 
    10  WS-MIN          PIC X(02).                   
    10  WS-MIN-9        REDEFINES                   
        WS-MIN          PIC 9(02).                   
    10  FILLER              PIC X        VALUE '.'. 
    10  WS-SEC          PIC X(02).                   
    10  WS-SEC-9        REDEFINES                   
        WS-SEC          PIC 9(02).                   
    10  WS-MILLI        PIC X(07)    VALUE '.000000'.

"Code"d


DB2 does not like group items.
try this
Code:
05  WS-TIMESTAMP pic x(26) value '0000-00-00-00.00.00.00000'.
   05 filler redefines ws-timestamp.
    10  WS-CCYY         PIC X(04).                   
    10  FILLER              PIC X.
    10  WS-MONTH        PIC X(02).                   
    10  FILLER              PIC X. 
    10  WS-DAY          PIC X(02).                   
    10  FILLER              PIC X. 
    10  WS-HR           PIC X(02).                   
    10  FILLER              PIC X. 
    10  WS-MIN          PIC X(02).                   
    10  WS-MIN-9        REDEFINES                   
        WS-MIN          PIC 9(02).                   
    10  FILLER              PIC X. 
    10  WS-SEC          PIC X(02).                   
    10  WS-SEC-9        REDEFINES                   
        WS-SEC          PIC 9(02).                   
    10  WS-MILLI        PIC X(07).

[/code]
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 10:41 pm    Post subject: it did not work
Reply with quote

it did not work
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 10:41 pm    Post subject:
Reply with quote

db2 wants a PIC clause, which is why a group item does not work.
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 10:43 pm    Post subject: so how should i declared
Reply with quote

if my declaration is wrong , can you suggest how to declare and use it

thanks
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 10:44 pm    Post subject:
Reply with quote

Quote:
it did not work


what is the complete pre-compiler error message (cut&paste),
show us the definition of the timestamp Host variable (cut&paste from precompiler output)
show us the sql which received the pre-compiler error message (cut&paste from precompiler output)
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 10:54 pm    Post subject: Errors
Reply with quote

DSNH312I E DSNHSMUD LINE 2311 COL 49 UNDEFINED OR UNUSABLE HOST VARIABLE "WS-timestamp
DSNH312I E DSNHSMUD LINE 2313 COL 38 UNDEFINED OR UNUSABLE HOST VARIABLE "Ws-timestamp


I declared Ws-timestamp as below

01 WS-MISC
05 WS-TIMESTAMP PIC X(26)
VALUE '0000-00-00-00.00.00.000000'.
05 FILLER REDEFINES WS-TIMESTAMP.
10 WS-CCYY PIC X(04).
10 FILLER PIC X VALUE '-'.
10 WS-MONTH PIC X(02).
10 FILLER PIC X VALUE '-'.
10 WS-DAY PIC X(02).
10 FILLER PIC X VALUE '-'.
10 WS-HR PIC X(02).
10 FILLER PIC X VALUE '.'.
10 WS-MIN PIC X(02).
10 WS-MIN-9 REDEFINES
WS-MIN PIC 9(02).
10 FILLER PIC X VALUE '.'.
10 WS-SEC PIC X(02).
10 WS-SEC-9 REDEFINES
WS-SEC PIC 9(02).
10 WS-MILLI PIC X(07) value '.000000'.

The below is the sql

EXEC SQL
DECLARE F64CURSOR CURSOR FOR
SELECT MBR_ELIGY_CVRG_TMLY_FILG_TX,
MBR_ELIGY_CVRGE_EFFV_DT,
MBR_ELIGY_CVRGE_TERMTN_DT
FROM F64_A999
WHERE CUSTOMER_ID = :ARG-F64-A999.CUSTOMER-ID
AND CLIENT_ID = :ARG-F64-A999.CLIENT-ID
AND GROUP_ID = :ARG-F64-A999.GROUP-ID
AND MEMBER_ID = :ARG-F64-A999.MEMBER-ID
AND MBR_ELIGY_CVRG_TMLY_FILG_TX IN ('DFBDE-C',
'DSSI-C',
'DPART-C',
'DLIS-C',
'DPAPER-UC',
'DPOS-UC',
'DPOS-C')
AND (MBR_ELIGY_CVRGE_ADD_TS > :WS-TIMESTAMP
OR
LAST_MNT_TS > :WS-TIMESTAMP)
End-exec

Please suggest

Thanks
Back to top
View user's profile Send private message
Craq Giegerich

Senior Member


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

PostPosted: Wed Jul 08, 2009 11:00 pm    Post subject:
Reply with quote

My error it should be pic x(27)
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Wed Jul 08, 2009 11:28 pm    Post subject: I did not get you
Reply with quote

I did not understand what you mean.

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

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 11:59 pm    Post subject:
Reply with quote

either MBR_ELIGY_CVRGE_ADD_TS or LAST_MNT_TS is not a timestamp.

or

your definition (if it is in the precompiler) comes after the DECLARE CURSOR statement.

for grins:
simply populate :ARG-F64-A999.MBR-ELIGY-CVRGE-ADD-TS and :ARG-F64-A999. LAST-MNT-TS with WS-TIMESTAMP,
and change the CURSOR DECLARATION to use the ARG-F64-A999 host variables.

and I asked you to cut&paste, you didn't:

HOST VARIABLE "WS-timestamp

and I wanted the WS-TIMESTAMP data division entry defining WS-TIMESTAMP cut&pasted from the precompiler output.
Back to top
View user's profile Send private message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Thu Jul 09, 2009 12:20 am    Post subject: data division timestamp
Reply with quote

Code:
01  WS-MISC                                             
    05  WS-TIMESTAMP PIC X(26)                         
               VALUE '0000-00-00-00.00.00.000000'.     
    05  FILLER REDEFINES WS-TIMESTAMP.                 
        10  WS-CCYY         PIC X(04).                 
        10  FILLER              PIC X        VALUE '-'.
        10  WS-MONTH        PIC X(02).                 
        10  FILLER              PIC X        VALUE '-'.
        10  WS-DAY          PIC X(02).                 
        10  FILLER              PIC X        VALUE '-'.
        10  WS-HR           PIC X(02).                 
        10  FILLER              PIC X        VALUE '.'.
        10  WS-MIN          PIC X(02).                 
        10  WS-MIN-9        REDEFINES                   
            WS-MIN          PIC 9(02).                 
        10  FILLER              PIC X        VALUE '.'.
        10  WS-SEC          PIC X(02).                 
        10  WS-SEC-9        REDEFINES                   
                   WS-SEC          PIC 9(02).                 
        10  WS-MILLI        PIC X(07) VALUE '.000000'.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 09, 2009 1:00 am    Post subject:
Reply with quote

possibly
dbzTHEdinosauer wrote:
your definition (if it is in the precompiler) comes after the DECLARE CURSOR statement.

for grins:
simply populate :ARG-F64-A999.MBR-ELIGY-CVRGE-ADD-TS and :ARG-F64-A999. LAST-MNT-TS with WS-TIMESTAMP,
and change the CURSOR DECLARATION to use the ARG-F64-A999 host variables.


try populating the other host variables and changing the DECLARE CURSOR statement as I suggested.
Back to top
View user's profile Send private message
Anand Renganath S

New User


Joined: 24 Dec 2007
Posts: 1
Location: chennai

PostPosted: Mon Jun 28, 2010 5:38 pm    Post subject: Reply to: Cobol-Db2 Program
Reply with quote

There is a fix available from IBM for your pre-compiler.. Please check www-01.ibm.com/support/docview.wss?uid=swg1PQ73157 -
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Jun 28, 2010 5:53 pm    Post subject:
Reply with quote

or you could simply populate your timestamp with a valid timestamp.
Code:
VALUE '0000-00-00-00.00.00.000000'.

is invalid.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Performing arithmetic on input field zh_lad DFSORT/ICETOOL 3 Tue Dec 06, 2016 8:04 pm
No new posts High CPU consumption Job using IAM fi... aswinir JCL & VSAM 8 Thu Dec 01, 2016 8:28 pm
No new posts Add PD field from 2nd file to PD in 1st Sushant Garje DFSORT/ICETOOL 6 Thu Dec 01, 2016 4:32 pm
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts How to convert the VBM file to VB or... Sulabh Agrawal JCL & VSAM 4 Fri Nov 18, 2016 1:04 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us