数据库

位置:IT落伍者 >> 数据库 >> 浏览文章

Oracle数据库-PL/SQL整理(1)


发布日期:2024年04月18日
 
Oracle数据库-PL/SQL整理(1)

获取系统记录行数

go_block(T_WARITEMPRT);

last_record;

row_count:=:systemtrigger_record; systemcursor_record

execute_trigger(POSTCHANGE);

设置鼠标状态

set_application_property(cursor_styleBUSY);

raise form_trigger_failure;

显示错误信息

exception when others then

display_note(sqlerrm||sqlcode:globallogon_user);

decode

decode(afreightmode企业自付供应商付费企业代付供应商代付null)

decode(qtyonhand qtyinitinvtranqtyinvtranqtynull)

导出路径

select * from t_parameter where f_name=LeanERPTempDir;

select f_c_value from t_parameter where f_name =WebServer;

合同附件

select f_c_value from t_parameter where f_name=purorderaccesspath;

select f_c_value from t_parameter where f_name=purorderaccessurl;

设置值列表

SET_ITEM_PROPERTY(topORIGINALNOLOV_NAMELOV_MSO);

LIST_VALUES;

下拉列表

n:=populate_group(rec_lb);

populate_list(BLK_BUTAPPTYPErec_lb);

:bLK_BUTAPPTYPE:=;

调用另一模块

DECLARE

pl_id ParamList;

v_string varchar();

v_itemname varchar();

BEGIN

pl_id := Get_Parameter_List(calendar);

IF NOT Id_Null(pl_id) THEN

Destroy_Parameter_List(pl_id);

END IF;

pl_id := Create_Parameter_List(calendar);

v_itemname:=:systemcurrent_block||||:systemcurrent_item;

v_string:=name_in(v_itemname);

Add_Parameter(pl_id p_strTEXT_PARAMETERv_string);

Call_Form(input_strno_hideno_replaceno_query_onlypl_id);

copy(:globalstrv_itemname); Erase(:globalstr);

END;

批量处理

set_application_property(cursor_styleBUSY);

SYNCHRONIZE;

first_record;

loop

null;

exit when :systemlast_record = TRUE;

next_record;

end loop;

set_application_property(cursor_styleDEFAULT);

bell;

display_note(SRMP:globallogon_user);

采购计划关闭完毕!

对话框

IF display_stop(INV :GLOBALlogon_user) <> alert_button THEN

RETURN;

END IF;

取得货币名称

begin

select currencydesc

into v_currencydesc

from t_currency

where currencycode = csplymoneyflag;

exception when others then v_currencydesc := 人民币(元);

end;

询问对话框

declare

return_value number;

begin

set_alert_property(stop_alertalert_message_text确认送审该合同吗?);

return_value := show_alert(stop_alert);

if return_value != alert_button then

return;

end if;

end;

询问对话框

DECLARE

return_value number;

BEGIN

return_value := display_stop(mdm:globallogon_user);

IF return_value = ALERT_BUTTON THEN

COMMIT_FORM;

END IF;

END;

取下周一

select trunc(sysdated)+ from dual;

message_level

oldmsg := :SystemMessage_Level;

IF reldef = FALSE THEN

Go_Block(detail);

Check_Package_Failure;

:SystemMessage_Level := ;

Execute_Query;

:SystemMessage_Level := oldmsg;

ELSE

取当前年度期段号

begin

select yearperiod

into v_yearv_period

from t_accperiod

where sysdate >= startdate

and to_char(sysdateyyyy/mm/dd)<=to_char(enddateyyyy/mm/dd);

exception when others then null;

end;

设置画布属性

vCan:=FIND_VIEW(CAN_PRTNO);

SET_VIEW_PROPERTY(vCanVISIBLEproperty_true);

vCan:=FIND_VIEW(CAN_PRTNO);

SET_VIEW_PROPERTY(vCanVISIBLEproperty_false);

设备提示信息

elsif :topopsrc = X or :topopsrc=T then

set_item_property(toptranobjprompt_text客户代码);

else

set_item_property(toptranobjprompt_text部门代码);

end if;

设置值列表KEYLISTVAL

ELSIF :topOPSRC=I THEN 零星出库

SET_ITEM_PROPERTY(topORIGINALNOLOV_NAMELOV_MSI);

LIST_VALUES;

IF :topORIGINALNO IS NOT NULL THEN

PRTNO_MSI;

END IF;

