---设置'时间' DECLARE timer_id Timer; one_minute NUMBER(5) := 60000; BEGIN timer_id := CREATE_TIMER('emp_timer', one_minute, REPEAT|NO_REPEAT); END; ---产生一个'EDITER'框 DECLARE ed_id Editor; status BOOLEAN; BEGIN ed_id:=Find_Editor('edit_name'); ---由'edit_name'导航器定义
IF NOT Id_Null(ed_id) THEN Show_Editor(ed_id, NULL, :block_name.item_name, status); ELSE Message('Editor "Happy_Edit_Window" not found'); RAISE Form_Trigger_Failure; END IF; END; ----产生一个'LOV'框 DECLARE lv_id LOV; status BOOLEAN; BEGIN lv_id := Find_LOV('lov_name'); ---'lov_name' 由导航器定义 -- IF Id_Null(lv_id) THEN -- lv_id := Find_LOV('lov_name1'); ---'lov_name1' 由导航器定义 -- END IF; status := Show_LOV(lv_id,10,20); END; ---定义一个'EXCEPTION'例外 Declare err_1 exception; Begin If ... then Raise err-1; End if; Exception When err_1 then .... END; ---设置应用特性(光标类型) SET_APPLICATION_PROPERTY(CURSOR_STYLE, 'CROSSHAIR'|'BUSY'|'HELP'|'DEFAULT'|'INSERTION');
---比较单行中多个列的值获得最大('GREATEST'最小('LEAST') GREATEST|LEAST(列名,列名,...) ---按表达式或位置排序 ORDER BY '表达式'OR'位置' ASC|DESC ASC'升',DESC'降' 默认'ASC' *********************************************************************** *********************************************************************** ---游标的属性 (1) %ISOPEN 打开属性 布尔型 打开为TRUE 判断'光标'是否打开如未打开则打开'光标' IF NOT(CORSOR_NAME%ISOPEN) THEN OPEN CORSOR_NAME; END IF; FETCH CORSOR_NAME INTO ... (2) %NOTFOUND 布尔型 最近一次'FETCH'返回无结果 则为TRUE OPEN CORSOR_NAME; LOOP FETCH CORSOR_NAME INTO ... EXIT WHEN CORSOR_NAEM%NOTFOUND; END LOOP; (3) %FOUND 布尔型 最近一次'FETCH'返回无结果 则为FALSE OPEN CORSOR_NAME;
WHILE CORSOR_NAME%FOUND LOOP ...... FETCH CORSOR_NAME INTO ... END LOOP; CLOSE CORSOR_NAME; (4) %ROWCOUNT NUMVER型 为游标取出的行数 OPEN CORSOR_NAME; LOOP FETCH CORSOR_NAME INTO ... EXIT WHEN CORSOR_NAME%ROWCOUNT>5; ...... END LOOP; CLOSE CORSOR_NAME;
---循环语句 (1)基本循环 LOOP ..... EXIT WHILE; 如(EXIT WHEN X>100) END LOOP; (2)WHILE循环 WHILE 如( WHEN X>100) LOOP ..... END LOOP; (3)数值型FOR循环 'X'为计数器 FOR X IN (第减值) Y..Z LOOP ..... END LOOP; (4)游标FOR循环
---Exception(例外)在最近的'BEGIN'和'END'之间 Exception 语法1 当'没有数据找到'时 when no_data_found then 语法2 当'发生任何错误'时 when others then 语法3 当'发现多行'时 WHEN TOO_MANY_ROWS THEN 语法4 当'字符向数字转换失败'时 WHEN INVALID_NUMBER THEN 语法5 当'被零除'时 WHEN ZERO_DIVIDE THEN 语法6 当'向唯一索引中插入重复数据'时 WHEN DUP_VAL_ON_INDEX THEN 语法7 当'非法游标操作'时 WHEN INVALID_CURSOR THEN 语法8 当'数字的,数据转换,截字符串或强制性的错误'时 WHEN VALUE_ERROR THEN ************************************************************************** ************************************************************************** --常用TEXT_IO Delcare out_file text_io.file_type; Begin out_file:=text_io.fopen('prn','w'); text_io.new_line(out_file,' '); text_io.put_line(out_file,' ') text_io.fclose(out_file); End; ---文本输入输出 TEXT_IO TEXT_IO PACKAGE TEXT_IO FCLOSE TEXT_IO.FILE_TYPE TEXT_IO.FOPEN TEXT_IO.IS_OPEN TEXT_IO.GET_LINE TEXT_IO.NEW_LINE TEXT_IO.PUT TEXT_IO.PUTF TEXT_IO.PUT_LINE USING TEXT_IO CONSTRUCTS ---------------------------- Declare Out_file Text_io.file_type; L Varchar2(100); L1 Varchar2(100); L2 Varchar2(100); Begin Out_file :=text_io.fopen('c:\ll\login.txt','r'); If text_io.is_open(Out_file) then text_io.get_line(Out_file,L); text_io.get_line(Out_file,L1); text_io.get_line(Out_file,L2); Else Null; End if; End; ---清除全局变量 erase('global.var_name'); ---隐藏'WINDOW','VIEW','MENU' HIDE_WINDOW|VIEW|MENU(WINDOW|VIEW|MENU_name); --- 增加参数add_parameter Declare pl_id ParamList; BEGIN pl_id:=Get_Parameter_List('tempdata'); IF NOT Id_Null(pl_id) THEN Destroy_Parameter_List(pl_id); END IF; pl_id:=Create_Parameter_List('tempdata'); Add_Parameter(pl_id,'EMP_QUERY',DATA_PARAMETER,'EMP_RECS'); Run_Product(REPORTS,'empreport',SYNCHRONOUS,RUNTIME, FILESYSTEM,pl_id,NULL); END; --- DECLARE lArgs OLE2.LIST_TYPE; BEGIN word.hApp:=OLE2.CREATE_OBJ('Word.Basic'); lArgs:=OLE2.CREATE_ARGLIST; OLE2.ADD_ARG(lArgs,:ole.word_doc); OLE2.INVOKE(Word.hApp,'fileopen',lArgs); OLE2.DESTROY_ARGLIST(lArgs); END; ***********************删除重复记录************** Delete from emp e where e.rowid > (select min(f.rowid) from emp f 4 where f.empno=e.empno);