一个颇高难度的存储过程

civb 2004-04-30 03:17:52
create or replace procedure delete_all(pName varchar2) is
begin
delete Tbparam where Name= pName and BS in (select BS from TbBase);
..................
end delete_all;


怎么增加一两句,把TbBase 相应的BS的记录也删掉。
我只能想到临时表。不知道怎么在orcale中创建临时表
比如sql中的select into b from a;

...全文
58 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
civb 2004-04-30
  • 打赏
  • 举报
回复
老大详细点阿。。
我试了是错误的阿
strstr varchar(200);
strstr:='select * from test';
错误了。
atao245993 2004-04-30
  • 打赏
  • 举报
回复
PL/SQL可以执行DDL。用动态SQL。
先定义个字符串,比如SQLSTR,然后用下列语句
execute immediate SQLSTR

只是连接字符串的时候注意字符串标记符号'的问题就可以了。
civb 2004-04-30
  • 打赏
  • 举报
回复
存储过程不能Create table ,select的吗?真的晕了。
civb 2004-04-30
  • 打赏
  • 举报
回复
阿涛是写在存储过程中的马。。?
怎么是MGR-00072: There is no more information about this error.

lilygy5(我爱oracle) 的办法不是看到很懂。。

Create table tbxxxxx as select .............这个直接执行可以,放到
存储过程中就不灵啦。。

存储过程中联执行这样的语句都error?
create or replace procedure testtest is
begin
select * from test2;
end testtest;

There is no more information about this error.

atao245993 2004-04-30
  • 打赏
  • 举报
回复
sqlstr='create table tempdelete as select bs from tbparam where name='''||pname||''' '||and bs in (select bs from tbbase);

execute immediate sqlstr;

delete from tbbase where bs in (select bs from tempdelete);

sqlstr='drop table tempdelete';

execute immediate sqlstr;
lilygy5 2004-04-30
  • 打赏
  • 举报
回复
create global temporary tablename(column list)
on commit perserve rows; --提交保留数据,会话临时表
on commit delete rows;  --提交删除数据,事务临时表

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