cancel
Showing results for 
Search instead for 
Did you mean: 

Question about creating a specific SELECT Statement

Former Member
0 Kudos

I am trying to create a SELECT statement where I use a date range for the same date column, I am having a difficult time creating an AND for the same column I thought maybe you guys could help, here is the XML I have so far.

<?xml version="1.0" encoding="UTF-8"?>

<ns0:MT_JDBC_TRDHEADER_REQ xmlns:ns0="http://citgo.com/JDBC_to_CSL">

<STATEMENT>

<TABLENAME ACTION="SELECT">

<TABLE>qa_citgo_baseline.trd_header</TABLE>

<ACCESS>

<TRADE_NUM/>

<DEAL_NAME_STR/>

<COUNTERPART_COMPANY_NUM/>

<TRADE_TYPE_CD/>

<STRATEGY_NUM/>

<TRADE_INPUT_DT/>

<TRADE_DT/>

<ACCOUNTING_CLASS_CD/>

</ACCESS>

<KEY>

<TRADE_DT compareOperation="GTEQ">01-Jan-2008</TRADE_DT>

</KEY>

<KEY1>

<TRADE_DT compareOperation="LTEQ">08-Jan-2008</TRADE_DT>

</KEY1>

</TABLENAME>

</STATEMENT>

</ns0:MT_JDBC_TRDHEADER_REQ>

Is there anyway to do an AND instead of an OR.

Thanks

Accepted Solutions (0)

Answers (2)

Answers (2)

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi,

yes its posible:

see this

<StatementName1>

<dbTableName action=u201DUPDATEu201D | u201CUPDATE_INSERTu201D>

<table>realDbTableName</table>

............<access>

..................<col1>val1</col1>

..................<col2>val2new</col2>

............</access>

............<key1>

..................<col2>val2old</col2>

..................<col4>val4</col4>

............</key1>

............<key2>

..................<col2>val2old2</col2>

............</key2>

......</dbTableName>

</StatementName1>

UPDATE dbTableName SET col1=u2019val1u2019, col2=u2019val2newu2019 WHERE ((col2=u2019val2oldu2019 AND col4=u2019val4u2019) OR (col2=u2019val2old2u2019))

the key1 represent "AND" and the key2 represent OR in the SQL query before. see this link please to undestand ir more clear

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

in your case your query means

<KEY>

<TRADE_DT compareOperation="GTEQ">01-Jan-2008</TRADE_DT>

</KEY>

<KEY1>

<TRADE_DT compareOperation="LTEQ">08-Jan-2008</TRADE_DT>

</KEY1>

<TRADE_DT compareOperation="GTEQ"> OR <TRADE_DT compareOperation="LTEQ">

in your case, you cannot use AND and OR in same query because your field is the same, just the value change. you only can use OR.

thats your doubt??

Thanks

Rodrigo

Edited by: Rodrigo Alejandro Pertierra on Aug 12, 2008 11:57 AM

Former Member
0 Kudos

I want to use an AND on the same column, from what you've just said it seems that it is not possible on the same column

rodrigoalejandro_pertierr
Active Contributor
0 Kudos

hi,

if you want to use AND you have to add a new field inside the segment <KEY1>.

Former Member
0 Kudos

Rodrigo,

I am trying to do the AND for the same column(Field) "TRADE_DT"

Former Member
0 Kudos

Hi,

I dont know how its possible........... bcoz its internally it use OR between two Key nodes.

Check this:

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

Thanks,

Mahi

Former Member
0 Kudos

I already read that document, I thought maybe somebody would have come up with solution to this issue