Discussion:
Accessing MS-SQL Server from within ACU-Cobol
(too old to reply)
Daniel Klopfer
21 years ago
Permalink
Hi all,

I am trying to access a SQL-Server database from within an Cobol
program.
The first attempts were succesful, but now I've got a problem with
some record-dscriptions: The variable-types "INT" , "INT NOT NULL"
and "VARCHAR(nn)" can be represented by PIC 9(9), PIC S9(9) and PIC X
clauses.

What PIC must I use for variable-type "DATETIME" and "DECIMAL(X,Y)???

Any hint is welcome.......

Thanks
Daniel
Peter E.C. Dashwood
21 years ago
Permalink
Post by Daniel Klopfer
Hi all,
I am trying to access a SQL-Server database from within an Cobol
program.
The first attempts were succesful, but now I've got a problem with
some record-dscriptions: The variable-types "INT" , "INT NOT NULL"
and "VARCHAR(nn)" can be represented by PIC 9(9), PIC S9(9) and PIC X
clauses.
What PIC must I use for variable-type "DATETIME" and "DECIMAL(X,Y)???
Dates are problematic. If you really must store them as DATETIME (I store
them as CHAR (YYYYMMDD) and do all the arithmetic and conversion in my
Programs, using a standard component I wrote) then try "USAGE COMP-2" (NO
Picture clause). Dates are actually stored on the database as 64 bit
floating point numbers. You can also get away with PIC 9(18) the maximum
numeric size in COBOL that hasn't implemented the new standard. Use your
debugger to see what is actually returned in these fields.

DECIMAL (X,Y) is PIC 9(X)v(Y). so, 123.45678 is PIC 9(3)v9(5).

HTH,

Pete.
Richard
21 years ago
Permalink
Post by Peter E.C. Dashwood
DECIMAL (X,Y) is PIC 9(X)v(Y). so, 123.45678 is PIC 9(3)v9(5).
DECIMAL (X,Y) is PIC S9(Z)v9(Y) where Z is X - Y. The X is the total
number of digits, Y of which are the decimal part.

DECIMAL (10,2) is PIC S9(8)V99.
Peter E.C. Dashwood
21 years ago
Permalink
Oops!

Thanks for that. Haven't CREATEd any DBs for a while <G>.

Pete.
Post by Richard
Post by Peter E.C. Dashwood
DECIMAL (X,Y) is PIC 9(X)v(Y). so, 123.45678 is PIC 9(3)v9(5).
DECIMAL (X,Y) is PIC S9(Z)v9(Y) where Z is X - Y. The X is the total
number of digits, Y of which are the decimal part.
DECIMAL (10,2) is PIC S9(8)V99.
Daniel Klopfer
21 years ago
Permalink
Post by Richard
DECIMAL (X,Y) is PIC S9(Z)v9(Y) where Z is X - Y. The X is the total
number of digits, Y of which are the decimal part.
DECIMAL (10,2) is PIC S9(8)V99.
Thanks for the information. For myself I wouldnt use DATETIME, but I
have to access an existing database in which the dates are defined in
this way.

So thank you again and greetings from Germany
Daniel
Thane Hubbell
21 years ago
Permalink
Post by Daniel Klopfer
Post by Richard
DECIMAL (X,Y) is PIC S9(Z)v9(Y) where Z is X - Y. The X is the total
number of digits, Y of which are the decimal part.
DECIMAL (10,2) is PIC S9(8)V99.
Thanks for the information. For myself I wouldnt use DATETIME, but I
have to access an existing database in which the dates are defined in
this way.
So thank you again and greetings from Germany
Daniel
For Oracle I formated them using SQL (date/Time fields) so they are
passed and updated in a more "traditional" and not "native" format. I
don't have an example handy but someone here will.
Peter E.C. Dashwood
21 years ago
Permalink
Post by Daniel Klopfer
So thank you again and greetings from Germany
Das war fuer mich ein vergnugung, und gleichfalls mit der Grussen, von Neu
Seeland <G>

Pete.
Grinder
21 years ago
Permalink
Post by Daniel Klopfer
Thanks for the information. For myself I wouldnt use DATETIME, but I
have to access an existing database in which the dates are defined in
this way.
Just a bit of info about DATETIME in MS parlance -- that's an 8-byte IEEE
floating point. It is a simple offset from a fixed zero date (December 30,
1899 if I remember correctly.)

Jon Scally
21 years ago
Permalink
Post by Daniel Klopfer
Hi all,
I am trying to access a SQL-Server database from within an Cobol
program.
The first attempts were succesful, but now I've got a problem with
some record-dscriptions: The variable-types "INT" , "INT NOT NULL"
and "VARCHAR(nn)" can be represented by PIC 9(9), PIC S9(9) and PIC X
clauses.
What PIC must I use for variable-type "DATETIME" and "DECIMAL(X,Y)???
Any hint is welcome.......
Thanks
Daniel
For a DATE field you would want to use a PIC 9(8), but you will also need
to use the DATE directive for Acu4GL for MS SQL to identify to the
database that it knows the field is a DATE field:

01 MY-REC.
$XFD DATE=YYYYMMDD
05 DATE-FLD PIC 9(8).

Hope that helps.
Loading...