Welcome to plsql4all.blogspot.com SQL, MYSQL, ORACLE, TERADATA, MONGODB, MARIADB, GREENPLUM, DB2, POSTGRESQL.

Wednesday 6 August 2014

Anonymous Blocks in Oracle

Anonymous block:-
 
Anonymous block is an unnamed pl/sql program. Unlike other pl/sql named pre-compile object, Anonymous blocks does not get stored in a database. There are pre-compile object like store procedure, function package.

Syntax of the anonymous block is:-

DECLARE
- - - Declaration of variable, constant, cursor etc.
BEGIN
- - - executable part.
EXCEPTION
- - - we can catch any exception/ error here.
END;

Let’s try to create anonymous block with “Hello World” output:-

DECLARE
V_OUT VARCHAR2 (15);
BEGIN         
V_OUT:= ‘HELLO WORLD’;
DBMS_OUTPUT.PUT_LINE (V_OUT);
END;


Many new programmer complaints that they have written a pl/sql block correctly and they can see oracle saying ‘PL/SQL procedure successfully completed.’ but they are not able to see the output. While writing program you make habit of making server output on so you would be able to see the result.

Let’s have another example:-

ght b m l p�N �W style='font-family:"Arial","sans-serif"'> 

Sub query in oracle:-

In oracle, we can define query in WHERE clause of the select statement. It is called sub query because it is a query in another query.
The difference between inline view and sub query is, inline view is used in FROM clause and sub query is used in WHERE clause.                      
Another example is:-

"_ g 0 i x�Y ��W e="#_x0000_t75" style='width:501.75pt;height:431.25pt;visibility:visible;mso-wrap-style:square'>




la� � s N x�Y ��W an style='font-family:"Arial","sans-serif";mso-no-proof: yes'>

nd: wG . ; s x�Y ��W f:yes'>

Click OK.

Oracle sql developer:-

Install oracle sql developer or click on sql developer.exe file, it will show you initialization process:-
Click on
Once you click on  you will land onto the below screen. Type the name of the connection as you want, type the username, password, and then click on save password checkbox, type host name or ip_address of the machine, specify the port number and database SID or Service name, after putting all the information click on test  or you can directly click on connect button:-

Once you click on save button, the connection will be saved in the connection tab so you can use it again and again. You can see below the name CONNECTION_TO_SCOTT is present in the connection tab.


If you want to add more connection then just click on  and put all the required information. After you saved it, it will be listed in connection tab.




Read Also:-  Creating procedure

No comments:

Post a Comment

Please provide your feedback in the comments section above. Please don't forget to follow.