Question

Here is my code:

create or replace
procedure postGateway (flgManual in nvarchar2, segmentID in number) as
sequel string(2000); 


  cursor download_cursor is
    select downloadid from ipcsdd_download_process where status LIKE 'W' OR status 

LIKE 'E';



 cursor table_cursor is

   select table_name from user_tab_columns where column_name = 'DOWNLOADID' and 

table_name like 'IPCSDD%' OR table_name like 'IPCSCUSTDD' group by table_name;

begin       

    for download in download_cursor
    loop
        dbms_output.put_line('DownloadID: ' || download.downloadid );

      for usertable in table_cursor
     loop

sequel:=' select * FROM'||usertable.table_name||'where downloadid='||download.downloadid;
execute immediate sequel;
      dbms_output.put_line(' select * from'||usertable.table_name||'where downloadid='||download.downloadid);  
    end loop;   

  end loop;

end postGateway ;

What I doing here is: In first cursor I am trying to get the downloadids whose status are W or E. In the second cursor I am trying to get the tables which have downloadid coloumn and those table name should start with IPCSDD or IPCSCUSTDD.

Now I have to write a query such that In every table starting from IPCSDD that i get from cursor 2 i need to see if a data is present for the downloadid that i get from cursor 1. I tried writing dynamic sql but it gives me error saying "00923. 00000 - "FROM keyword not found where expected"" .

How can I achieve this?

Thanks

Was it helpful?

Solution

You simply neglected to add spaces after and before your keywords, with a space after FROM and a space before where:

sequel:=' select * FROM '||usertable.table_name||' where downloadid='||download.downloadid;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top