oracle - Procedure with looping and execute immediate -
oracle - Procedure with looping and execute immediate -
recently have started preparing datamarts regular reporting process, , tried create utilize of procedures parameters.
so read this guideline , tried replicate confused error in compiling.
here code:
create or replace procedure mig_rate @rep_date date create or replace table mig_temp1( report_date date, portfolio string, bucket integer, q integer); begin j in 1..7 loop t in 0..32 loop -- execute immediate 'bla-bla-bla insert statement mig_temp1 end loop; end loop; end
this results in pls-00103
saying @
symbol unexpected.
what's wrong syntax, how should set parameters procedure??
the main thing wrong you're trying utilize sql server syntax in oracle database.
firstly, oracle object names have start letter (unless utilize quoted identifiers, please don't) and... well, here relevant parts:
nonquoted identifiers must begin alphabetic character database character set. quoted identifiers can begin character.
nonquoted identifiers can contain alphanumeric characters database character set , underscore (_), dollar sign ($), , pound sign (#). database links can contain periods (.) , "at" signs (@). oracle discourages using $ , # in nonquoted identifiers.
quoted identifiers can contain characters , punctuations marks spaces. however, neither quoted nor nonquoted identifiers can contain double quotation marks or null character (\0).
... can't utilize @
@ in procedure name, , don't need that's sql server thing (i think, don't utilize that!).
edit: see, i'm unfamiliar sql server misread doing. procedure name ok, that's not how declare parameters; should start:
create or replace procedure mig_rate(rep_date date) ...
secondly, can't create (declare?) table in oracle procedure. looks want temporary table duration of procedure, that's not how oracle works; can create global temporary table outside procedure it's permanent database object - info temporary.
you can utilize pl/sql collection instead depends want it. if it's staging area before inserting normal table might able single sql command, perform better.
i'm not sure why you'd want utilize dynamic sql (execute immediate
) here...
please refer pl/sql language reference , oracle-specific sites rather sql server-specific sites larn do; there important differences in how work.
oracle pls-00103
Comments
Post a Comment