1. Club Seiden uses Gitter chat for day to day discussion. If you are a member of Github you just need to ask to join our Github organization: https://github.com/club-seiden and join us on the Gitter.IM chat page!
    Dismiss Notice

Using ILE SQL RPG with SYSTOOLS.GROUP_PTF_CURRENCY

Discussion in 'RPG' started by Tom R, Dec 18, 2016.

  1. Tom R

    Tom R New Member

    I'm try to write a small ile sql rpg program that queries against SYSTOOLS.GROUP_PTF_CURRENCY.
    //***********************************************************
    //*
    //* Name: MK_CHKPTF -- Check for PTF updates
    //* Type: Embedded SQL RPG program
    //* Desc: Check SYSTOOLS.GROUP_PTF_CURRENCY
    //* Auth: Thomas Reynolds
    //*
    //***********************************************************
    //*

    Ctl-Opt DFTACTGRP(*NO)
    ACTGRP(*NEW);

    Dcl-PR Cmd int(10) extproc('system');
    cmdstring pointer value options(*string);
    END-PR;

    Dcl-s errmsgid char(7) import('_EXCP_MSGID');

    Dcl-Pr printf Int(10) ExtProc('printf');
    format Pointer Value Options(*String);
    END-PR;

    Dcl-DS PTFCHK_temp;
    KCRNCY VARCHAR(46);
    KID CHAR(7);
    KTITLE VARCHAR(1000);
    KLVL INT(10);
    KIBMLVL INT(10);
    KLSTUPD CHAR(10);
    KRLS VARCHAR(6);
    KSYSSTS VARCHAR(20);
    END-DS;

    Dcl-DS PTFCHK LikeDS(PTFCHK_temp);

    EXEC SQL Declare PTF_Cur Cursor FOR
    SELECT *
    FROM SYSTOOLS.GROUP_PTF_CURRENCY
    WHERE GRP_CRNCY = 'UPDATE AVAILABLE';

    EXEC SQL Open PTF_Cur;

    IF (SQLSTATE = '00000');
    EXEC SQL Fetch PTF_cur INTO `:pTFCHK;
    DOW (SQLSTATE = '00000');
    printf(%TRIM(PTFCHK.KTITLE) + x'25');
    EXEC SQL Fetch PTF_cur INTO `:pTFCHK;
    ENDDO;

    ENDIF;

    EXEC SQL Close PTF_Cur;

    *InLr = *On;
     
    Last edited: Dec 19, 2016
  2. Tom R

    Tom R New Member

    The joys of looking dumb on a forum... the pink face is PT
     
  3. Tom R

    Tom R New Member

    The solution to my problem is something obvious. I used the wrong column names when referencing the SQL cols. I used the system names accidentally.
     

Share This Page