ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 动态SQL学习一例

动态SQL学习一例

原创 Linux操作系统 作者:genweihua 时间:2013-01-16 08:50:13 0 删除 编辑
       想写一个传递参数建立用户的存储过程,一直没有写出来,到自己加的群里问了问,说要用到动态SQL,就上网查找关于动态SQL的信息。资料是查了很多,就是不知道怎么写。后来好不容易编译通过了,发现测试的时候报错误。最后再根据网上的资料改写,最终成功了。不过这个存储过程要在sys用户下运行,才能正常运行。在system下说是权限不够。
下边是编译运行成功的例子,放在这里以供参考:

create or replace procedure createUser(Uname char,passwd char)
as
createSQL char(50);
grantSQL char(50);
begin
 createSQL:='create user '||Uname||' identified by '||passwd||'';
 grantSQL:='grant dba to '||Uname||'';
  execute immediate createSQL;
  dbms_output.put_line(createSQL);
  execute immediate grantSQL;
end;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/22275400/viewspace-752725/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
事了拂衣去,深藏功与名!

注册时间:2009-08-28

  • 博文量
    114
  • 访问量
    623621