Results 1 to 1 of 1

Thread: field name as variable

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

    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

         C     
    *ENTRY        PLIST
         C                   PARM                    Field            10

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

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

         C                   dsply                   Result
         C                   
    eval      *inlr = *ON 

  2. # 666
    Circuit advertisement
    Join Date
    Aug 1965
    Location
    Yakutsk, Russia
    Posts
    1,000,000
     

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

Bookmarks

Posting Permissions

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