In progress 4gl get field names of temp-table
Asked Answered
R

1

7

I have some temp-tables in my script that I will be exporting to a csv file. I need to also export the field names as well as their values. How can I get the field names of temp-tables?

Romulus answered 20/6, 2014 at 21:42 Comment(0)
B
11

Here's a quick and dirty example of what you're asking for:

define temp-table tt1
  field f1 as character
  field f2 as decimal
  .

def var iCnt as integer no-undo.

create tt1.
assign 
   tt1.f1 = "f1"
   tt1.f2 = 123.456
   .

do icnt = 1 to buffer tt1:num-fields:

   display buffer tt1:buffer-field(icnt):name
           buffer tt1:buffer-field(icnt):buffer-value
       with down
       .

   down.

end.
Barram answered 20/6, 2014 at 22:21 Comment(2)
Excellent! Thank you so much. I couldn't find this anywhere.Romulus
They won't let me give any up votes yet. :-/ A reputation score of 15 is required before that is enabled, and mine is 14 at the moment.Romulus

© 2022 - 2024 — McMap. All rights reserved.