Celeron.JB
1st February 2011, 15:37
Hello!

Please, sorry for my English:)

May I use variables inside the SQL query?

I want to change sort order on runtime.

select tisfc001.pdno(1;4):sndr,
tisfc001.pdno,
tisfc001.cwar,
tisfc001.mitm,
tcibd001.dsca

from tisfc001 inner join tcibd001 on tcibd001.item = tisfc001.mitm
order by 1, tisfc001.cwar, 4

Depending on the options on the form I want to change the sort order of the latter, for example at 5 (tcibd001.dsca), may I use a variable there, or is it not possible at all?

Should get something like... order by 1, tisfc001.cwar, var
But this construction is not compile

Thanks

mark_h
1st February 2011, 18:44
I am sure there is something fancy in LN that would solve this, but one thing we have done in the past is use different reports. So if we give the users a couple of different sort options we would put different reports in different report groups. Then based off the sort picked what the report group would be - then the reports would have the different sorts on them. Just one suggestion I thought I would mention. You should probably wait for someone who knows ln.

sameer.don
1st February 2011, 19:24
I have not tried this ever. But can suggest you to use dynamic SQL queries.
You can change the sort order at run time based on user inputs.

Celeron.JB
2nd February 2011, 08:38
Thank you very much for your answers, I do these options considered, but I wanted to know exactly about the use of variables in the body of an SQL query in ORDER BY clause. Agree, it would be convenient