Declare v_name emp.ename%TYPE: = ' SMITH ';--defined as a emp.ename type whose initialization value must exist in the ename v_job varchar (): = ' salesman '; V_sal number; REC EMP%Rowtype;begin Select* into rec from emp where ename =V_name; Dbms_output. Put_Line (' Name: ' | | rec.ename| | ' Salary: ' | | rec.sal| | ' Working hours: ' | |rec.hiredate); Select Ename to V_name from EMP where ename= ' WARD '; --dbms_output.put_line (' Name: ' | |v_name); ifV_name= ' WARD 'Then dbms_output.put_line (' Name: ' | | v_name| |rec.sal); Endif; ifV_name= ' JONES 'Then dbms_output.put_line (' Jones came to work today. '); ElseDbms_output.put_line (' Jones is playing really happy today. '); Endif; ifV_name = ' SCOTT 'Then dbms_output.put_line (' Scott came to work today. '); elsif V_name= ' Ten teams 'Then dbms_output.put_line (' Ward's coming to work today. '); ElseDbms_output.put_line (' No one is working today, the company is empty '); Endif; End;Application of--case practice v_appraisal: =the value of the case statement is the return value declare V_gradeChar(1): = ' A '; V_appraisal VARCHAR2 (20); Begin V_appraisal:= --The case does not have to be added, only at the end. CaseV_grade when' A ' then ' excellent ' when' B ' Then ' vary good ' when' C ' Then ' GOOG 'Else' No such grade 'end; Dbms_output. Put_Line (' Grade: ' | | v_grade| | ' Appraisal: ' | |v_appraisal); End CREATE TABLE ower (time date, NAME varchar (NUM Number (2));d eclare INT number (2): = 1; BEGIN LOOP INT:= INT +1; INSERT into Ower (time,name,num) VALUES (Sysdate,' HHH ', 5); Dbms_output.put_line (' Want to see you print ' | | To_char (int) | | ' Times); Dbms_output.put_line (int); Exit whenint= 8; --The loop content contains the value here end loop;end; Select*From ower; declareintNumber: = 1; begin while int<10 Loop--is equal to 10 when exiting Dbms_output.put_line (' Want to see you print ' | | To_char (int) | | ' Times); int:=int+1; End Loop; End CREATE TABLE Temp_table (num_col number (10)) ; DECLARE v_counter Number:= 10; BEGIN INSERT into temp_table (num_col) VALUES (v_counter); For V_counter in20.. LOOP--print out 20, to 25 lines of content. INSERT into Temp_table (num_col) VALUES (v_counter); END LOOP; INSERT into Temp_table (num_col) VALUES (v_counter); For V_counter in REVERSE20.. 25LOOP INSERT into temp_table (num_col) VALUES (v_counter); END LOOP; END;
PL/SQL block