Digi
Digi

Reputation: 60

Issue in creating a Function returning a SQL Query

I am currently trying to create a Function in oracle Apex to return SQL Query, and there seems to be some errors in my code. Can someone look over it and see what's wrong.

  RETURN
'SELECT 1, LAN_ID label,'||
'   '#'              target,'||
'    NULL          is_current_list_entry,'||
'   'http://orig03.deviantart.net/efa6/f/2015/200/5/6/anon_icon_thinger_by_arofexdracona-d920vda.png'    image,'|| 
'    NULL             image_attribute,'||
'    NULL             image_alt_attribute,'||
'    'left'           attribute1,'||
'    'fa-clock-o'     attribute2,'||
'    DATE_POSTED      attribute3,'||
'    RESPONSE         attribute4'||
'from CHAT_RESPONSE'||
'where LAN_ID IS NOT NULL'||
'order by DATE_POSTED DESC;'||

Upvotes: 0

Views: 199

Answers (1)

Trinimon
Trinimon

Reputation: 13957

Quote the ' in the right way and replace the trailing || by ;:

RETURN
'SELECT 1, LAN_ID label,'||
'  ''#''              target,'||
'    NULL          is_current_list_entry,'||
'  ''http://orig03.deviantart.net/efa6/f/2015/200/5/6/anon_icon_thinger_by_arofexdracona-d920vda.png''    image,' || 
'    NULL             image_attribute,'||
'    NULL             image_alt_attribute,'||
'  ''left''           attribute1,'||
'  ''fa-clock-o''     attribute2,'||
'    DATE_POSTED      attribute3,'||
'    RESPONSE         attribute4'||
'  from CHAT_RESPONSE'||
' where LAN_ID IS NOT NULL'||
' order by DATE_POSTED DESC;';

... and add some spaces before from and where.

Upvotes: 2

Related Questions