ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Field name as passed parm

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Field name as passed parm

    Hi,
    It there a way to pass a field name as a parameter to an RPGLE program (not FREE) so that field name can be read from an overridden file?

    I need to run a program over several files, specifically several fields of different names within each file, and I'm looking for a way to do this dynamically, like from a command where I can allow a file name and library to be supplied via the command along with a list of field names. Then in a CL, override to the lib/file and pass the fields as a single parameter from a loop in the CL. Let the RPGLE program do it's thing, return to the CL, pass the next field, etc.

    Is this possible?
    Mike
    Everyday's a school day, what grade are you in?

  • #2
    Can't imagine why free is not an option - V5 happened a long, long time ago ... daft to limit yourself to fixed.

    There are various ways of doing it, most would require the use of pointer, or heavy substringing. But probably the best and most versatile way to do it would be by using dynamic SQL. Build the statement, prepare it and execute it.

    Doing it without SQL is much harder work. The amount of work would depends on whether the files have the same layouts, field names, etc.

    Comment


    • #3
      There are lots of ways to do this. Dynamic SQL, API/Pointer logic, call an existing utility, etc.

      IMHO, you should avoid the use of overrides. Just as the field/col names can be dynamic, so too the file/table names can be dynamic.

      Comment

      Working...
      X