a1 -a6 ,6張表,要求分別查出所有的a1.a1、a2.a2、a3.a3、a4.a4、a5.a5.
這五個字段插入到a6的表中去.
a6表的五個字段已經設定好了就是這五個字段
create or replace procedure sp_test
is -- is和as是一樣的
-- 這裡定義變數,以;分隔
v_a1 a1.a1%rowtype;
v_a2 a2.a2%rowtype;
v_a3 a3.a3%rowtype;
v_a4 a4.a4%rowtype;
v_a5 a5.a5%rowtype;
begin
select a1 into v_a1 from a1;
select a2 into v_a2 from a2;
select a3 into v_a3 from a3;
select a4 into v_a4 from a4;
select a5 into v_a5 from a5;
insert into a6(a1,a2,a3,a4,a5)values(v_a1 ,v_a2, v_a3, v_a4, v_a5 );
commit;
end;
--建立乙個帶引數的儲存過程
create or replace procedure p
(v_a in number,v_b number, v_ret out number, v_temp in out number)
--in 代表輸入引數,什麼都不寫,預設是in,out 輸引數,in out 既是輸入也是輸出
isbegin
if(v_a>v_b) then
v_ret := v_a;
else
v_ret := v_b;
end if;
v_temp := v_temp+1;
end--呼叫帶參儲存過程
declare
v_a number := 3;
v_b number := 4;
v_ret number;
v_temp number :=5;
begin
p(v_a,v_b,v_ret,v_temp);
dbms_output.put_line(v_ret);
dbms_output.put_line(v_temp);
end;
--再寫pl/sql程式時的細節,每一句話結束後都要寫";"
-- 尤其是以下三個一定不要忘記加";" end if; end loop; end;
--建立乙個帶引數的儲存過程
create or replace procedure swap(
p1 in out number,
p2 in out number)is
v_temp number;
begin
v_temp:= p1;
p1 :=p2;
p2 := v_temp;
end;
--呼叫帶參儲存過程
declare
num1 number:=10;
num2 number:=20;
begin
swap(num1,num2);
dbms_output.put_line('num1 = '||num1);
dbms_output.put_line('num2 = '||num2);
end;
C 如何呼叫儲存過程簡單的事例
儲存過程在開發過程中,經常使用到,會給我們的開發帶來很多的便利,儲存過程建好後,在 中該如何呼叫呢,下面的是乙個簡單的呼叫儲存過程的示例 1 2 3 4 5 6 7 8 9 create proc p test name varchar 20 rowcount int output asbegin ...
儲存過程系列之儲存過程sql查詢儲存過程的使用
1.查詢某個表被哪些儲存過程 以下簡稱 sp 使用到 select distinct object name id from syscomments where id in select object id from sys.objects where type p and text like ta...
儲存過程系列之儲存過程sql查詢儲存過程的使用
1.查詢某個表被哪些儲存過程 以下簡稱 sp 使用到 select distinct object name id from syscomments where id in select object id from sys.objects where type p and text like ta...