insert into table1(id,corp_id,type)
select fun_gid(),v_corp_id,t.type from table2 t where t.is_defualt = 1
说明:
table1,table2为表名,
fun_gid()生成ID的方法,
v_corp_id已定义的变量,之前已赋值
请教:这个动态sql怎么写?
如下这么写不对:
execute immediate
'insert into table1(id,corp_id,type)
select :id,:corp_id,t.type from table2 t where t.isdefualt = :isdefualt'
using fun_gid(),v_corp_id,1
select fun_gid(),v_corp_id,t.type from table2 t where t.is_defualt = 1
说明:
table1,table2为表名,
fun_gid()生成ID的方法,
v_corp_id已定义的变量,之前已赋值
请教:这个动态sql怎么写?
如下这么写不对:
execute immediate
'insert into table1(id,corp_id,type)
select :id,:corp_id,t.type from table2 t where t.isdefualt = :isdefualt'
using fun_gid(),v_corp_id,1
解决方案 »
- 这段psql语句是什么意思?求高手!
- drop table之后可以直接拿回那些space吗?
- oracle tuxedo tpopen()的问题
- ORACL的系统表user_tables是那个SKIM下的表,
- 使用:NEW的问题
- ORACLE error 1658
- 可以在WIN 2000 PROFESSIONAL下安装 ORACLE8.1.5的服务器版吗
- 100多万条数据不小心被删除了,还可以恢复吗?SOS!!!
- 我是新手!我新装了8.05for nt 的,装了之后不会用,问问大家帮个忙啊~
- Oracle12每添加数据库后,之前的数据库都无法启动
- 写了一个存储过程,但客户不让用游标,不知道怎么写了,高手们快来帮忙吧!!!!急..
- 求一解析字段内分解字符转换的函数
'insert into table1(id,corp_id,type)
select '||fun_gid()||','||v_corp_id||',t.type from table2 t where t.is_defualt = 1';
'insert into table1(id,corp_id,type)
select t.id,t.corp_id,t.type from table2 t where t.id=:id and t.corp_id=:corp_id and t.isdefualt = :isdefualt'
using fun_gid(),v_corp_id,1
'insert into table1(id,corp_id,type)
select '||fun_gid()||','||v_corp_id||',t.type from table2 t where t.is_defualt = 1';
UP!!!
函数方法写在里面要用字串啦
1.将fun_gid()的值先覆盖一个变量,using里面改为这个变量。
2.如果第1步还是报错的话,前两个变量改为1楼的方式拼起来,但是where里面还是用绑定变量。这个肯定没问题了。