Host variables in embedded SQL - IBM AS400

This is a discussion on Host variables in embedded SQL - IBM AS400 ; I have created an RPG program on a V5R4 system that includes some embedded SQL. I am sending out put to an externally described print file. I would like to use the fields defined in the print file as host ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Host variables in embedded SQL

  1. Host variables in embedded SQL

    I have created an RPG program on a V5R4 system that includes some
    embedded SQL. I am sending out put to an externally described print
    file. I would like to use the fields defined in the print file as host
    variables in my embedded SQL. When I try this, the program will not
    compile. The compiler listing says the variables are undefined or used
    incorrectly. The documentation I found online says an externally
    described file's fields can be used as host variables. I wondering if
    this only applies to database files and not to printer files.

  2. Re: Host variables in embedded SQL

    Thomas Laza wrote:
    > I have created an RPG program on a V5R4 system that includes some
    > embedded SQL. I am sending out put to an externally described print
    > file. I would like to use the fields defined in the print file as host
    > variables in my embedded SQL. When I try this, the program will not
    > compile. The compiler listing says the variables are undefined or used
    > incorrectly. The documentation I found online says an externally
    > described file's fields can be used as host variables. I wondering if
    > this only applies to database files and not to printer files.


    Just hazarding a guess, I think it might be because the printer file is
    opened for output only.

  3. Re: Host variables in embedded SQL

    Jonathan Ball wrote:
    > Thomas Laza wrote:
    >> I have created an RPG program on a V5R4 system that includes some
    >> embedded SQL. I am sending out put to an externally described print
    >> file. I would like to use the fields defined in the print file as
    >> host variables in my embedded SQL. When I try this, the program will
    >> not compile. The compiler listing says the variables are undefined or
    >> used incorrectly. The documentation I found online says an externally
    >> described file's fields can be used as host variables. I wondering if
    >> this only applies to database files and not to printer files.

    >
    > Just hazarding a guess, I think it might be because the printer file is
    > opened for output only.


    That seems to be it.

    I think I found a way around it. Declare external data structures for
    each of your printer file formats that contains one or more of the
    fields you want to use as host variables:

    d somedsname e ds extname(prtfname:format)


    Now the SQL precompiler will "see" the printer file field names and be
    able to use them as host variables.

  4. Re: Host variables in embedded SQL

    Jonathan Ball wrote:
    > Jonathan Ball wrote:
    >> Thomas Laza wrote:
    >>> I have created an RPG program on a V5R4 system that includes some
    >>> embedded SQL. I am sending out put to an externally described print
    >>> file. I would like to use the fields defined in the print file as
    >>> host variables in my embedded SQL. When I try this, the program will
    >>> not compile. The compiler listing says the variables are undefined or
    >>> used incorrectly. The documentation I found online says an
    >>> externally described file's fields can be used as host variables. I
    >>> wondering if this only applies to database files and not to printer
    >>> files.

    >>
    >> Just hazarding a guess, I think it might be because the printer file
    >> is opened for output only.

    >
    > That seems to be it.
    >
    > I think I found a way around it. Declare external data structures for
    > each of your printer file formats that contains one or more of the
    > fields you want to use as host variables:
    >
    > d somedsname e ds extname(prtfname:format)
    >
    >
    > Now the SQL precompiler will "see" the printer file field names and be
    > able to use them as host variables.

    I'll give it a try. Thanks.

+ Reply to Thread