Issue Reagrding Structure type array variable in SQC code.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nibakshi
    New Member
    • Feb 2008
    • 2

    Issue Reagrding Structure type array variable in SQC code.

    As i have defined a structure in EXEC SQL BEGIN and END section and i am declaring a structure type array variable after structure definition,but during precompilation it is throwing an error:
    " SQL0008N The token "[" found in a host variable declaration is not valid."

    Code is like this:

    EXEC SQL BEGIN DECLARE SECTION

    struct abc
    {
    int a,
    int b,
    char c[12];
    char d[14];
    .....
    .....
    ....

    } v_abc[20];

    EXEC SQL END DECLARE SECTION

    please suggest a solution asap....
  • sakumar9
    Recognized Expert New Member
    • Jan 2008
    • 127

    #2
    Can you give the exact code text, I mean your BEGIN to END DECLARE SECTION.

    Regards
    - Sanjay

    Comment

    • sakumar9
      Recognized Expert New Member
      • Jan 2008
      • 127

      #3
      You cannot have arrays in DECLARE section.

      Example:
      Code:
      You cannot have this:
           struct {
           short vchar_len;
           char  vchar_value[24];
          } hv_vchar24[B][U][20][/U][/B];
      
      
      You can have this:
      
           struct {
           short vchar_len;
           char  vchar_value[24];
          } hv_vchar24;

      You can have such declarations out of the DECLARE section. I am not sure why do you need such variable because we declare host variables in DECLARE section. These host variables are used to pass values to and from database.

      Let me know if it doesn't suits your requirement.

      Regards
      -- Sanjay

      Comment

      • nibakshi
        New Member
        • Feb 2008
        • 2

        #4
        Originally posted by sakumar9
        You cannot have arrays in DECLARE section.

        Example:
        Code:
        You cannot have this:
             struct {
             short vchar_len;
             char  vchar_value[24];
            } hv_vchar24[B][U][20][/U][/B];
        
        
        You can have this:
        
             struct {
             short vchar_len;
             char  vchar_value[24];
            } hv_vchar24;

        You can have such declarations out of the DECLARE section. I am not sure why do you need such variable because we declare host variables in DECLARE section. These host variables are used to pass values to and from database.

        Let me know if it doesn't suits your requirement.

        Regards
        -- Sanjay
        Hi Sanjay,

        Thanks for reply.....

        I have used array of structures in PRO*C code,but this is not working in SQC.

        I have also implemented this thing using linked list but pointer type varible is not being recognised by DB2 precompiler.


        I need to declare aray of structure in SQL block,if it is declared outside then i cannot use it for DB manipulation.

        Thanks
        Nipun........

        Comment

        • ramesh18589
          New Member
          • Jun 2014
          • 1

          #5
          Hi nibakshi,

          We cannot use 'int' inside the structure.

          Use sqlint32 or sqlint64....

          Comment

          Working...