I have a query in quotes(' '). I want Oracle SQL to not to treat as string but as a query and store the data from the query in a variable.
Here I am trying to store the date in array - example:
[10-JAN-22 01.47,10-JAN-22 01.47]
which is a string by the way
Code is here
DECLARE qms varchar(400);
BEGIN
qms := 'select ''['' || TO_CHAR(CURRENT_TIMESTAMP, ''DD-MON-RR HH.MI'') || '',''|| TO_CHAR(CURRENT_TIMESTAMP, ''DD-MON-RR HH.MI'') || '']'' as customdate from dual';
dbms_output.put_line('value of varl is ' ||qms);
END;
Here is the output
value of varl is select '[' || TO_CHAR(CURRENT_TIMESTAMP, 'DD-MON-RR HH.MI') || ','|| TO_CHAR(CURRENT_TIMESTAMP, 'DD-MON-RR HH.MI') || ']' as customdate from dual
I need to get the data from query but here the query is getting printed.
I am newbie and just learning SQL - any help would be appreciated