cancel
Showing results for 
Search instead for 
Did you mean: 

Order by in a select Statement ?

Former Member
0 Kudos

Hi all,

In PI, I would like to translate this SQL Query in a select statement :

SELECT * FROM Table1

WHERE FIELD1 = val1 AND FIELD2 = val2

ORDER BY FIELD3 DESC

No problem for the beginning of the select statement with help of the following blogs :

/people/bhavesh.kantilal/blog/2006/07/03/jdbc-receiver-adapter--synchronous-select-150-step-by-step

/people/sap.user72/blog/2005/06/01/file-to-jdbc-adapter-using-sap-xi-30

it gives :

<StatementSelect>

<table name>

<access>

<col1>

<col2>

</access>

<Key>

</key>

</tablename>

My question is : How to implement the function ORDER BY in the key element ?

I was thinking about something like this :

<Key>

<Order_by>

<column_name>

</order_by>

<order_clause>DESC</order_clause>

</key>

or

<Key>

<order_clause>FIELD3</order_close>

</key>

But it seems that FIELD3 must be in the select condition...

Can someone help me plz ?

Thank you.

Edited by: Jean-Philippe PAIN on Jan 10, 2008 5:29 PM

Edited by: Jean-Philippe PAIN on Jan 10, 2008 5:30 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi !

Check the "SQL_Query" action type in this document

http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm

I think you will need to type the query in "raw" mode with placeholders.

Example:

<root>

<stmt>

<myTable action="SQL_QUERY">

<access> SELECT * FROM Table1

WHERE FIELD1 = $val1$ AND FIELD2 = $val2$

ORDER BY FIELD3 DESC

</access>

<key>

<val1>value 1</val1>

<val2>value 2 </val2>

</key>

</myTable>

</stmt>

</root>

Regards,

Matias.

Former Member
0 Kudos

Hi all,

i would have liked to continue without passing directly the SQL QUERY but i think, it's the only solution and it works.

Thanks for Help

JP

Answers (1)

Answers (1)

justin_santhanam
Active Contributor
0 Kudos

Jean,

You can try by directly passing the SQL-Query isn't it?

raj.