oracle - PL/SQL To Run Simple SQL Commands -


using basic sql, i'm populating table db. uses basic delete statements remove old data , insert statements from clause using dblink. i'm attempting transfer package , have come this:

package:

create or replace  package loaddata    procedure populatetable;   end loaddata; 

pl/sql (package body):

create or replace  package body loaddata  procedure populatetable       begin  delete datatransfer;  insert datatransfer    select valuenum, datacontent, sysdate transfer_data     transfertable@datalink;  commit;  null; end populatetable; end loaddata; 

and run command, run:

exec loaddata.populatetable(); 

my question should procedure have input/output parameter or declared variables? has compiled , worked correctly i'm unsure if i'm following pl/sql methodology.

there no rule provide parameters.

additonally can insert record log table store start date, end date, number of records inserted , number of records deleted in case need track batch execution periodically.

also if package called web page or application may need create exception block , send error message output parameter in user readable form.

edit:

package specification

create or replace  package loaddata    procedure populatetable(out_variable out varchar2);   end loaddata; 

package body

create or replace  package body loaddata procedure populatetable(out_variable out varchar2)       begin delete datatransfer -- <todo:insert records deleted , date log table> insert datatransfer    select valuenum, datacontent, sysdate transfer_data     transfertable@datalink; -- <todo:insert records inserted , date log table> commit; null; -- assign out_variable success if comletes out_variable := 'success'; exception -- when others catches exceptions oracle error message displayed in sqlerrm     when others -- assign out_variable error message if errors out         out_variable := 'error :'||sqlerrm; end populatetable; end loaddata; 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -