declarev_sal number :=6000;
beginwhile (v_sal <8000) loopv_sal := v_sal +1;dbms_output.put_line(v_sal);end loop;
end; 原文:http://www.cnblogs.com/nick-huang/p/4609060.html
查询语句pl/sql中用F5优化语句ORACLE的explain plan工具的作用只有一个,获取语句的执行计划1.语句本身并不执行,ORACLE根据优化器产生理论上的执行计划2.语句的分析结果存放在表PLAN TABLE中select * from TABLE where NOWTIME >=to_date(‘20160101‘,‘yyyy-mm-dd‘) and NOWTIME < to_date(‘20160102‘,‘yyyy-mm-dd‘)通过截图显示select语句是走索引的“INDEXRANGE SCAN”后边是索引名称,cost显示成本,走索引成本是...
记录exit和return的用法 exit用来跳出循环 loop IF V_KBP IS NULL THEN EXIT; END IF; end loop; return跳出存储过程 loop IF V_KBP IS NULL THEN return; END IF; end loop; 跳出loop 一次循环 oracle 11g已提供continue; oracle 10g及以下,使用goto来替代,例如 SQL> set serveroutput on; SQL> declare 2 begin 3 for i in 1..10 loop 4 if mod(i,2)=0 then 5 goto next; 6 ...
例子:create or replace procedure p_xl isv_count NUMBER(10);begin for rs in(select yhbh from dbyh) loop v_count := osm_pkg_arc_limited_configs.F_LIMITED_METERS_CREATE(‘rs.yhbh‘, 10001,---限量用水id sysdate, ...
declare forInt number(18); seqnum number(18);begin for forInt in 1..20000 loop select seq_forum.nextval into seqnum from dual; insert into frm_answer (ANSWERID, QUESTIONID, PARENTID, ANSWERTYPE, CREATEUSERID, CREATEDATE, UPDATEUSERID, UPDATEDATE, STATUS, STATUSDATE, DISCUSSNUM, SOURCE, UPDATETIME, PRAISEANSWERNUM, CANPRAISEANSWERNUM) values (seqnum, 144862, null, ‘reply‘, ...
declarev_display varchar2(10);
beginfor i in1 .. 100 loopfor j inreverse1 .. 10 loopdbms_output.put_line(i ||‘ - ‘|| j);end loop;end loop;end; 原文:http://www.cnblogs.com/nick-huang/p/4609056.html
--打印输出从1到10的正整数DECLARE v_i NUMBER(10) := 0;BEGIN LOOP v_i := v_i + 1; DBMS_OUTPUT.put_line(v_i); EXIT WHEN v_i=10; --或者v_i>9; END LOOP;END;--打印输出从1到10之间的偶数DECLARE v_i NUMBER(10) := 0;BEGIN LOOP v_i := v_i + 1; IF v_i MOD 2 = 0 THEN DBMS_OUTPUT.put_line(v_i); ...
declarev_sal number :=6000;
beginloopv_sal := v_sal +1;dbms_output.put_line(v_sal);exitwhen v_sal =8000;end loop;
end; 原文:http://www.cnblogs.com/nick-huang/p/4609064.html
declare --类型定义 cursor c_eventstate is Select CampaignId,phonenumber,PolicyNumber from mkt_eventstate a where synstate =0 and packagestate = 2 and errorcode = 6; --定义一个游标变量v_cinfo c_emp%ROWTYPE ,该类型为游标c_emp中的一行数据类型 c_row c_eventstate%rowtype;begin for c_row in c_eventstate loop begin dbms_output.put_line(c_row....
declare forInt number(18); seqnum number(18);begin for forInt in 1..20000 loop select seq_forum.nextval into seqnum from dual; insert into frm_answer (ANSWERID, QUESTIONID, PARENTID, ANSWERTYPE, CREATEUSERID, CREATEDATE, UPDATEUSERID, UPDATEDATE, STATUS, STATUSDATE, DISCUSSNUM, SOURCE, UPDATETIME, PRAISEANSWERNUM, CANPRAISEANSWERNUM) values (seqnum, 144862, null, ‘reply‘, ...
declare --类型定义 strsql string(500); v_ErrorCode NUMBER; -- Variable to hold the error message code v_ErrorText VARCHAR2(200); -- Variable to hold the error message text cursor c_eventstate is Select CampaignId,phonenumber,PolicyNumber from mkt_eventstate a where synstate =0 and packagestate = 2 and errorcode = 6; --定义一个游...
create table computers
(comNo number(4) constraint PK_comp primary key,compModel varchar2(64) constraint unique_comp unique,buyTime date,price number(12,2) constraint ch_price check(price>0 and price<=300000),owner varchar2(32));DECLAREi number := 0;
BEGINfor i in 1 .. 3000 loopinsert into computers(comNo, compModel, buyTime, price, owner)values(i, 8 + i, to_date( + sysdate, YYYY-MM), i, zhangsa...
: 分表,分区,建索引,全表扫描---开并行, 永远把它 放内存,压缩2.多表关联,任何时刻只能是2个表关联,得到的结果集再和其他表关联。3.嵌套循环:Oracle从较小结果集(驱动表/外部表)中读取一行,然后和较大结果集(被探查表/内部表)中的所有数据逐条进行比较(嵌套循环可以用于非等值连接),如果符合规则,就放入结果集中,然后取较小结果集的下一条数据继续进行循环,直到结束。嵌套循环只适合输出少量结果集或者是用于快速输出...
OR REPLACE TRIGGER trg_testbefore updateON cm_bogie_inandoutreport DECLARE//定义游标,查找表里边的每一列的值cursor c_bogie is select s_bureaunumno c_b_bureaunumno,s_serialnum c_b_serialnum,s_trainsetid c_b_trainsetid from cm_bogie_inandoutreport;BEGIN//循环赋值for v_record in c_bogie loopupdate test_mhb tset t.s_id=v_record.c_b_bureaunumnowhere t.s_sex = v_record.c_b_bureaunumno;dbms_output.put_l...
create or replace procedure sp_addProjectQj( ret out number, flowid in number --流程Id) ascursor c_design is select * from LC_VR_Detail where lc_crm_visitreport_Id = flowid and dd_status != 2; c_row c_design%rowtype; v_id number;begin for c_row in c_design loop pnextid(‘T_XMSJQJ‘,v_id); --项目涉及器件(id,项目名称,器件) values --design明细表(v_id,项目名称,器件名称) ...