spacer
cornerspacercorner
Reply
Advisor
Prax
Posts: 34
Registered: 07-05-2011
0 Kudos
Accepted Solution

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

 

 

Valued Contributor
Paul
Posts: 146
Registered: 05-19-2010

Re: Reading multiple columns in one request

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]

Advisor
Prax
Posts: 34
Registered: 07-05-2011
0 Kudos

Re: Reading multiple columns in one request

Thanks Paul ! I'll try this out.

Advisor
Prax
Posts: 34
Registered: 07-05-2011
0 Kudos

Re: Reading multiple columns in one request

Works perfect. Thanks!

line spacer line
spacerFollow Metastorm on:
spacer Twitter YouTube Blog iTunes LinkedIn Metastorm Community Central, MC2
spacer Copyright © 2011 OpenText Corporation. All Rights Reserved.spacer About Metastormspacer Privacyspacer Legalspacer Site Mapspacer RSSspacer Contact Us
Microsoft Gold Certified Partner
Powered by Windows Azure
line spacer line