-PL/SQL Foundation of Oracle Development Tool for MU lesson network note

Source: Internet
Author: User

Instance 1--IF statement

/* Web Oracle Database development must be pl/sql_2-3

Determine the number the user has entered from the keyboard

1. How to use the IF statement

2. Receive input from a keyboard (string) */

Set serveroutput on;

--Receive a keyboard input

--num: Address value, meaning: The value entered is saved on the address

Accept num Prompt ' Please enter a number ';

Declare--Define variable to save the number of keyboard input

Pnum Number: = #

Begin-Executing an IF statement for conditional judgment

If Pnum=0 then Dbms_output.put_line (' you enter the number is: 0 ');

elsif Pnum=1 then Dbms_output.put_line (' you enter the number is: 1 ');

elsif pnum=2 then Dbms_output.put_line (' you enter the number is: 2 ');

else Dbms_output.put_line (' You enter the number: other number ');

End If;

End

/

Instance 2--while statement

/*
The necessary pl/sql_2-4 of Oracle database development in MU-class network
While loop statement prints the number 1-10
*/
Set Serveroutput on
Declare
Pnum number: = 1;
Begin
While pnum<=10 loop
Dbms_output.put_line (Pnum);
Pnum: = Pnum +1;
End Loop;
End
/

Instance 3--loop statement

/* Web Oracle Database development must be pl/sql_2-4

Loop Loop Statement Prints the number 1-10 */

Set Serveroutput on

DECLARE pnum number: = 1;

Begin Loop Exit when pnum>10;

Dbms_output.put_line (Pnum);

Pnum: = Pnum +1;

End Loop;

End

/

Instance 3--for statement

/* Web Oracle Database development must be pl/sql_2-4

For Loop statement to print the number 1-10

For loop format:

For I in 1..9 loop

End Loop; */

Set Serveroutput on

DECLARE pnum number: = 1;

Begin for Pnum in 1..10 loop

Dbms_output.put_line (Pnum);

End Loop;

End

/

-PL/SQL Foundation of Oracle Development Tool for MU lesson network note

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.