What is the line-continuation character for HANA SQL? Considering I have a super long statement and want it to span across multiple lines instead of it being a super long one in a line.
Thanks.
What is the line-continuation character for HANA SQL? Considering I have a super long statement and want it to span across multiple lines instead of it being a super long one in a line.
Thanks.
For most SQL statements, you can implicitly continue on the next line. There is no "line-continuation character". Long strings can be continued on the next line by separating them in multiple strings concatenated with ||
.
For example, this is perfectly valid HANA SQL:
SELECT
"RefID",
"FirstName",
"LastName"
FROM
"People"
WHERE
"FirstName" = 'Hubert Blaine'
AND
"LastName" = 'Wolfeschlegelsteinhausenbergerdorffvoralternwaren' ||
'gewissenhaftschaferswesenchafewarenwholgepflegeun' ||
'dsorgfaltigkeitbeschutzenvonangereifenduchihrraub' ||
'giriigfeindewelchevorralternzwolftausendjahresvor' ||
'andieerscheinenbanderersteerdeemmeshedrraumschiff' ||
'gebrauchlichtalsseinursprungvonkraftgestartseinla' ||
'ngefahrthinzwischensternartigraumaufdersuchenachd' ||
'iesternwelshegehabtbewohnbarplanetenkreisedrehens' ||
'ichundwohinderneurassevanverstandigmenshlichkeitt' ||
'konntevortpflanzenundsicherfreunanlebenslamdlichf' ||
'reudeundruhemitnichteinfurchtvorangreifenvonander' ||
'erintlligentgeschopfsvonhinzwischensternartigraum';
PS: That person actually exists. :)
You can hit the return key and have a statement split in multiple line for your convenience.
Like in the image below:
Even in dynamic SQL you can split the string (with the || operator) you're going to feed in the EXEC() command.