当前位置: 移动技术网 > IT编程>数据库>Oracle > ORACLE应用经验(1)

ORACLE应用经验(1)

2017年12月12日  | 移动技术网IT编程  | 我要评论

五一劳动节演讲稿,人大代表建活人墓,幸福时光陶然幼儿园

正在看的oracle教程是:oracle应用经验(1)。jan-1(january)   feb-2(february)   mar-3(march)
apr-4(april)     may-5(may)        jun-6(june)
jul-7(july)      aug-8(august)     sep-9(september)
oct-10(october)  nov-11(november)  dec-12(december)
********************************************************************
****************************常用设置********************************
---on-log 触发器编写示范
declare
  flag      varchar2(80):=null;
  cou       number:=1;
  n         number;
begin
  loop
       logon(username,password||'@'||connect,property_false....);
       flag:=get_application_property(datasource);
       exit when cou>8 or flag='oracle';
       cou:=cou+1;
  end loop;
  if flag<>'oracle' then
     set_alert_property('a_1',alert_message_text,
                          '登录失败,请返回重试');
     n:=show_alert('a_1');
     raise form_trigger_failure;   --中断 form
  end if;
end;
---对基表执行查询(只对基表)
   set_block_property('block_name',default_where,'where ......');
   go_block('block_name');
   execute_query;
***************************************************
  变量:
       局部变量;
       全局变量--------------1.:block.item
                 2.:parameter.v_name
                 3.:global.v_name

***************************************************
---同步发生显示
    synchronize;
---实施'trigger'触发
   execute_trigger(trigger_name);
---清除模块
clear_block(no_validate);  'no_validate'不生效
--建立警告栏并由警告栏选择
declare
   n     number;
begin
   set_alert_property('alert_name',alert_message_text,'message');
   n:=show_alert('alert_name');
   if n=alert_button1 then
      ...;   
   elsif n=alert_button2 then      
   ...;
   end if;
end;
---window设置
  --运行时最大化,最小化
  set_window_property(forms_mdi_window, window_state, maximize|minimize);
  --window标题
  set_window_property(forms_mdi_window, title,'text');
  --退出是否为真
  set_window_property(forms_mdi_window, remove_on_exit,property_false|true);
---设置系统提示信息等级
  :system.message_level:= '5|10|15|20';
---设置item属性
  --设置item属性enabled
  set_item_property('block_name.item_name',enabled,property_true|false);
  --设置item属性navigable
  set_item_property('block_name.item_name',navigable,property_true|false);
  --设置item属性visual_attribute
  set_item_property('block_name.item_name',visual_attribute,'vname');
        --'vname'由导航器中(visual_attributes)定义
  --设置item属性displayed
  set_item_property('block_name.item_name',displayed,true|false);
  --设置item属性position
  set_item_property('block_name.item_name',position,x,y);
  --设置item_size
  set_item_property('block_name.item_name',item_size,x,y);
  --设置item属性lable
  set_item_property('block_name.item_name',label,'message')
---设置list item示范
declare
&nbs

[1] [2] [3] [4] [5] 下一页

正在看的oracle教程是:oracle应用经验(1)。p; n  number;
begin
     clear_list('b1.fkfs');
     m:=populate_group('fkfs');
     populate_list('b1.fkfs','fkfs');
/*
   其中fkfs 为 record group ;
*/
end;
---增加'list item'
       add_list_element(list_name, list_index, list_label, list_value);
       add_list_element(list_id, list_index, list_label, list_value);
---删除'list item'项
      delete_list_element(list_name, list_index);
      delete_list_element(list_id, list_index);
   例:
      begin
         delete_list_element('years',1);
         add_list_element('years', 1, '1994', '1994');
      end;
---获得'list item'项的组成
     1.获得'list item'的总和   
         get_list_element_count(list_id);
         get_list_element_count(list_name);
     2.获得'list item'的标签
         get_list_element_label(list_id, list_name, list_index);
         get_list_element_label(list_name, list_index);

     3.获得'list item'的值
         get_list_element_value(list_id, list_index);
         get_list_element_value(list_name, list_index);  

---设置'时间'
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');

***********************************************************************   
**********************************函数*********************************
---把字符串的字符变成全大写(upper)全小写(lower)第一个字母大写(initcap)
     upper|lower|initcap(string)
---在文件的左('lpad')右('rpad')粘贴字符
      lpad|rpad(string,length,'set')  "length"为总字符长"set"为粘贴字符
---在文件的左('ltrim')右('rtrim')删除字符
      ltrim|rtrim(srting,'set')    "set"为待删除字符
---找出'字符集'在字符串中的位置
  instr('string','set',n,m)  从'string'中找出'set'从'n'位起第'm'个
---数的绝对值
   abs(value)
---'mod'模
    mod(value,除数) 返回'除数'除'value

上一页  [1] [2] [3] [4] [5] 下一页

正在看的oracle教程是:oracle应用经验(1)。'的余数常用判断'value'是否为整数   
---把'value'从'n'位四舍五入'round'  或从'n'位截断'trunc'
     round|trunc(value,n)
---返回'value'的符号
   sign(value)

---列表的最大值
    greatest(n1,n1...);
   列表的最小值
    least(n1,n1...);
---返回小于或等于数的最大整数
   floor(value)   floor(1.3)=1  floor(-1.3)=-2
---返回大于或等于数的最小整数
   ceil(value)    cell (1.3)=2  cell (-1.3)=-1

---取字符串长度
   substr(string,start,number)  number为string长度,start为string起点


---decode函数,多重(if,then,else)
   decode(value,if1,then1,if2,then2,.....,else)
---判断'value'是否为空(空值替换)
   nvl(ualue,'wkfhz')  'wkfhz'是为空返回值,不为空则为原值
---字段长度
    length(:block_name.item_id)
---返回字符串的第一(最左)个字符的ascii值
   ascii(string)
---多行'value'的   (作用于多'行')
    avg(value)平均值
    count(value)行数
    max(value)最大值
    min(value)最小值
    sum(value)和
---字符转换
    translate(string,'待转字符','转换字符');
    如  teanslate('aaabbb','ab','ba')  返回'bbbaaa'

---比较单行中多个列的值获得最大('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
         .....
    

上一页  [1] [2] [3] [4] [5] 下一页

正在看的oracle教程是:oracle应用经验(1)。;   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:lllogin.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 >
 

上一页  [1] [2] [3] [4] [5] 下一页

正在看的oracle教程是:oracle应用经验(1)。;  (select min(f.rowid) from emp f
    4 where f.empno=e.empno);

上一页  [1] [2] [3] [4] [5] 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网