PL SQL Cursors
Hrno records in the Hregright table that do not exist are populated with the Hrno in the House table (house only)
Declare cursorHouse_cur is SelectH.regno,h.hrno fromHouse HwhereH.hrno is not NULL Group byH.regno,h.hrno having Count(H.regno)=1; begin forHouseinchHouse_cur LoopUpdateHregright RSetR.hrno=House.hrnowhereR.regno=House.regno andR.hrno is NULL; EndLoop; End;
PL SQL variable
(1). Defines a variable-length string V_enamevarchar2(Ten); (2). Define a decimal, range-9999.99~9999.99V_sal Number(6,2); (3). Define a decimal and give an initial value of 5.4:=It's pl./the assignment number of SQL V_sal2 Number(6,2):=5.4; (4). Defines a date type of data v_hiredate date; (5). Defines a Boolean variable that cannot be null and has an initial value of False V_valid Boolean not NULL defaultFalse
Declarec_tax_rate Number(3,2):=0.03; --User nameV_enamevarchar2(5); V_sal Number(7,2); V_tax_sal Number(7,2); begin --Execution SelectEname,sal intoV_ename,v_sal fromEmpwhereEmpno=&No; --Calculate Income TaxV_tax_sal:=V_sal*c_tax_rate; --OutputDbms_output.put_line ('the name is:'||V_ename||'Salary:'||V_sal||'Tax:'||v_tax_sal); End;
DECLARE varchar2 (begin V_A1: = ' M000000000 ' ; Update set a.a1=where a.a0='0000000000' End;
Oracle Database PL SQL Cursor