Create or Replace procedurePr_test1 isV_case Number(3) := -;--Defining Variablesbegin--/ * Judgment Statementif 2>1 ThenDbms_output.put_line ('conditions established'); ElseDbms_output.put_line ('conditions are not tenable'); End if; if 2<1 ThenDbms_output.put_line ('conditions established'); Elsif4>3 ThenDbms_output.put_line ('condition not established 1'); End if; elsif4 > 2 ThenDbms_output.put_line ('condition not established 2'); elsif7>3 ThenDbms_output.put_line ('condition not established 3'); End if;-- */ CaseV_case--define V_case when 1 Then --when V_case is 1 o'clockDbms_output.put_line ('conditions established');--Output when - ThenDbms_output.put_line ('conditions established in the');Else--when no other matches are establishedDbms_output.put_line ('conditions are not set, conditions do not match! ');End Case; Case when 8>7 ThenDbms_output.put_line ('8>7 established'); when 9>8 ThenDbms_output.put_line ('9>8 established'); ElseDbms_output.put_line ('It 's not true .');End Case;<<Loop1>>--label, just to mark the exit is the loop LOOP1Loop v_case:=V_case- 1; Dbms_output.put_line ('value of v_case ='||v_case);--if (v_case =) Then--dbms_output.put_line (' exit cycle ');ExitLoop1 whenV_case= -;--End If; EndLoop; whileV_case> theLoop v_case:=V_case- 1; Dbms_output.put_line ('value of v_case ='||v_case); EndLoop; forInxinch 1.. -Loop--define a variable from 1 onwards toV_case:=V_case+Inx; Dbms_output.put_line ('value of v_case ='||v_case); EndLoop; forInxinch Reverse 1.. -Loop--Starting from big to small, starting from 20 to 1V_case:=V_case+Inx; Dbms_output.put_line ('value of v_case ='||v_case);EndLoop;EndPr_test1;
How to use the IF-judgment statement case statement using the Loop statement
Create or Replace procedurePr_test5 isbegin UpdateT_hq_ryxxSetBumbm= '103' whereBumbm is NULL;--where is the judging conditionifSql%RowCount > 0 ThenDbms_output.put_line ('updated the'||Sql%RowCount||'article Records');ElseDbms_output.put_line ('0 Records updated');End if;Commit;--Commit StatementEndPR_TEST5;
update operations for data
--Match the relevant content by entering the number, and output the relevant content after the match is successfulCreate or Replace procedurePr_test3 (V_BHinch varchar2, v_xxinchOutvarchar2) isbegin --define input Output XINGM variable to V_XM and Bianh as variable v_bh, enter number, match BUMBM to output name SelectXingm intoV_xx fromT_hq_ryxxwhereBianh=V_bh andBumbm=v_xx;ifSql%Found ThenDbms_output.put_line ('find the LE data!'); ElseDbms_output.put_line ('No data found'); End if; exception whenNo_data_found ThenDbms_output.put_line ('No data found'); Dbms_output.put_line ('Sqlcode:'||Sqlcode);--Error codeDbms_output.put_line ('SQLERRM:'||SQLERRM);--error Message whenOthers ThenDbms_output.put_line ('Find Error'); Dbms_output.put_line ('Sqlcode:'||Sqlcode);--Error codeDbms_output.put_line ('SQLERRM:'||SQLERRM);--error MessageEndPr_test3;Create or Replace procedurePr_test4 (V_BHinch varchar2) isV_XM T_HQ_RYXX.XINGM%type;beginV_XM:='102'; Pr_test3 (V_BH,V_XM); Dbms_output.put_line ("'||V_XM);EndPr_test4;
Oracle Sub-Program Data Association and exception handling
Oracle Base Code Usage