DAY16-dong Soft training. Oracle. Anonymous block

Source: Internet
Author: User

2018-07-1216:41:19

1 Six, anonymous block2 1, define anonymous blocks:3 Declare 4Definition section;---optional Section5 begin6Executive section;---Required Section7 Exception8Exception handling Section;---optional Section9 End;Ten  One ---Output Hello world to console A begin -Dbms_output.put_line ('Hello World'); - End; the ---turn on the console output switch F5 - SetServeroutput on; -  -  + ---Define variables, assign values to variables, output variable values - ---; + Declare Av_id Number(3); at begin -V_ID:=1; - Dbms_output.put_line (v_id); - End;  -  - ---query data output from database tables to the console in Declare  -V_namevarchar2( -); toV_sal Number(7,2); +  begin -    SelectEname,sal intoV_name,v_sal fromEmpwhereEmpno=7788; theDbms_output.put_line (v_name||','||v_sal); * End; $ Panax Notoginseng &: Bring up input box to receive input data.  - ---Query The salary of the specified employee the SelectSal fromEmpwhereEmpno=&No; +  A ---Input String type the Select *  fromEmpwhere Upper(ename)=UPPER('&name'); +  -  $ Declare  $V_namevarchar2( -); -V_sal Number(7,2); - begin the    SelectEname,sal intoV_name,v_sal fromEmpwhereEmpno=&No; -Dbms_output.put_line (v_name||','||v_sal);Wuyi Exception the     whenNo_data_found Then -Dbms_output.put_line ('Sorry, the user you entered does not exist'); Wu End; -  About ---%type: Use data type of a column in a database as the data type of a variable $syntax; table name. Column Name%type -  - Declare  -V_name Emp.ename%type; AV_sal Emp.sal%type; + begin the    SelectEname,sal intoV_name,v_sal fromEmpwhereEmpno=&No; -Dbms_output.put_line (v_name||','||v_sal); $ Exception the     whenNo_data_found Then theDbms_output.put_line ('Sorry, the user you entered does not exist'); the End; the  -  in ---%rowtype: Row data, using one of the behavior data types of a table in a database the Declare  theV_emp EMP%RowType; About begin the   Select *  intoV_emp fromEmpwhereEmpno=&No; theDbms_output.put_line (v_emp.empno||','||v_emp.ename); the End; +    -    the   Bayi   

DAY16-dong Soft training. Oracle. Anonymous block

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.