Embedded SQL in RPGIV - IBM AS400

This is a discussion on Embedded SQL in RPGIV - IBM AS400 ; Hi, I'm having a problem using embedded SQL and accessing a S/36 file; SQLSTT is always 24501 I've copied the SQL from the RPG into intereactive SQL and changed the parameter to the value that I want and it works ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Embedded SQL in RPGIV

  1. Embedded SQL in RPGIV

    Hi,

    I'm having a problem using embedded SQL and accessing a S/36 file;
    SQLSTT is always 24501

    I've copied the SQL from the RPG into intereactive SQL and changed the
    parameter to the value that I want and it works ok.

    Can anybody help? I've copied the source below;

    c/exec sql
    c+ declare LinkedCursor Cursor
    c+ for
    c+ select distinct
    c+ concat(substring(b.f00002,2,2) , a.k00001)
    c+ from elicli a, elimis b
    c+ where substring(a.f00001,123,8) = :l#postcode
    c+ and a.k00001 = substring(b.k00001,1,8)
    c/end-exec
    /free
    *in50 = *off;
    *in51 = *off;
    *in53 = *off;
    *in52 = *on;
    #2rrn = *zeros;
    Write #2ctl;
    *in52 = *off;

    #1policy = l#POlicyType + '/' + l#PolicyNo;
    /end-free
    c/exec sql
    c+ fetch next
    c+ from LinkedCursor
    c+ into :PolicyNumber
    c/end-exec
    /free
    dow SQLSTT = '00000';
    #2Policy = PolicyNumber;
    #2rrn +=1;
    Write #2sfl;
    Clear #2sfl;
    /end-free
    c/exec sql
    c+ fetch next
    c+ from LinkedCursor
    c+ into :PolicyNumber
    c/end-exec
    /free

  2. Re: Embedded SQL in RPGIV

    On Jul 11, 9:25*am, Steve wrote:
    > Hi,
    >
    > I'm having a problem using embedded SQL and accessing a S/36 file;
    > SQLSTT is always 24501
    >
    > I've copied the SQL from the RPG into intereactive SQL and changed the
    > parameter to the value that I want and it works ok.
    >
    > Can anybody help? *I've copied the source below;
    >
    > *c/exec sql
    > * * *c+ declare LinkedCursor * Cursor
    > * * *c+ * for
    > * * *c+ select distinct
    > * * *c+ concat(substring(b.f00002,2,2) , a.k00001)
    > * * *c+ from elicli a, elimis b
    > * * *c+ where substring(a.f00001,123,8) = :l#postcode
    > * * *c+ and a.k00001 = substring(b.k00001,1,8)
    > * * *c/end-exec
    > * * * /free
    > * * * * *in50 = *off;
    > * * * * *in51 = *off;
    > * * * * *in53 = *off;
    > * * * * *in52 = *on;
    > * * * * #2rrn = *zeros;
    > * * * * Write #2ctl;
    > * * * * *in52 = *off;
    >
    > * * * * #1policy = l#POlicyType + '/' + l#PolicyNo;
    > * * * /end-free
    > * * *c/exec sql
    > * * *c+ fetch next
    > * * *c+ *from LinkedCursor
    > * * *c+ *into :PolicyNumber
    > * * *c/end-exec
    > * * * /free
    > * * * * dow *SQLSTT = '00000';
    > * * * * * *#2Policy * = PolicyNumber;
    > * * * * * *#2rrn +=1;
    > * * * * * *Write #2sfl;
    > * * * * * *Clear #2sfl;
    > * * * /end-free
    > * * *c/exec sql
    > * * *c+ fetch next
    > * * *c+ *from LinkedCursor
    > * * *c+ *into :PolicyNumber
    > * * *c/end-exec
    > * * * /free


    Did you forget to include the open cusor statement above or is it
    really not part of your code? Other than that I might suggest your
    field names are a bit weird but cant see it causing a codepage issue,
    who knows?

    Jonathan

+ Reply to Thread