Results 1 to 1 of 1

Thread: field name as variable

  1. #1
    SuperMan as400Pro's Avatar
    Join Date
    Mar 2006
    Dobrovelychkivka, Kirovohrads'ka, Ukraine
    Rep Power

    Exclamation field name as variable

    Here's a sample of using embedded SQL to retrieve the value of a database field when the field name comes from another variable:
    PHP Code:
         D FieldName       s             10A
         D Stmt            s            500A
         D Result          s             50A

    *ENTRY        PLIST
         C                   PARM                    Field            10

    EVAL      Stmt 'SELECT ' + %trimr(Field)
    C                                  ' from CUSTMAS'
    c                                  ' where CUSTNO=1316'

    C/exec sql          set option naming=*sys
    /exec sql          prepare sqlstmt from :stmt
    /exec sql          declare C1 cursor for sqlstmt
    /exec sql          open C1
    /exec sql          fetch from C1 into :Result
    /exec sql          close C1

         C                   dsply                   Result
    eval      *inlr = *ON 

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Yakutsk, Russia

Facebook Comments

Similar Threads

  1. Regarding Journaling
    By Sandeep D in forum RPG/RPGLE
    Replies: 3
    Last Post: November 16th, 2009, 07:37 AM
  2. VARLEN in DDS defined file
    By itp in forum RPG/RPGLE
    Replies: 2
    Last Post: October 22nd, 2007, 03:02 PM
  3. how to use/implement variable length field
    By ruma in forum RPG/RPGLE
    Replies: 6
    Last Post: September 21st, 2005, 09:22 AM
  4. rpgle
    By mohans in forum RPG/RPGLE
    Replies: 4
    Last Post: May 21st, 2005, 11:50 PM
  5. Null Values and SQL Fetch
    By pjk in forum SQL
    Replies: 1
    Last Post: February 22nd, 2005, 11:31 AM


Posting Permissions

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