sql - Using sequence.nextval in subquery -


i want create template (via sql) can copied straight ms excel.

generally went pretty well, however, i've run problem field supposed store excel formula. field supposed used create insert statements in excel file, based on user input in 1 of columns of excel sheet.

here's code:

select -- other fields here [...], (select '="insert mytable values(" &c' || create_inserts_temp_seq.nextval || '&",''this column filled user in excel'',''"&d' || create_inserts_temp_seq.currval || '&"'',14,sysdate);"' dual) sql_statement mytable; 

i getting error message ora-02287: sequence number not allowed here.

why not allowed in subquery? idea how fix this?

i must have access these values in order create functioning excel formula, these numbers reference respective excel rows...

the documentation includes restrictions, including:

currval , nextval cannot used in these places:

  • a subquery
  • ...

but don't need subquery here:

select -- other fields here [...], '="insert mytable values(" &c' || create_inserts_temp_seq.nextval   || '&",''this column filled user in excel'',''"&d'   || create_inserts_temp_seq.currval || '&"'',14,sysdate);"' sql_statement mytable; 

this form doesn't generate error.

i suspect once reason isn't allowed in subquery because isn't clear, or deterministic, how many times subquery executed. if had worked in scenario might have got same insert statement every row in table, presumably isn't intention.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

mysql - FireDac error 314 - but DLLs are in program directory -