cancel
Showing results for 
Search instead for 
Did you mean: 

how to write 1=1 in SAP SQL

former_member625844
Participant
0 Kudos

in oracle sql I can use 1=1 if I'm using a optional condition.what's the same syntax in SAP SQL? I tried

 SELECT * FROM spfli where 1 = 1 INTO TABLE  @gt_spfli

and nothing returned. I'm using this SQL in a JCO to query data from SAP.

Vitaliy-R
Developer Advocate
Developer Advocate
0 Kudos

There is no such thing as "SAP SQL". I think you mean "Open SQL" used in SAP ABAP.

I added JCo tag to your question, so that it is visible to others in JCo Q&A.

UweFetzer_se38
Active Contributor
0 Kudos

Hi Witalij,

it's now called ABAP SQL 😉

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member182090
Active Participant
0 Kudos

What makes you think 1=1 would not work in Hana? It does -- in fact, you can just as well use 2=2 or 0=0 (or 2 = 1+1 if you're adventurous). Or, as already noted, avoid the predicate completely.

Since the specific Hana SQL dialect variation was not mentioned, let me just add for completeness two examples:

-- SAP Hana SQLScript:
DO BEGIN
my_tabvar = SELECT * FROM MyTable WHERE 1 = 1;
SELECT * FROM :my_tabvar;
END;

-- SAP Hana SQL:
CREATE TABLE My_New_Table AS (SELECT * FROM MyTable WHERE 2 = 2);
UweFetzer_se38
Active Contributor
0 Kudos

If 1=1 means, that every record should be returned then just don't use any WHERE condition.