暂无图片
postgresql创建存储过程时报错
我来答
分享
大漠
2021-08-17
postgresql创建存储过程时报错
暂无图片 5M

create or replace procedure stu_proc1 (pno in student.sno%type)
pname text;
begin
select sname into pname from student where sno=pno;
dbms_output.put_line(pname);
end;

报错信息:
ERROR: syntax error at or near “pname”
LINE 2: pname text;
^
SQL state: 42601
Character: 68

我来答
添加附件
收藏
分享
问题补充
4条回答
默认
最新
大漠

pg-procedure.png

暂无图片 评论
暂无图片 有用 0
大漠

下图是在Pgadmin4中运行显示

暂无图片 评论
暂无图片 有用 0
章芋文

这个语法不对,不能直接用Oracle的,创建示例如下:

create [or replace] procedure procedure_name(parameter_list) language plpgsql as $$ declare -- variable declaration begin -- stored procedure body end; $$
暂无图片 评论
暂无图片 有用 0
彭冲
create or replace procedure stu_proc1 (pno in student.sno%type)
as $$
declare
    pname text;
begin
    select sname into pname from student where sno=pno;
	raise notice ' %',pname;
end;
$$ language plpgsql;
暂无图片 评论
暂无图片 有用 0
回答交流
提交
问题信息
请登录之后查看
邀请回答
暂无人订阅该标签,敬请期待~~
暂无图片墨值悬赏