END IF;

调用值列表show_lov

DECLARE

a_value_chosen BOOLEAN;

BEGIN

a_value_chosen := Show_Lov(lov_name);

IF a_value_chosen THEN

set_block_property(t_efficiencydefault_whereusername = :controldisplay_name);

go_block(t_efficiency);

execute_query;

set_block_property(t_efficiencydefault_whereusername in (select username from t_hrmuser where department = :globaluser_dept));

END IF;

END;

生成序号

declare

vlpadnum number;

maxno varchar();

cursor cerpcode is select sequencelpadnum from t_erpcode

where erpcode=PURAPPNO and prifix=to_char(sysdateyy)||to_char(sysdatemm) for update nowait;

begin

if :t_purappappno is null then

if :SYSTEMMODE = NORMAL THEN

begin

begin

for c in cerpcode loop

update t_erpcode set sequence=sequence+ where erpcode=PURAPPNO and prifix=to_char(sysdateyy)||to_char(sysdatemm);

end loop;

exception

when others then

display_note(SYS:globallogon_user);

raise form_trigger_failure;

end;

select sequencelpadnum into maxnovlpadnum from t_erpcode where erpcode=PURAPPNO and prifix=to_char(sysdateyy)||to_char(sysdatemm);

exception

when NO_DATA_FOUND then

select count(*)+ into maxno from t_purapp where appno like %||to_char(sysdateyy)||to_char(sysdatemm)||%;

select max()

vlpadnum:=;

insert into t_erpcode(erpcodeprifixsequencelpadnum)

values (PURAPPNOto_char(sysdateyy)||to_char(sysdatemm)maxnovlpadnum);

end;

:t_purappappno := Q||:globallogon_user||to_char(sysdateyy)||to_char(sysdatemm)||lpad(maxnovlpadnum);

end if;

end if;

end;

遍历树

select t_prtstrudefprtno

t_prtbasdefprtdesc

t_prtbasdefmtltmrk

t_prtstrudefprtpqty

t_prtbasdefprtum

t_prtstrudeftranprtno

from t_prtstrudeft_prtbasdef

where t_prtstrudefprtno = t_prtbasdefprtno

connect by prior t_prtstrudefprtno=t_prtstrudefprntno

start with t_prtstrudefprntno=:BLOCK_BUTTONPRTNO;

/*

** Builtin: FORMS_DDL

** Example: The expression can be a string literal

*/

BEGIN

Forms_DDL(create table temp(n NUMBER));

IF NOT Form_Success THEN

Message (Table Creation Failed);

ELSE

Message (Table Created);

END IF;

END;

物料所属大类判断

and (exists (select a from t_prtinclass c where cclassid=||:blk_queryclassid|| and cprtno=v_totqryprtno ) or :blk_queryclassid is null)

给值列表赋初值

declare

cursor v_cur is select machtype A machtype B from t_gkdept order by machtype;

N_INDEX NUMBER :=;

begin

DELETE_LIST_ELEMENT(T_TPMSCKMTNMACHTYPE);

for c in v_cur loop

Add_List_Element(T_TPMSCKMTNMACHTYPEN_INDEXCACB);

N_INDEX := N_INDEX + ;

end loop;

end;

查询重复数据

select rpno from t_purtrace group by rpno having count(rpno) >;

生成单据号

PROCEDURE GET_PRTNO is

v_sysdate varchar();

v_Svdictateno varchar();

v_DbodNo varchar();

n_count integer;

v_count varchar();

n_count integer;

n_count integer;

v_count varchar();

n_num number;

v_num varchar();

BEGIN

v_DbodNo:= ZS;

v_sysdate:=to_char(sysdateYYMMDD);

获取满足条件的记录数

select count(*)+ into n_num

from bas_prtbasdef

where prtno like v_DbodNo||v_sysdate||%;

v_num := to_char(n_num);

填充

v_count:=lpad(v_num);

合成为物料号

v_Svdictateno:=v_DbodNo||v_sysdate||v_count;

判断是否存在该号码

select count(*) into n_count from bas_prtbasdef

where prtno=v_Svdictateno;

不存在

if n_count= then

把新物料号赋给参数p_prtno

:parameterp_prtno := v_Svdictateno;

若存在

elsif n_count> then

递增

n_count:=v_count+;

loop

v_count:=lpad(n_count);

v_Svdictateno:=v_DbodNo||v_sysdate||v_count;

