Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

how to get max date in variable using dynamic query

947771Feb 4 2013 — edited Feb 5 2013
Hi,

the following code gets all dates from sourcetable i want only max date , so i thought max function can be added and it will work
but still i have to create a table for one value(scalar) can get it in any other effeciant way.

declare
TYPE date_string IS TABLE OF VARCHAR(1000);
date_obj date_string;
BEGIN

EXECUTE IMMEDIATE 'SELECT to_char('''||day1||'-'||month1||'-'||year1||''') FROM '||source_schema||'.'|| sourcetable ||'' bulk collect INTO date_obj;

FOR indx IN date_obj.FIRST..date_obj.LAST loop
dbms_output.put_line(
date_obj(indx));
END loop;

DBMS_OUTPUT.PUT_LINE('Sample output');
END;


yours sincerely
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 5 2013
Added on Feb 4 2013
3 comments
3,580 views