If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL4002N - Precompiler strange error

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-25-09, 08:29
Yan302 Yan302 is offline
Registered User
 
Join Date: Feb 2009
Posts: 12
SQL4002N - Precompiler strange error

Hi everyone,

I've got a strange precomplier error ; hope someone will have any idea how to resolve this because I'm completely disappointed about that problem

I'll try to explain my problem clearer as possible but it's not trivial.

First of all, I’ve got two similar functions declared like this:

Code:
CREATE FUNCTION "DB2ADMIN"."FUNC_BK_BIG_2_624001995" (
    "COMPOUND_2_1"	CHARACTER(8),
    "COMPOUND_2_2"	CHARACTER(8) )
  RETURNS VARCHAR(16)
  SPECIFIC "SQL090520165705700"
  LANGUAGE SQL
  DETERMINISTIC
  NO EXTERNAL ACTION
  CONTAINS SQL
  CALLED ON NULL INPUT
  INHERIT SPECIAL REGISTERS
RETURN VARCHAR(COMPOUND_2_1, 8) || VARCHAR(COMPOUND_2_2, 8);

CREATE FUNCTION "DB2ADMIN"."FUNC_BK_BIG_3_79140483" (
    "COMPOUND_4_1"	CHARACTER(4),
    "COMPOUND_4_2"	CHARACTER(4),
    "COMPOUND_4_3"	CHARACTER(4),
    "COMPOUND_4_4"	CHARACTER(4) )
  RETURNS VARCHAR(16)
  SPECIFIC "SQL090520165706200"
  LANGUAGE SQL
  DETERMINISTIC
  NO EXTERNAL ACTION
  CONTAINS SQL
  CALLED ON NULL INPUT
  INHERIT SPECIAL REGISTERS
RETURN VARCHAR(COMPOUND_4_1, 4) || VARCHAR(COMPOUND_4_2, 4) || VARCHAR(COMPOUND_4_3, 4) || VARCHAR(COMPOUND_4_4, 4);
When I try to precompile this C code:
Code:
EXEC SQL BEGIN DECLARE SECTION;

static struct _index_buff_102_OT {
    struct {short len; char buff[8];} COMPOUND_2_1;
    struct {short len; char buff[8];} COMPOUND_2_2;
} index_buff_A_102;

  EXEC SQL DECLARE SEQ_ON_INDEX_102 CURSOR FOR
    SELECT 
        RID,
        VERSION,
        "COL1",
        "COL2",
        "COL3",
        "COL4",
        "COL5",
        "COL6",
        "COL7",
        "COL8",
        "COMPOUND",
        "COMPOUND_2_1",
        "COMPOUND_2_2",
        "COMPOUND_4_1",
        "COMPOUND_4_2",
        "COMPOUND_4_3",
        "COMPOUND_4_4",
        ("AMOUNT" * 100)
      FROM
        BIG
      WHERE
        BK_BIG_2_624001995 >= func_BK_BIG_2_624001995(:index_buff_A_102.COMPOUND_2_1.buff, :index_buff_A_102.COMPOUND_2_2.buff)
      ORDER BY
        "BK_BIG_2_624001995";

EXEC SQL END DECLARE SECTION;
everything goes well:
Code:
        SQL0060W  The "C" precompiler is in progress.
        SQL0091W  Precompilation or binding was ended with "0"
                  errors and "0" warnings.
but if I try to precompile :
Code:
EXEC SQL BEGIN DECLARE SECTION;

static struct _index_buff_103_OT {
    struct {short len; char buff[4];} COMPOUND_4_1;
    struct {short len; char buff[4];} COMPOUND_4_2;
    struct {short len; char buff[4];} COMPOUND_4_3;
    struct {short len; char buff[4];} COMPOUND_4_4;
} index_buff_A_103;

  EXEC SQL DECLARE SEQ_ON_INDEX_103 CURSOR FOR
    SELECT 
        RID,
        VERSION,
        "COL1",
        "COL2",
        "COL3",
        "COL4",
        "COL5",
        "COL6",
        "COL7",
        "COL8",
        "COMPOUND",
        "COMPOUND_2_1",
        "COMPOUND_2_2",
        "COMPOUND_4_1",
        "COMPOUND_4_2",
        "COMPOUND_4_3",
        "COMPOUND_4_4",
        ("AMOUNT" * 100)
      FROM
        BIG
      WHERE
        BK_BIG_3_79140483 >= func_BK_BIG_3_79140483(:index_buff_A_103.COMPOUND_4_1.buff, :index_buff_A_103.COMPOUND_4_2.buff, :index_buff_A_103.COMPOUND_4_3.buff, :index_buff_A_103.COMPOUND_4_4.buff)
      ORDER BY
        "BK_BIG_3_79140483";

EXEC SQL END DECLARE SECTION;
I got this error :
Code:
        SQL0060W  The "C" precompiler is in progress.
   10   SQL4002N  "index_buff_A_103.COMPOUND_4_3.buff" and
                  "index_buff_A_103.COMPOUND_4_2.buff" are undeclared host
                  variables that cannot both be used as descriptor names in a
                  single SQL statement.
   10   SQL4002N  "EXEC" and "" are undeclared host variables that
                  cannot both be used as descriptor names in a single SQL
                  statement.
        SQL0095N  No bind file was created because of previous
                  errors.
        SQL0091W  Precompilation or binding was ended with "3"
                  errors and "0" warnings.
Someone got any ideas what the problem is and how to resolved it ?

Any help would really be appreciated.

Thanks in advance,

Yan302
Reply With Quote
  #2 (permalink)  
Old 05-25-09, 10:21
Yan302 Yan302 is offline
Registered User
 
Join Date: Feb 2009
Posts: 12
Hi all,

I've found a workaround. I use VARCHAR instead of CHAR.
No more problem.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On