View previous topic :: View next topic |
Author |
Message |
naren_ab Beginner
Joined: 07 Jan 2003 Posts: 32 Topics: 10
|
Posted: Fri Aug 29, 2003 12:41 am Post subject: question on C langauge |
|
|
In a C pgm how do i define DB2 host variable say name of length 20.
In Db2 table name is defined as Char of length 20.
SO i tried char name[20] in C but it gives error saying undefined or unusable host varibale.
Let me know if you have answer |
|
Back to top |
|
 |
DaveyC Moderator

Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Fri Aug 29, 2003 2:52 am Post subject: |
|
|
DB2 adds 1 to all C char buffers for the NULL terminator (even if it's not a string). If you use the DCLGEN utility you should have no problems. _________________ Dave Crayford |
|
Back to top |
|
 |
naren_ab Beginner
Joined: 07 Jan 2003 Posts: 32 Topics: 10
|
Posted: Fri Aug 29, 2003 8:30 am Post subject: |
|
|
Thanks you Dave,
But >
declgen created the name field as
char NAME 41Y; and when I compile, I get UNDEFINED OR UNUSABLE HOST VARIABLE "NAME". so I changed it to "char NAME;" it made to work fine. Since char is only 1 byte i am getting onyl the 1st character of name in NAME field.
How do i solve it. I cannot declare NAME as array, as DB2 will not know it. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Fri Aug 29, 2003 12:01 pm Post subject: |
|
|
Naren,
How about defining like this ???
Code: |
struct
{ char NAME??(20??)
|
Hope this helps..
cheers
kolusu |
|
Back to top |
|
 |
naren_ab Beginner
Joined: 07 Jan 2003 Posts: 32 Topics: 10
|
Posted: Fri Aug 29, 2003 12:17 pm Post subject: |
|
|
Hurray! it works. but would request you to explain about it, and where can i find more on the same.
Thanks once again Kolusu  |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
naren_ab Beginner
Joined: 07 Jan 2003 Posts: 32 Topics: 10
|
Posted: Fri Aug 29, 2003 3:00 pm Post subject: |
|
|
I have used spufi to create the DCLGEN. But where did you see this syntax
"char NAME??(20??) " what does "??" mean? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Sat Aug 30, 2003 7:49 am Post subject: |
|
|
Naren,
There is a seperate option for DCLGEN on DB2I panel. option 1 is spufi and option 2 is DCLGEN. once you run the dclgen initially you will see the table declaration and if you scroll down you will find the approriate language declarations below.The links posted above explains clearly the DCLGEN for both batch and interactive
Why dont you run the sample jcl I provided above and check out the include in your pds ??
Kolusu |
|
Back to top |
|
 |
DaveyC Moderator

Joined: 02 Dec 2002 Posts: 151 Topics: 3 Location: Perth, Western Australia
|
Posted: Mon Sep 01, 2003 3:45 am Post subject: |
|
|
??( is called a trigraph. The problem is the DB2 pre-compiler doesn't recognise the locale you are using (I think it uses 1047). I run a translation program before the DB2 precompile
Code: |
//**********************************************************************
//* *
//* Convert locale from 037 to 1047. *
//* *
//* The DB2 preprocessor does not recognize the z/OS C/C++ compiler's *
//* diffent locales. Code must be in codepage 1047... *
//* *
//**********************************************************************
//CONVERT EXEC PGM=EDCICONV,REGION=6M,
// PARM=('FROMCODE(IBM-037),TOCODE(IBM-1047)')
//SYSUT1 DD DISP=SHR,DSN=DOC.USER.C(&MEM)
//SYSUT2 DD DISP=SHR,DSN=DOC.USER.SOURCE(&MEM)
//SYSPRINT DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSIN DD DUMMY
//*
|
_________________ Dave Crayford |
|
Back to top |
|
 |
|
|