簡體   English   中英

如何在 PostgreSQL 中創建過程並調用/執行

[英]How to create procedure and call/Execute in PostgreSQL

如何在 PostgreSQL 中創建過程並調用/執行

要返回結果“表”,請使用 function 而不是過程:

create function Proc_StudentLogin(Sid bigint)
  returns setof students
as
$Body$
  select * from students where id = sid;
$Body$
language sql
stable;
-- Use function:
select * 
from Proc_StudentLogin(1);
--Create Procedure

Create procedure Proc_StudentLogin(

Sid bigint,

inout get_result refcursor)

Language 'plpgsql'

AS $Body$

Begin

open get_result for 

Select * from Students where id = sid;

End

$Body$;



--Call procedure

Call Proc_StudentLogin(1,'result');

fetch all in "result";

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM