Reading multiple columns in one request

Hi All

 

Whats the best way to read multiple columns in one SelectSQL call and assign them to different variables?

 

Say i have variables v1, v2, v3 - that correspond to columns col1, col2, col3

 

Instead of writing

 

v1 = %selectSQL("select col1 from table")

v2 = %selectSQL("select col2 from table")

v3 = %selectSQL("select col3 from table")

 

I want to get all 3 values in one database hit, something like

 

tempVar = %selectSQL("select col1, col2, col3 from table") 

v1 = tempVar[0]

v2=tempVar[1] etc.

 

I can think of one way to do this using a delimited select statement and then substring operations to get the values out. This sounds really weird. Another way is possibly through grids, but I don't want to create a dummy grid to just get these values out.

 

I'm sure this is a common pattern for which there is hopefully a straightforward solution !

 

HELP

 

Thanks

Have a nice day

 

 

Tagged:

Comments

  • You could try something like this...

     

    %myMemo := %SelectSQL("SELECT column1, column2, column3 FROM myTable WHERE something = somethingelse)

    %myColumnData1 := %myMemo[0]

    %myColumnData2 := %myMemo[1]

    %myColumnData3 := %myMemo[2]

     

    Hope this helps,

     

    Regards,

     

    Paul

     

    [this probably adddresses your earlier thread as well]

  • Thanks Paul ! I'll try this out.

  • Works perfect. Thanks!