首页 > 解决方案 > Query as number parameter inside another query

问题描述

Is it possible (in one query) to get the result of query_2 and put it as parameter to replace the number 7 in the query_1 ?

query_1 : 

CREATE SEQUENCE  "SEQ_PK_ABC"  MINVALUE 1 MAXVALUE 9999 INCREMENT BY 1 START WITH 7  ;

query_2 : 

select count(*)+1 from Table1 ; 

标签: sqloracle

解决方案


You can do it with dynamic sql.

use like this:

EXECUTE IMMEDIATE  'CREATE SEQUENCE  "SEQ_PK_ABC"  MINVALUE 1 MAXVALUE 9999 INCREMENT BY 1 START WITH '||YOUR_NUMBER  ;

推荐阅读