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

Passing timstamp from input file to select statement


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Wed Jul 08, 2009 10:00 pm
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
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
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
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
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

Moderator Emeritus


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

PostPosted: Wed Jul 08, 2009 10:23 pm
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
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
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
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
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
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
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
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
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
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
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
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
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
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
dbzTHEdinosauer

Global Moderator


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

PostPosted: Mon Jun 28, 2010 6:41 pm
Reply with quote

since it took me a while to find it,
I will provide you with a link to valid timestamp ranges
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jun 12, 2012 6:00 pm
Reply with quote

any one has updates to this thread??
Back to top
View user's profile Send private message
Naish

New User


Joined: 07 Dec 2006
Posts: 82
Location: UK

PostPosted: Tue Jun 12, 2012 6:15 pm
Reply with quote

Yearly job triggered. Need to investigate why it didn't run in 2011. (pun intended).

icon_biggrin.gif
Back to top
View user's profile Send private message
Rohit Umarjikar

Global Moderator


Joined: 21 Sep 2010
Posts: 3051
Location: NYC,USA

PostPosted: Tue Jun 12, 2012 6:28 pm
Reply with quote

Really icon_smile.gif
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Tue Jun 12, 2012 6:33 pm
Reply with quote

Hello,

Quote:
any one has updates to this thread??
If you had an actual question, it would have been better to start a new topic for your question rather than post a reply to a 2-year-old topic with nothing to contribute to that topic icon_confused.gif

Is there something you are tyring to learn?

d
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 -> COBOL Programming Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top