Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2004
    Posts
    2

    Unanswered: Declaring host variables in Pro*C/C++

    Hello!

    if I want to use a host variable in embedded SQL, I have to do it like this:

    example1:

    ...

    EXEC SQL BEGIN DECLARE SECTION

    char * connstr = "login/password";

    EXEC SQL END DECLARE SECTION

    ..

    int main()
    {
    ...

    EXEC SQL CONNECT :connstr;
    }


    .. but it some manuals I saw that, they used host variables that where not declared in EXEC SQL DECLARE SECTION

    example2:

    int main()
    {
    char * connstr = "login/password";
    EXEC SQL CONNECT :connstr;
    }


    QUESTION:

    If I try example2, it ends with an error .. only the example1 works well .. I'm using Microsoft Visual C++ for complilation .. I would like to ask, what I have to do to make the example2 (using host variable even if it wasnt declared in DECLARE SECTION) working well ..

    thanks a lot, Majo

  2. #2
    Join Date
    Jul 2004
    Posts
    4
    You do not require a Declare Section when you use the command line option PARSE=FULL (which is not allowed if you are writing your program in C++) and if MODE is not set to ANSI.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •