Problem with exec sql include

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carmen Gloria Sepulveda Dedes

    Problem with exec sql include

    Hello.

    I have a 2 files: test.h and test.pgc.

    In test.h, I defined:

    typedef struct {
    long curid;
    char curnombre[20];
    char curfecha[10];
    } struct_cursor;

    And, in test.pgc, I want to declare:

    EXEC SQL BEGIN DECLARE SECTION;
    struct_cursor t_cursor;
    EXEC SQL END DECLARE SECTION;

    But, when I do: ecpg -I/<include_file_p ath> test.pgc,
    I get: test.pgc:7: ERROR: invalid datatype 'struct_cursor'

    I know that I can include the typedef at DECLARE SECTION, but I don't
    want to use that (test.h and test.pgc are only examples of the problem
    bigest).

    How can I resolve this?

    Thanks.

    CG


    ---------------------------(end of broadcast)---------------------------
    TIP 7: don't forget to increase your free space map settings

  • Michael Meskes

    #2
    Re: Problem with exec sql include

    On Wed, Nov 19, 2003 at 11:09:58AM -0300, Carmen Gloria Sepulveda Dedes wrote:[color=blue]
    > I know that I can include the typedef at DECLARE SECTION, but I don't
    > want to use that (test.h and test.pgc are only examples of the problem[/color]

    ECPG does not parse anything outside EXEC SQL blocks, so how else should
    it lear about your struct definition? You can of course use a EXEC SQL
    TYPE command to define it for ECPG as well.

    Michael
    --
    Michael Meskes
    Email: Michael at Fam-Meskes dot De
    ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.o rg
    Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

    ---------------------------(end of broadcast)---------------------------
    TIP 5: Have you checked our extensive FAQ?



    Comment

    • Carmen Gloria Sepulveda Dedes

      #3
      Re: Problem with exec sql include

      Thanks for you suggestion.

      In the test.pgc file, I do:

      EXEC SQL BEGIN DECLARE SECTION;
      exec sql include test;
      struct_cursor t_cursor;
      EXEC SQL END DECLARE SECTION;

      .... and it works fine. It is correct????

      Thank you again.

      CG

      [color=blue]
      > ECPG does not parse anything outside EXEC SQL blocks, so how else should
      > it lear about your struct definition? You can of course use a EXEC SQL
      > TYPE command to define it for ECPG as well.[/color]


      ---------------------------(end of broadcast)---------------------------
      TIP 5: Have you checked our extensive FAQ?



      Comment

      • Michael Meskes

        #4
        Re: Problem with exec sql include

        On Wed, Nov 19, 2003 at 12:26:07PM -0300, Carmen Gloria Sepulveda Dedes wrote:[color=blue]
        > In the test.pgc file, I do:
        >
        > EXEC SQL BEGIN DECLARE SECTION;
        > exec sql include test;
        > struct_cursor t_cursor;
        > EXEC SQL END DECLARE SECTION;
        >
        > ... and it works fine. It is correct????[/color]

        Depends on what test.h contains. ecpg has to learn the definition of
        your struct somewhere.

        Michael

        --
        Michael Meskes
        Email: Michael at Fam-Meskes dot De
        ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.o rg
        Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

        ---------------------------(end of broadcast)---------------------------
        TIP 5: Have you checked our extensive FAQ?



        Comment

        • Michael Meskes

          #5
          Re: Problem with exec sql include

          On Wed, Nov 19, 2003 at 12:26:07PM -0300, Carmen Gloria Sepulveda Dedes wrote:[color=blue]
          > In the test.pgc file, I do:
          >
          > EXEC SQL BEGIN DECLARE SECTION;
          > exec sql include test;
          > struct_cursor t_cursor;
          > EXEC SQL END DECLARE SECTION;
          >
          > ... and it works fine. It is correct????[/color]

          Depends on what test.h contains. ecpg has to learn the definition of
          your struct somewhere.

          Michael

          --
          Michael Meskes
          Email: Michael at Fam-Meskes dot De
          ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.o rg
          Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

          ---------------------------(end of broadcast)---------------------------
          TIP 5: Have you checked our extensive FAQ?



          Comment

          Working...