sql - 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 ;
解决方案
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 ;
推荐阅读
- sdk - 为什么 Yocto SDK 不能构建 Yocto SDK?
- javascript - Jquery创建没有结束标签的元素
- docker - Dockerfiles 中的多行注释
- palindrome - Java BitSet 示例 - Can Palindrome 算法
- terraform - terraform 状态文件已重新定位,terraform 现在与 openstack 刷新/导入错误时的基础设施没有关联
- php - 使用 laravel 将裁剪后的图像保存在 public/uploads 文件夹中
- http - RestApi:404、422 还是 500?
- php - 使用 php 上传文件 | 文件不再上传
- tableau-api - 如何在 Tableau 中堆叠两个度量,同时将其余度量保留为单列
- asp.net-core - 在 ASP.NET Core 中保护对 .html 文件的请求