select count(*) into n_count from bas_prtbasdef

where prtno=v_Svdictateno;

if n_count= then

:parameterp_prtno := v_Svdictateno;

exit;退出循环

end if;

n_count:=n_count+;

end loop;

end if;

exception when others then

display_note(sqlerrm||sqlcode:globallogon_user);

END;

当保存记录时控制同一物料质量编号不能相同

DECLARE

row_count NUMBER; 记录行数

row_num number; 所新建或修改记录行数

V_PRTLOTNO t_srmchkprojectprtlotno%type; 质量编号

BEGIN

获取当前记录行数

row_num := :systemtrigger_record;

first_record;

loop

row_count:=:systemtrigger_record;

V_PRTLOTNO := :t_srmchkprojectprtlotno;

GO_RECORD(ROW_COUNT + );

loop

若质量编号相同

if v_prtlotno = :t_srmchkprojectprtlotno then

display_note(同种物料的质量编号不能相同!请改正:globallogon_user);

go_item(t_srmchkprojectprtlotno);

return;返回

exit;

end if;

exit when :systemlast_record = TRUE;

next_record;

end loop;

GO_RECORD(ROW_COUNT+); 用以最后一行记录判断

exit when :systemlast_record = TRUE;

返回外层循环记录

GO_RECORD(ROW_COUNT);

next_record;

end loop;

commit_form;

返回当前记录

go_record(row_num);

EXCEPTION WHEN OTHERS THEN NULL;

END;

自动定位树结构的焦点

DECLARE

htree item;

find_node FtreeNODE;

begin

htree:= Find_Item(T_BOMBOM);

find_node := FTREEFIND_TREE_NODE(htree:T_PRTBASDEF_CREATEPRTNOFTREEFIND_NEXTFTREENODE_VALUEFTREEROOT_NODEFTREEROOT_NODE);

IF NOT FtreeID_NULL(find_node) then 如果存在对应的节点

pause;

FTREESET_TREE_SELECTION(htree FIND_NODE FTREESELECT_TOGGLE);

end if;

end;

杀死死进程

select SID serial# USERNAME SCHEMANAME STATUS OSUSER OSUSERTERMINAL PROGRAM LOGON_TIME from v$session;

ALTER SYSTEM KILL SESSION ;

select funcDECODEPASSWD(password) from t_user where username = ;

select funcENCODEPASSWD(password) from t_user where username = ;

用户权限

(:GLOBALLOGON_USER in (select object from t_roleuser where role=MODIFER and flag=) or MODIFER=:GLOBALLOGON_USER)

列表项

DECLARE

v_n Number;

BEGIN

v_n := populate_group(rec_ptype);

populate_list(t_freesbprntnorec_ptype);

END;

提示对话框

set_alert_property(note_alertalert_message_text口令更改成功!);

return_value := show_alert(note_alert);

改变按钮标签文本

DECLARE

v_Count NUMBER;

v_Label VARCHAR();记录全选按钮的标签文本

BEGIN

Go_Block(user_col_comments);

v_Label := Get_Item_Property(Blk_ControlBtn_Select_Col Label);

First_Record;

IF v_Label = + THEN

LOOP

/*SELECT COUNT(*)

INTO v_Count

FROM t_Fieldrole

WHERE Table_Name = :User_Col_CommentsTable_Name

AND Column_Name = :User_Col_CommentsColumn_Name

AND Role = :t_FieldroleRole;*/

IF v_Count = THEN

:User_Col_CommentsChk_Select := ;

END IF;

EXIT WHEN :SystemLast_Record = TRUE;

NEXT_RECORD;

END LOOP;

First_Record;

Set_Item_Property(Blk_ControlBtn_Select_Col Label);

Set_Item_Property(Blk_ControlBtn_Select_Col TOOLTIP_TEXT取消选择);

ELSIF v_Label = THEN

First_Record;

LOOP

:User_Col_CommentsChk_Select := ;

EXIT WHEN :SystemLast_Record = TRUE;

NEXT_RECORD;

END LOOP;

First_Record;

Set_Item_Property(Blk_ControlBtn_Select_Col Label+);

Set_Item_Property(Blk_ControlBtn_Select_Col TOOLTIP_TEXT选取全部);

END IF;

EXCEPTION

WHEN OTHERS THEN

NULL;

END;

上一篇:Delphi中对Oracle存取RTF文档

下一篇:ORACLE在HP-UX下的系列问题处理(21)