Re: COBOL/DB2 Date edit question
- From: "Pete Dashwood" <dashwood@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sun, 12 Aug 2007 13:37:06 +1200
"Graham Hobbs" <ghobbs@xxxxxxxxxxx> wrote in message
news:pltrb3hf2o0ujn52tqnd8tk5nsn5ars8uj@xxxxxxxxxx
Help please.
The following code fails - think I've missed something simple.
Table and column exist, database is connected.
I thought I could get a field off screen and edit it via the
SQL below but I get a compile error. I get the same error for
Time and Timestamp fields.
Might there be an 'industry standard' for dealing with these
types of fields?
My docs give little guidance on this and since I work in
isolation there's no-one to ask.
Environment is Visualage Cobol 2.2, DB2 V7.2
02 MP1ZADATEI PIC X(00010).
*------------------------------
E1-ADATE.
*------------------------------
IF MP1ZADATEL NOT = ZERO
EXEC SQL DATE(MP1ZADATEI) END-EXEC
IF SQLCODE = -180
..ETC
--------------------------------------------------------------------
SQL0060W The "COBOL" precompiler is in progress.
83 SQL0062W Starting INCLUDE of file
"E:\conrad\edi1\THEBOOK.cbl".
83 SQL0063W Completed INCLUDE of file "THEBOOK.cbl".
1057 SQL0104N An unexpected token "DATE" was found following
"BEGIN-OF-STATEMENT". Expected tokens may include:
"SELECT". SQLSTATE=42601
Any help or code examples appreciated. please, thanks.
Your problem here is that you are not referencing a host variable to the SQL
DATE function.
As long as your RDBMS supports the function, it is OK to use it in COBOL,
but you need to be clear about what is a field on your database and what is
a field in your program.(Michael was not quite right about that.)
This is addressed by using Host Variables. Host variables must be declared
with an SQL DECLARE statement, and prefixed with a symbol whenever they are
referenced in EXEC SQL statements. (Often the symbol is a colon, but it
varies on different systems.)
It would also be very helpful if, when posting here, you told us what COBOL
and what RDBMS you are using. Believe it or not, but despite
standardization of both COBOL and SQL, there are actually differences
between different systems! (Shock! Horror!)
Consult your documentation regarding the use of Host Variables and all will
be revealed.
Robert Jones has posted a code example.
HTH,
Pete.
--
"I used to write COBOL...now I can do anything."
.
- Follow-Ups:
- Re: COBOL/DB2 Date edit question
- From: Graham Hobbs
- Re: COBOL/DB2 Date edit question
- References:
- COBOL/DB2 Date edit question
- From: Graham Hobbs
- COBOL/DB2 Date edit question
- Prev by Date: Re: COBOL subscript range checking
- Next by Date: Re: Baby Update
- Previous by thread: Re: COBOL/DB2 Date edit question
- Next by thread: Re: COBOL/DB2 Date edit question
- Index(es):
Relevant Pages
|