扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
在本页阅读全文(共2页)
ID | NAME | SALARY |
100 | Jacky | 5600 |
101 | Rose | 3000 |
102 | John | 4500 |
create or replace procedure create_table as begin execute immediate ' create table emp(id number, name varchar2(10) salary number; )'; --动态SQL为DDL语句 insert into emp values (100,'jacky',5600); insert into emp values (101,'rose',3000); insert into emp values (102,'john',4500); end create_table; |
create or replace procedure find_info(p_id number) as v_name varchar2(10); v_salary number; begin execute immediate ' select name,salary from emp where id=:1' using p_id returning into v_name,v_salary; --动态SQL为查询语句 dbms_output.put_line(v_name ||'的收入为:'||to_char(v_salary)); exception when others then dbms_output.put_line('找不到相应数据'); end find_info; |
create or replace procedure find_emp(p_salary number) as r_emp emp%rowtype; type c_type is ref cursor; c1 c_type; begin open c1 for ' select * from emp where salary >:1' using p_salary; loop fetch c1 into r_emp; exit when c1%notfound; dbms_output.put_line('薪水大于‘||to_char(p_salary)||’的员工为:‘); dbms_output.put_line('ID为'to_char(r_emp)||' 其姓名为:'||r_emp.name); end loop; close c1; end create_table; |
濠电姷顣介埀顒€鍟块埀顒€缍婇幃妯诲緞閹邦剛鐣洪梺闈浥堥弲婊勬叏濠婂牊鍋ㄦい鏍ㄧ〒閹藉啴鏌熼悜鈺傛珚鐎规洘宀稿畷鍫曞煛閸屾粍娈搁梻浣筋嚃閸ㄤ即宕㈤弽顐ュС闁挎稑瀚崰鍡樸亜閵堝懎濮┑鈽嗗亝濠㈡ê螞濡ゅ懏鍋傛繛鍡樻尭鐎氬鏌嶈閸撶喎顕i渚婄矗濞撴埃鍋撻柣娑欐崌閺屾稑鈹戦崨顕呮▊缂備焦顨呴惌鍌炵嵁鎼淬劌鐒垫い鎺戝鐎氬銇勯弽銊ф噥缂佽妫濋弻鐔碱敇瑜嶉悘鑼磼鏉堛劎绠為柡灞芥喘閺佹劙宕熼鐘虫緰闂佽崵濮抽梽宥夊垂閽樺)锝夊礋椤栨稑娈滈梺纭呮硾椤洟鍩€椤掆偓閿曪妇妲愰弮鍫濈闁绘劕寮Δ鍛厸闁割偒鍋勯悘锕傛煕鐎n偆澧紒鍌涘笧閹瑰嫰鎼圭憴鍕靛晥闂備礁鎼€氱兘宕归柆宥呯;鐎广儱顦伴崕宥夋煕閺囥劌澧ù鐘趁湁闁挎繂妫楅埢鏇㈡煃瑜滈崜姘跺蓟閵娧勵偨闁绘劕顕埢鏇㈡倵閿濆倹娅囨い蹇涗憾閺屾洟宕遍鐔奉伓