declare
str varchar2(200);
nowTime Date;
a number(10);
b number(10);
start_value number;
end_value number;
begin
select sysdate into nowTime from dual;
str := ' 分隔符 ';
-- CHR(10)||CHR(13)||
DBMS_OUTPUT.PUT_LINE('------------当前时间--------------' || str /*|| CHR(10)*/
|| CHR(13) ||
to_char(nowTime, 'YYYY-MM-DD hh24:mi:ss'));
a := 100;
b := 200;
if a < b then
DBMS_OUTPUT.PUT_LINE('-------a<b-------');
end if;
-- while 循环
DBMS_OUTPUT.PUT_LINE('------------while 循环--------------');
start_value := 1;
end_value := 10;
while start_value <= end_value loop
DBMS_OUTPUT.PUT_LINE('now number:' || start_value);
start_value := start_value + 1;
end loop;
-- for循环
DBMS_OUTPUT.PUT_LINE('------------for循环--------------');
for tmp in 10 .. 20 loop
if mod(tmp, 2) = 0 then
dbms_output.put_line('now number1:' || tmp);
dbms_output.put_line('now number2:' || tmp);
end if;
end loop;
-- 游标for循环
DBMS_OUTPUT.PUT_LINE('------------游标for循环--------------');
declare
cursor userinfo_cursor is
select * from tm_employee a where a.asc_code = '4102019';
begin
for userinfo_rec in userinfo_cursor loop
dbms_output.put_line('userno is:' || userinfo_rec.employee_no|| ' userno is:' || userinfo_rec.employee_name);
end loop;
end;
DBMS_OUTPUT.PUT_LINE('------------当前时间--------------' || CHR(13) ||
to_char(nowTime, 'YYYY-MM-DD hh24:mi:ss'));
end;