oracle怎么导出function和procedure,即函数和存储过程

oracle怎么导出function和procedure,即函数和存储过程,第1张

使用oracle的一般都装了PL/SQL吧,对象窗口,找到对应的函数或者存储过程,右键查看或编辑。

一般单个我是这么用,如果很多的话可以参考一下网上提供的方法

oracle 导出一个用户下的所有存储过程

方法一:

set echo off ;

set heading off ;

set feedback off ;

spool d:\tmptxt

select text from user_source ;

spool off;

方法二:

使用PL/SQL 菜单 Tools --> Export user objects ,对d出的dialog中选择user和output file,选中要导出的内容,点击export导出就行了

两种方法,建议你用触发器:

create or replace trigger business

after insert on tbl_business

for each row

begin

if :newbusiness_amt =2000000 then

insert into tbl_Rbusiness(business_id,user_id,business_date,business_amt) values (:newbusiness_id,:newuser_id,:newbusiness_date,:newbusiness_amt);

end if;

end;

函数:

create or replace function amount return number as

v_exists number;

begin

for v in (select from tbl_business) loop

if (vbusiness_amt = 2000000) then

select count() into v_exists from ip

where business_id = vbusiness_id

and user_id = vuser_id

and business_date = vbusiness_date

and business_amt = vbusiness_amt;

if v_exists = 0 then

insert into ip (business_id,user_id,business_date,business_amt)

values (vbusiness_id,vuser_id,vbusiness_date,vbusiness_amt);

commit;

end if;

end if;

end loop;

end;

CREATE OR REPLACE FUNCTION fun_get_met_cas_diagnose(inpatient VARCHAR2)

RETURN t_table IS

rs t_table := t_table();

BEGIN

rsextend(1);

SELECT obj_table(ticd_code, trow_num, tdiag_name)

INTO rs(1)

FROM (SELECT dicd_code, ddiag_name, rownum row_num

FROM met_cas_diagnose d

WHERE dinpatient_no = inpatient

AND ddiag_kind = '1'

ORDER BY dhappen_no) t;

RETURN rs;

END fun_get_met_cas_diagnose;

select holiday into star_h from time 改成 select max(holiday) into star_h from time

取最大的那一天 再一个个比好了。。

或者这样做更方便

用not exist 只要当这个日期不在这个表中就返回这个日期,否则就-1 再查

我试着去弄了一下,只能返回游标啊

select xx from dual好像本身只能返回一行数据,无法返回多行数据

以下是我做一个返回游标的函数。

create or replace package types as

type mytype is ref cursor;

end;

create or replace function oraclefunc(col_in varchar)

return typesmytype is

mycursor typesmytype;

restr varchar2(4096);

begin

restr:=trim(col_in);

restr:=replace(restr,',',''' as 列名 from dual union select ''');

restr:=''''||restr||'''';

restr:='select '||restr;

restr:=restr||' as 列名 from dual';

open mycursor for restr;

return mycursor;

end;

以上就是关于oracle怎么导出function和procedure,即函数和存储过程全部的内容,包括:oracle怎么导出function和procedure,即函数和存储过程、定义一个oracle 自定义函数 function、帮看一下oracle的这个function怎么写等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/9464601.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-04-28
下一篇2023-04-28

发表评论

登录后才能评论

评论列表(0条)

    保存