當前位置:九游会j9娱乐平台-九游ag登录中心网址 » 存儲配置 » oracle存儲過程ifin

oracle存儲過程ifin-九游会j9娱乐平台

發布時間: 2024-02-08 02:19:16

a. oracle存儲過程怎麼寫循環

寫循環的操作方法和步驟如下:

1、第一步,編寫存儲過程的整體結構,然後定義變數,見下圖。

b. oracle儲存過程中,if條件為某變數不等於1,怎麼寫

oracle存儲過程中的if條件判斷的寫法:
比如:
temp varchar2(10) := '10000';
if temp <> '10000' then
insert into ...
else
update .......

end if;

c. oracle存儲過程if判斷的問題

問題1:當你傳入37
時,if
flag>5
已經滿足條件了,直接v_value
:=1;,不會繼續判斷了。然後就調到end
if。可以按f9調試,不信一步步看它的執行過程。
問題2:if
v_null=null,不是這樣寫,是if
v_null
is
null
,就會輸出888啦。

d. oracle 存儲過程中 如果用if語句判斷一條查詢語句的結果集是否為空

已經經過測試,可以。

create table test1023(id int); --創建測試表 test1023

declare cnt int;
begin
select count(*) into cnt from test1023;
if cnt=0 then
insert into test1023 values('1');
commit;
end if;
end;

e. oracle存儲過程循環怎麼寫

oracle中有三種循環(for、while、loop):
1、loop循環:

sql">createorreplaceprocerepro_test_loopis
inumber;
begin
i:=0;
loop
i:=i 1;
dbms_output.put_line(i);
ifi>5then
exit;
endif;
endloop;
endpro_test_loop;


2、while循環:

createorreplaceprocerepro_test_loopis
inumber;
begin
i:=0;
whilei<5loop
i:=i 1;
dbms_output.put_line(i);
endloop;
endpro_test_loop;


3、for循環1:

createorreplaceprocerepro_test_foris
inumber;
begin
i:=0;
foriin1..5loop
dbms_output.put_line(i);
endloop;
endpro_test_for;

4、for循環2:

createorreplaceprocerepro_test_cursoris
userrowt_user%rowtype;
cursoruserrowsis
select*fromt_user;
begin
foruserrowinuserrowsloop
dbms_output.put_line(userrow.id||','||userrow.name||','||userrows%rowcount);
endloop;
endpro_test_cursor;

f. oracle 怎麼調用存儲過程

oracle存儲過程 以oracle自帶例子資料庫的表舉例
1、

create or replace procere p
is
cursor c is
select * from emp2 for update;
begin
for v_emp in c loop
if(v_emp.sal <2000) then
update emp2 set sal =sal 1 where current of c ;
elsif(v_emp.sal>=2000) then
delete from emp2 where current of c;
end if;
end loop;
commit;
end;

創建了存儲過程不代表運行了存儲過程;
運行此存儲過程 :
方式一 exec p;
方式二
begin
p;
end;
2、帶參數的存儲過程
in 相當於程序里的參數,供傳入用,在存儲過程不能改變其值;
out 相當於程序里的返回值,在存儲過程中可以為其賦值傳出;
in out 既可以當參數又可以當返回值用;
不帶上述說明符默認為in類型;

下例中v_a v_b 為in類型
v_c 為out類型
v_d 為in out 類型

create or replace procere p(v_a in number,v_b number,v_c out number,v_d in out number)
is
begin
if(v_a > v_b) then
v_c := v_a;
else
v_c := v_b;
end if;
v_d := v_d 1;
end;

---> 調試時:
可以在命令窗口調試,出錯時 用show errors 顯示出錯信息;
可以在pldv中調試;

---> 運行時:
可以在命令窗口運行:
declare
v_a number:=3;
v_b number:=4;
v_c number;
v_d number:=5;
begin
p(v_a,v_b,v_c,v_d);
dbms_output.put_line(v_c);
dbms_output.put_line(v_d);
end;
可以在pldv中調試;

g. 誰知道oracle資料庫存儲過程的語法

oracle
存儲過程
的基本語法
1.基本結構
create
or
replace
procedure
存儲過程名字
(
參數1
in
number,
參數2
in
number
)
is
變數1
integer
:=0;
變數2
date;
begin
end
存儲過程名字
2.select
into
statement
將select查詢的結果存入到變數中,可以同時將多個
列存儲
多個變數中,必須有一條
記錄,否則拋出異常(如果沒有記錄拋出no_data_found)
例子:
begin
select
col1,col2
into
變數1,變數2
from
typestruct
where
xxx;
exception
when
no_data_found
then
xxxx;
end;
...
3.if
判斷
if
v_test=1
then
begin
do
something
end;
end
if;
4.while
循環
while
v_test=1
loop
begin
xxxx
end;
end
loop;
5.變數賦值
v_test
:=
123;
6.用for
in
使用cursor
...
is
cursor
cur
is
select
*
from
xxx;
begin
for
cur_result
in
cur
loop
begin
v_sum
:=cur_result.列名1 cur_result.列名2
end;
end
loop;
end;
7.帶參數的cursor
cursor
c_user(c_id
number)
is
select
name
from
user
where
typeid=c_id;
open
c_user(
變數值
);
loop
fetch
c_user
into
v_name;
exit
fetch
c_user%notfound;
do
something
end
loop;
close
c_user;
8.用pl/sql
developer
debug
連接資料庫後建立一個test
window
在窗口輸入調用sp的代碼,f9開始debug,ctrl n單步調試
參考
http://www.cnblogs.com/happyday56/archive/2007/07/05/806830.html

熱點內容
androidapk版本號 發布:2024-02-10 00:04:16 瀏覽:990
培訓學校源碼 發布:2024-02-09 23:57:28 瀏覽:687
pythonifaandb 發布:2024-02-09 23:36:26 瀏覽:264
javarsa私鑰加密 發布:2024-02-09 23:36:17 瀏覽:239
python證書微軟認證 發布:2024-02-09 23:34:27 瀏覽:999
wlan沒有ip配置怎麼解決 發布:2024-02-09 23:24:19 瀏覽:532
javatoexe 發布:2024-02-09 22:48:53 瀏覽:418
路由器撥號賬號密碼在哪裡 發布:2024-02-09 22:29:30 瀏覽:164
ssd緩存是什麼 發布:2024-02-09 22:00:12 瀏覽:626
簡單游腳本試用破解 發布:2024-02-09 21:42:34 瀏覽:41
网站地图