1031整理
create or replace procedure pr_test1 is2 begin3 4 if 2 > 1 then5 6 7 dbms_output.put_line('條件成立');8 9 elsif 4 > 3 then10 11 if 7 > 6 then12 13 dbms_output.put_line('條件不成立1');14 15 end if;16 17 elsif 6 > 5 then18 19 dbms_output.put_line('條件成立2');20 21 else22 dbms_output.put_line('條件不成立3');23 24 end if;25 26 27 28 29 30 31 end pr_test1;32 33 34 35 create or replace procedure pr_text2 is36 37 v_case number(3) := 100;38 39 begin40 41 case v_case42 43 when 1 then44 45 dbms_output.put_line('條件匹配=1');46 47 when 100 then48 49 dbms_output.put_line('條件成匹配=100');50 51 else52 53 dbms_output.put_line('條件不匹配');54 55 end case;56 57 case58 59 when 8 > 7 then60 61 dbms_output.put_line('8>7成立');62 63 when 9 > 8 then64 65 dbms_output.put_line('9>8成立');66 67 else68 69 dbms_output.put_line('都不成立');70 71 end case;72 73 --loop循環74 75 <<loop1>>76 loop77 78 v_case:=v_case-1;79 80 dbms_output.put_line('v_case='||v_case);81 82 --if(v_case = 90) then83 84 --dbms_output.put_line('退出循環');85 86 exit loop1 when v_case =90;87 88 --end if;89 90 end loop;91 92 93 while v_case >8094 95 loop96 97 v_case:=v_case-1;98 99 dbms_output.put_line('v_case='||v_case);
100
101 --exit when v_case =90;
102
103 end loop;
104
105
106 dbms_output.put_line('v_case='||'--------');
107 for inx in reverse 1..10 loop --1..10(逐漸加1) reverse(從大向小加)
108
109
110 v_case:=v_case+inx;
111
112 dbms_output.put_line('v_case='||v_case);
113
114
115
116 end loop;
117
118
119
120 end pr_text2;
121
122
123
124 create or replace procedure pr_test2(v_nl in varchar2 default '22' ) is
125 begin
126
127 update t_hq_ryxx set ruzrq = sysdate where nianl = v_nl;
128
129 commit;
130
131 end pr_test2;
132
133
134 create or replace procedure pr_test3(v_nl in varchar2,v_xx in out varchar2) is
135 begin
136
137 select xingm into v_xx from t_hq_ryxx where nianl = v_nl and bum = v_xx;
138
139 if sql%found then
140
141
142 dbms_output.put_line('查找到數據了');
143
144
145 else
146
147 dbms_output.put_line('未找到數據');
148
149 end if;
150
151
152
153 exception --異常
154
155
156
157
158 when no_data_found then
159
160 --dbms_output.put_line('未查找到數據');
161 dbms_output.put_line('sqlcode='|| sqlcode);
162 dbms_output.put_line('sqlerrm='|| sqlerrm);
163
164 when others then
165 dbms_output.put_line('查找出錯');
166 dbms_output.put_line('sqlcode='|| sqlcode);
167 dbms_output.put_line('sqlerrm='|| sqlerrm);
168
169
170 end pr_test3;
171
172
173
174 create or replace procedure pr_test4(v_nl in varchar2) is
175
176 v_xm t_hq_ryxx.xingm%type;
177
178 begin
179
180 v_xm := '102';
181 pr_test3(v_nl,v_xm);
182
183 dbms_output.put_line('v_xm='|| v_xm);
184
185
186
187 end pr_test4;
188
189
190
191 create or replace procedure pr_test5 is
192 begin
193
194 update t_hq_ryxx set bum= '101' where bum is null;
195
196 commit;
197
198 if sql%rowcount >0 then
199
200 dbms_output.put_line('更新了'|| sql%rowcount || '記錄');
201
202 else
203
204 dbms_output.put_line('更新了0條記錄');
205
206
207 end if;
208
209 end pr_test5; View Code
轉載于:https://www.cnblogs.com/zxw0004/p/4928769.html
總結
- 上一篇: Oracle(一)
- 下一篇: Js文件中调用其它Js函数的方法