RDBMS - PL SQL - Topic 5 - MSBTE QUESTIONS AND ANSWERS

Size: px
Start display at page:

Download "RDBMS - PL SQL - Topic 5 - MSBTE QUESTIONS AND ANSWERS"

Transcription

1 RDBMS - PL SQL - Topic 5 - MSBTE QUESTIONS AND ANSWERS SUMMER 2017 Q. Describe Exception handling. Explain with example. 4 Marks Exception Handling: Exception is nothing but an error. Exception can be raise when DBMS encounters errors or it can be raised explicitly. When the system throws a warning or has an error it can lead to an exception. Such exception needs to be handled and can be defined internally or user defined. Exception handling is nothing but a code block in memory that will attempt to resolve current error condition. Syntax: DECLARE ; Declaration section executable statement; EXCEPTION WHEN ex_name1 THEN :Error handling statements/user defined action to be carried out; DECLARE s_rollnostudents.rollno%type := 10; s_namestudents.name%type; s_addressstudents.address%type; SELECT rollno, name, address FROM students WHERE rollno = s_rollno; dbms_output.put_line(s_rollno ' ' s_name ' ' s_address); EXCEPTION WHEN no_data_found THEN dbms_output.put_line('no such student!'); WHEN others THEN dbms_output.put_line('error!'); Q. Write a PL/SQL program to print numbers from 50 to 60 using for loop. 4 Marks (Note: Any other Logic also considered) DECLARE x number :=50;

2 LOOP dbms_output.put_line(x); x := x +1; IF x >60 THEN exit; END IF; END LOOP; Q. Explain implicit and explicit cursor. 4 Marks Implicit Cursor: Implicit cursors are automatically created by Oracle whenever an SQL statement is executed, when there is no explicit cursor for the statement. Whenever a DML statement (INSERT, UPDATE and DELETE) is issued, an implicit cursor is associated with this statement. For INSERT operations, the cursor holds the data that needs to be inserted. For UPDATE and DELETE operations, the cursor identifies the rows that would be affected. In PL/SQL, implicit cursor as has the attributes like %FOUND, %ISOPEN, %NOTFOUND, and %ROWCOUNT. Example of implicit cursor: Begin Update emp set salary= salary +500 where empno =&empno; If SQL%FOUND then Dbms_out.put_line( Emp table modified ); Else Dbms_out.put_line( Emp table modified ); End if; End; Explicit cursor: Explicit cursors are programmer defined cursors for gaining more control over the context area. An explicit cursor should be defined in the declaration section of the PL/SQL Block. It is created on a SELECT Statement which returns more than one row. Working with an explicit cursor involves four steps: Declaring the cursor for initializing in the memory Cursor cursor_name IS select_statement; Opening the cursor for allocating memory Open cursorname; Fetching the cursor for retrieving data Fetch cursorname INTO variable1,variable2

3 Closing the cursor to release allocated memory Close cursorname; Example of explicit cursor: Declare Cursor c1 is select empno, salary from emp Where deptno=10; ecode emp.empno%type; sal emp.salary%type; Begin Open c1; If c1%isopen then Loop Fetch c1 into ecode,sal; If c1% NOTFOUND then Exit; End if; Update emp set salary = salary+500; End Loop; Close c1; Else dbms_out.put_line( unable to open ); End if; End; Q. Differentiate between view and index. 4 Marks

4 Q. Explain the concept of trigger. 4 Marks A trigger is a PL/SQL block structure which is fired when DML statements like Insert, Delete, Update is executed on a database table. A trigger is triggered automatically when an associated DML statement is executed. Syntax for Creating a Trigger: CREATE OR REPLACE TRIGGER trigger_name [BEFORE/AFTER] [INSERT/UPDATE/DELETE] ON Table_name [FOR EACH STATEMENT/FOR EACH ROW] [WHEN CONDITION] PL/SQL block Example: CREATE OR REPLACE TRIGGER trg1 BEFORE INSERT ON EMP FOR EACH ROW IF :new.sal<=0 THEN Rasie_application_error( Salary should be greater than 0 ); END IF; Q. Define following term with example. 4 Marks (i) Procedure (ii) Function (i) Procedure: Definition: A procedure is named PL/SQL block which perform one or more specifies task. Example The following example creates a simple procedure that displays the string 'Hello World!' on the screen when executed. CREATE OR REPLACE PROCEDURE greetings AS dbms_output.put_line('hello World!'); (ii) Function: Definition: Function is a logically grouped set of SQL and Pl/SQL statements that perform a specific task.

5 Example: This function returns the total number of CUSTOMERS in the customers table. CREATE OR REPLACE FUNCTION totalcustomers RETURN number IS total number(2):=0; SELECT count(*)into total FROM customers; RETURN total; / Q. Explain GOTO statement with example. 4 Marks The GOTO statement transfers control to a labelled block or statement. It is an unconditional branching statement. It does not use any condition for transferring the control to other part of code. It transfers the control to the part of code which contains same label mentioned in goto statement. Syntax : GOTO label;.... << label >> statement; Example : DECLARE p VARCHAR2(30); n PLS_INTEGER := 37; FOR j in 2..ROUND(SQRT(n)) LOOP IF n MOD j = 0 THEN p := ' is not a prime number'; GOTO print_now; END IF; END LOOP; p := ' is a prime number'; <<print_now>> DBMS_OUTPUT.PUT_LINE(TO_CHAR(n) p);

6 Q. Explain PL/SQL block structure. 4 Marks Block structure of PL/SQL: Declare Declaration of memory variables (Mandatory) SQL executable statements Exception Handling errors (Mandatory) A block begins with a declarative section where variables are declared. This is followed by a section containing the procedural statements surrounded by and END keywords. Each block must have Begin and End statements and may optionally include an exception section to handle errors. End section marks the end of PLSQL block. Q. Explain locking strategy in detail. 4 Marks Implicit Locking: Implicit locks are generally placed by the DBMS automatically. Explicit Locking: The technique of lock taken on a table or its resources by a user is called Explicit Locking. Users can lock tables they own or any tables on which they have been granted table privileges (such as select, insert, update, delete). Explicit locking done by two ways as 1) The Select...For Update statement It is used for acquiring exclusive row level locks in anticipation of performing updates on records. 2) Using lock table statement: To manually override Oracle s default locking strategy by creating a data lock in a specific mode. Syntax: LOCK TABLE <TableName> [, <TableName>] IN { ROW SHARE ROW EXCLUSIVE SHARE UPDATE SHARE SHARE ROW EXCLUSIVE EXCLUSIVE} [NOWAIT]

7 SUMMER 2016 Q. Give any four advantages of using PL/SQL. 4 Marks (Any four advantages - 1 mark each) Advantages of PL/SQL: 1. PL/SQL is portable and high transaction processing language. 2. PL/SQL is in fact procedural language but it also supports object oriented programming. 3. PL/SQL is that development tool which not only supports SQL data manipulations but also provides facilities of conditional checking and looping. 4. It allows user to write as well as access the functions and procedures from outside the programs. 5. It has got built in libraries of packages. 6. PL/SQL is highly productive as it works with the oracle forms to develop the application software i.e. it works with the front ends to develop the complete commercial applications. 7. The performance of PL/SQL is better, as in single line query entire block of statements can be processed. 8. Some special features of PL/SQL include the different data types that are capable of handling different types of data required in real life applications. 9. The most important features like triggers, cursors, locks etc have made PL/SQL a very versatile language. 10. Security can be ensured with the help of PL/SQL, while developing a commercial database system. 11. PL/SQL is a user friendly language and very simple to use. Q. What are Predefined exceptions and User defined exceptions? 4 Marks (Predefined exception - 2 marks; User Defined exception - 2 marks) 1) Predefined Exception/system defined exception/named exception: Are always automatically raised whenever related error occurs. The most common errors that can occurs during the execution of PL/SQL. Not declared explicitly. I.e. cursor already open, invalid cursor, no data found, zero divide and too many rows etc. Programs are handled by system defined Exceptions. 2) User defined exception: It must be declare by the user in the declaration part of the block where the exception is used. It is raised explicitly in sequence of statements using: Raise_application_error (error_no, error_name); Q. What is lock? Explain types of locks. 4 Marks (Lock - 2 marks; Description - 1 mark each type) The lock table statement allows explicitly acquire a shared or exclusive table lock on the specified table. The table lock lasts until the end of the current transaction. To lock a table, one must either be

8 the database owner or the table owner. Syntax: LOCK TABLE TABLE-NAME IN {SHARED EXCLUSIVE} MODE; Types of Locks: Shared Lock Exclusive Lock. 1. Shared. If a transaction Ti has obtained a shared-mode lock (denoted by S) on item Q, then Ti can read, but cannot write, Q. Shared Lock is provided to the readers of the data. These locks enable all the users to read the concurrent data at the same time, but they are not allowed to change/ write the data or obtain exclusive lock on the object. It could be set for table or table row. Lock is released or unlocked at the end of transaction. 2. Exclusive. If a transaction Ti has obtained an exclusive-mode lock (denoted by X) on item Q, then Ti can both read and write Q. Exclusive Lock is provided to the writers of the data. When this lock is set on a object or transaction, it means that only writer, who has set the lock can change the data, and if other users cannot access the locked object. Lock is released at the end of change in transaction. Q. Write a PL/SQL program to find the square of a number given by user usingwhile.loop.(accept the number from user dynamically) 4 Marks (Correct Program - 4 marks) [**NOTE: any relevant program logic shall be considered**] SET SERVEROUTPUT ON; DECLARE n number:= &n; sqr number:= 0; n_cntr number:=0; DBMS_OUTPUT.PUT_LINE(n); WHILE n_cntr < n LOOP sqr:= sqr + n; n_cntr := n_cntr + 1; END LOOP; DBMS_OUTPUT.PUT_LINE('Square of ' n ' is ' sqr); Q. Write a PL/SQL program using while loop to display n even numbers. 4 Marks (Correct logic - 2 marks; correct syntax - 2 marks) [** Note: Any relevant logic can be considered**] SET SERVEROUTPUT ON; DECLARE n number:= &n; i number:= 0; cnt number:=0; WHILE (cnt< n) LOOP if( mod (i,2)=0) then

9 Dbms_output.put_line(i); cnt:=cnt+1; End if; i:=i+1; END LOOP; Q. List out any four statements of PL/SQL. 4 Marks (Any four statement list/syntax - 1 mark each) 1. Declare 2. Begin 3. End 4. Exception 5. dbms_output.put_line(); 6. If condition then Statements Else Statements End if; 7. LOOP <loop_body> END LOOP; 8. LOOP <loop_body> EXIT WHEN (condition); END LOOP; 9. WHILE <condition> LOOP <loop body> END LOOP; 10. GOTO <<label_name>>; 11. FOR COUNTER IN [reverse] LOWER_BOUND..UPPER_BOUND LOOP <loop body> END LOOP; 12. CASE [expression] WHEN condition_1 THEN result_1 WHEN condition_2 THEN result_2.. WHEN condition_n THEN result_n ELSE RESULT END CASE;

10 Q. What is database trigger? Compare database triggers and procedures and explain the use of database trigger. (Definition - 1 mark; Comparison - 2 marks; Uses - 1 mark) [**Note: Any relevant comparison can be considered**] Database Trigger: Database trigger are event-condition-action model which are fixed on certain event. Trigger represents action to be taken if some event happens. In case of DBMS, triggers are automatically fired when tables are modified with insert, update and delete etc. Use of database trigger: Triggers can be used to prevent invalid transaction and to apply complex security authorization. It can be used to implement complicated integrity constraints. It can be used to maintain duplicate table and to check the data modifications. Comparison: Database Trigger Procedures 1. Triggers are fired when particular SQL 1. Procedures are executed when they are commands (DML) are executed called 2. Triggers have events and related actions 2. Procedure do not have events and related actions 3. Triggers are called implicitly 3. Procedure are called explicitly Q. Explain PL/SQL block structure. 4 Marks (Correct Explanation - 4 marks) A PL/SQL Block consists of four sections: 1. The Declaration section : Declaration of memory variables used later in begin section. 2. The Begin..End section : SQL executable statements for manipulating table data should be in...end block. 3. The Exception section : SQL and/or PL-SQL code to handle errors that may crop up during execution of the above code block.

11 Q. List types of cursor and explain each with example. 4 Marks (Description - 1 mark; example - 1 mark for each type; 1 mark shall be awarded if only list is given) [**Note: any other examples showing use of implicit and explicit cursor can be considered**] Types of Cursor Implicit cursor Explicit cursor Implicit cursor: If database engine opens a cursor for internal processing, it is called as implicit cursor. Example of implicit cursor: Declare Begin Update emp set salary= salary +500 where empno =&empno; If SQL%FOUND then Dbms_out.put_line( Emp table modified ); Else Dbms_out.put_line( Emp table modified ); End if; End; Explicit cursor: A user can open a cursor for processing data as required. Such user defined cursors are known as explicit cursors. Example of explicit cursor: Declare Cursor c1 is select empno, salary from emp Where deptno=10; Ecode emp.empno%type; Sal emp.salary%type; Begin Open c1; If c1%isopen then Loop Fetch c1 into ecode,sal; If c1% NOTFOUND then Exit; End if; Update emp set salary = salary+500; End Loop; Close c1; Else Dbms_out.put_line( unable to open ); End if; End;

12 WINTER 2016 Q. Define cursor? List the two types of cursor. 2 Marks Cursor: A cursor is a temporary work area created in the system memory when a SQL statement is executed. Types of Cursor: 1.Implicit Cursor 2.Explicit Cursor Q. Explain the exception handling with its two type. 4 Marks Exception Handling: Exception is nothing but an error. Exception can be raise when DBMS encounters errors or it can be raised explicitly. When the system throws a warning or has an error it can lead to an exception. Such exception needs to be handled and can be defined internally or user defined. Exception handling is nothing but a code block in memory that will attempt to resolve current error condition. Syntax: DECLARE ; Declaration section executable statement; EXCEPTION WHEN ex_name1 THEN ; Error handling statements/user defined action to be carried out; Types of Exception: 1) Predefined Exception/system defined exception/named exception: Are always automatically raised whenever related error occurs. The most common errors that can occur during the execution of PL/SQL. Not declared explicitly i.e. cursor already open, invalid cursor, no data found, zero divide and too many rows etc. Programs are handled by system defined Exceptions. 2) User defined exception: It must be declare by the user in the declaration part of the block where the exception is used. It is raised explicitly in sequence of statements using: Raise_application_error(Exception_Number,Error_Message); Q. Explain Database security with its requirements. 4 Marks Database Security: Database security refers to the collective measures used to protect and secure a database or database management software from illegal use and malicious

13 threats and attacks. Database security covers and enforces security on all aspects and components of databases like Data stored in database, Database server, DBMS. Data Security Requirements: 1. Authentication: System verifies a user's identity. 2. Authorization: Which database operations that user may perform (like read, update, drop etc.) and which data objects that user may access. 3. Secure Storage of Sensitive Data: Once confidential data has been entered, its integrity and privacy must be protected on the databases and servers wherein it resides. 4. Integrity: Data integrate means that data is protected from deletion and corruption 5. Availability: A secure system makes data available to authorized users, without delay. 6. Confidentiality: A secure system ensures the confidentiality of data. This means that it allows individuals to see only the data they are supposed to see. Q. Explain PL/SQL Block structure. 4 Marks Block structure of PL/SQL: Declare Declaration of memory variables (Mandatory) SQL executable statements Exception Handling errors (Mandatory) A PL/SQL Block consists of following sections: The Declaration section: Declaration of memory variables used later in begin section. The Begin section: SQL executable statements for manipulating table data should be in..end block. The Exception section: SQL and/or PL-SQL code to handle errors that may crop up during execution of the above code block. End : Mark the end of PL-SQL block Q. What is database Trigger? How to create Trigger? 4 Marks A trigger is a PL/SQL block structure which is fired when DML statements like Insert, Delete, Update is executed on a database table. A trigger is triggered automatically when an associated DML statement is executed. Syntax for Creating a Trigger CREATE OR REPLACE TRIGGER trigger_name [BEFORE/AFTER]

14 [INSERT/UPDATE/DELETE] ON Table_name [FOR EACH STATEMENT/FOR EACH ROW] [WHEN CONDITION] PL/SQL block Example: CREATE OR REPLACE TRIGGER trg1 BEFORE INSERT ON EMP FOR EACH ROW IF :new.sal<=0 THEN Rasie_application_error( Salary should be greater than 0 ); END IF; Q. Write a PL/SQL program to print even or odd number from given range (Accept number range from user). 4 Marks {**NOTE: any relevant program logic shall be considered**} DECLARE A NUMBER :=&A; B NUMBER :=&B; C NUMBER :=&C; IF(C=1) THEN FOR I IN A..B LOOP IF(MOD(I,2)=0) THEN DBMS_OUTPUT.PUT_LINE(I); END IF; END LOOP; ELSE FOR I IN A..B LOOP IF(MOD(I,2)=1) THEN DBMS_OUTPUT.PUT_LINE(I); END IF; END LOOP; END IF; OR

15 -- PL/SQL code to display even numbers DECLARE A NUMBER :=&A; B NUMBER :=&B; FOR I IN A..B LOOP IF(MOD(I,2)=0) THEN DBMS_OUTPUT.PUT_LINE(I); END IF; END LOOP; -- PL/SQL code to display odd numbers DECLARE A NUMBER :=&A; B NUMBER :=&B; FOR I IN A..B LOOP IF(MOD(I,2)=1) THEN DBMS_OUTPUT.PUT_LINE(I); END IF; END LOOP; Q. Explain function in PL/SQL with suitable example 4 Marks A function (also called a user function or user-defined function) is a set of PL/SQL statements that is called by name. A function returns a value to the environment in which it is called. Syntax: CREATE [OR REPLACE] FUNCTION function_name [parameters] RETURN return_datatype; IS Declaration_section Execution_section Return return_variable; EXCEPTION exception section Return return_variable;

16 Example : CREATE OR REPLACE FUNCTION employer_details_func RETURN VARCHAR(20); IS ename VARCHAR(20); SELECT fname INTO ename FROM emp WHERE empid = '100'; RETURN ename; Q. Explain two locking strategies. 4 Marks Implicit Locking: Oracle engine automatically locks table data while executing SQL statements Explicit Locking: The technique of lock taken on a table or its resources by a user is called Explicit Locking. Users can lock tables they own or any tables on which they have been granted table privileges (such as select, insert, update, delete). Explicit locking done by two ways as 1) The Select...For Update statement It is used for acquiring exclusive row level locks in anticipation of performing updates on records. 2) Using lock table statement: To manually override Oracle s default locking strategy by creating a data lock in a specific mode. Syntax: LOCK TABLE <TableName> [, <TableName>] IN { ROW SHARE ROW EXCLUSIVE SHARE UPDATE SHARE SHARE ROW EXCLUSIVE EXCLUSIVE} [NOWAIT] Q. Explain loop control structure used in PL/SQL. 4 Marks LOOP: PL/SQL LOOP statement is an iterative control statement that allows to execute a sequence of statements repeatedly like WHILE and FOR loop. Syntax: LOOP

17 sequence_of_statements; END LOOP; Example: i number :=1; Loop dbms_out.put_line( Good Morning ); i :=i+1; Exit when i=10 End Loop WHILE: If it is not known in advance how many times a sequence of statements needs to execute. In such cases, one should use PL/SQL WHILE LOOP statement. Syntax: WHILE condition LOOP sequence_of_statements; END LOOP; Example: i number := 1; while (i<=10) Loop dbms_output.put_line(i); i :=i+1; End Loop; 3) FOR: FOR loop is an iterative statement that execute a sequence of statements a fixed number of times. Syntax: FOR loop_counter IN [REVERSE] lower_bound.. higher_bound LOOP sequence_of_statements; END LOOP; Example: For i in loop dbms_output.put_line(i); end loop;

18 SUMMER-2015 Q. How to create trigger? State any two advantages of trigger. (Trigger Syntax or example -2Marks, Any 2 advantages- 2 Marks) [Note: Any relevant example can be considered] The Syntax for creating a trigger is: CREATE [OR REPLACE ] TRIGGER trigger_name {BEFORE AFTER INSTEAD OF } {INSERT [OR] UPDATE [OR] DELETE} ON table_name [FOR EACH ROW/For Each statement] WHEN (condition) --- sql statements (OR) Example CREATE or REPLACE TRIGGER After_Update_Row_product AFTER insert On product FOR EACH ROW INSERT INTO product_check Values('After update, Row level',sysdate); Advantages of triggers: 1. Triggers provide an alternative way to check the integrity of data. 2. Can catch errors in business logic in the database layer. 3. SQL triggers provide an alternative way to run scheduled tasks. 4. Triggers are very useful to audit the changes of data in tables. Q. Write a PL/SQL program which handles divide by zero exception. (Correct Program - 4 Marks) DECLARE A number:=20; B number:=0; C number; dbms_output.put_line( First Num : A); dbms_output.put_line( Second Num : B); C:= A / B; --Raise Exception

19 dbms_output.put_line( Result C); -- Result will not be displayed EXCEPTION WHEN ZERO_DIVIDE THEN dbms_output.put_line( Trying to Divide by zero :: Error ); / Q. Draw the block structure of PL/SQL. List advantages of PL/SQL. (Block structure 2Marks, Any 4 advantages 2 Marks) Advantages of PL/SQL : 1. PL/SQL is that development tool which not only supports SQL data manipulations but also provides facilities of conditional checking and looping. 2. PL/SQL sends an entire block of SQL statement to the ORACLE engine all in one go. 3. PL/SQL also permits dealing with errors as required, and facilitates displaying userfriendly messages, when errors are encountered. 4. PL/SQL allows declaration and use of variables in blocks of code. These variables can be used to store intermediate results of a query for later processing, or calculate values and insert them into an ORACLE table later. PL/SQL variables can be used anywhere, either in SQL statements or in PL/SQL blocks. 5. Applications written in PL/SQL are portable to any computer hardware and operating system, where Oracle is operational. Q. Explain Lock Compatibility Table. What is Two-phase locking protocol? (Lock compatibility table 2 Marks, two phase locking protocol 2Marks) The two commonly used locks are 1) shared and 2) Exclusive 1) Shared lock : It can lock the transaction only for reading. 2) Exclusive Lock : It can lock the transaction for reading as well as writing. The compatibility table for these two locks can be given as: Shared Exclusive Shared Compatible Not compatible Exclusive Not Compatible Not Compatible Two phase locking protocol: This protocol is for ensuring serializability.

20 It requires the locking and unlocking of the transaction to be done in two phases. 1) Growing phase: In this phase, a transaction may obtain locks, but may not release locks. 2) Shrinking phase: In this phase, a transaction may release locks, but may not acquire any new locks. Q. What are the various datatypes of PL/SQL? (Any 4 data types -1Mark each) The default data types that can be declared in Pl/SQL are : 1) number (size) for storing numeric data eg. a number(2); 2) char/ varchar(size) for character data eg: mynamevarchar(20); 3) date for date and time data eg : dob date; 4) Boolean for storing true, false or null eg: status Boolean; 5) %Type - to declare a variable or constant to have a same data type as that of a previously defined variable or a column in a table. e.g. enoemp.empno%type Q. Write a PL/SQL program to create any snapshot. (Creation of snapshot 2 Marks, PL/SQL code 2Marks) [Note: Any other relevant example of PL/SQL code can be considered] 1) To create a snapshot : Create snapshot emp_snap refresh with rowid as select * from emp; 2) To use snapshot from PL/SQL : declare cnt as number(2):=0; begin Select count(*) into cnt from emp_snap; dbms_output.put_line ( Number of rows from snapshot : cnt); end; / Q. Write PL/SQL procedure to calculate factorial of a give number. (Correct program 4Marks) [Note: Any other relevant logic shall be considered]

21 SQL> create or replace procedure Factorial(n in number) is v number :=1; begin for i in 1..n loop v :=v * i; end loop; dbms_output.put_line(v); end; Procedure created SQL> Begin Factorial(5); End; Q. Differentiate between function and procedure. (Any four point 1Mark each) Q. What are the various control structure statements used in PL/SQL? (Any four control structures - 1 Mark each) Conditional Control: 1. If then Else End If statement: The If then Else End if is used to check the conditions. If the condition in if part is true then the statement in the if block gets execute. If the condition in if part is false then the statement given in the else part gets execute. To give more number of conditions we can use if the elseif which provides more

22 number of conditions. The general syntax of if is as follows: If condition then Statements Else Statements End if; 2. Nested If: In this, any number of ELSIF clauses can be used with one IF statement. Either set of actions of the result of the first IF statement of ELSE statement can contain further IF statements before specific actions are performed. Each nested IF statement must terminate with a corresponding END IF. Syntax: If condition then Statements If condition then Statements Else If condition then Statements Else condition then Statements End if; End if; End if; 3. Case Evaluates a list of conditions and returns one of multiple possible result expressions. CASE can be used in any statement or clause that allows a valid expression. For example, you can use CASE in statements such as SELECT, UPDATE, DELETE and SET, and in clauses such as select_list, IN, WHERE, ORDER BY, and HAVING. Synatx: CASE [ expression ] WHEN condition_1 THEN result_1 WHEN condition_2 THEN result_2... WHEN condition_n THEN result_n

23 ELSE result END Iterative Control: 1. Simple Loop 2. While Loop 3. For Loop 1. Simple Loop LOOP statements let you execute a sequence of statement multiple times. Place the keyword LOOP before the first statement in the sequence and the keyword END LOOP after the last statement in the sequence. Syntax: Endless loop LOOP <loop_body> END LOOP; Conditional loop LOOP <loop_body> EXIT WHEN (Condition); END LOOP; The EXIT WHEN statement lets you complete a loop if further processing is impossible or undesirable. When the EXIT statement encountered, the condition in the WHEN clause is evaluated. If the condition is true, the loop completes and control passes to the next statement. 2. While Loop The WHILE LOOP statement associates a condition with a sequence of statements. Before each iteration of loop, the condition is evaluated. If the condition is true, the sequence of statement is executed, then control resumes at the top of the loop. If the condition is false or null, the loop is bypassed and control passes to the next statement. Syntax: WHILE <Condition> LOOP <loop body> END LOOP; 3. For Loop :

24 The FOR LOOP statement specifies a range of integers, then execute a sequence of statements once for each integer in the range. To reverse the range, REVERSE keyword is used. The syntax is : FOR i IN 1..N LOOP <loop_body> END LOOP; 4. Sequential Control: Label can be used to give a label or name to the piece of code. And once the name is given to it, user can call that piece of code with that label whenever and wherever required in the program. Syntax for label is as follows: <<label_name>> Statements; The Goto statement is used to transfer the control or to change the sequence of the instructions. Syntax for goto statement is as follows: Goto<<label_name>> WINTER 2015 Q. What statement is used in PL/SQL to display the output? (Correct statement 2 Marks) dbms_output.put_line( var/msg); OR set serveroutput on; dbms_output.put_line( var/msg); Q. What is Cursor? (Cursor Description 2 Marks) Oracle creates a memory area, known as context area, for processing an SQL statement, which contains all information needed for processing the statement, for example, number of rows processed, etc. Q. What do you mean by database security? (Database Security 2 Marks; any relevant description shall be considered) Database security refers to the collective measures used to protect and secure a database or database management software from illegitimate use and malicious threats and attacks.

25 Database security covers and enforces security on all aspects and components of databases like Data stored in database, Database server, DBMS. Q. Explain implicit and explicit locking strategy. (Implicit Locking Strategy - 1 Mark; Explicit Locking Strategy - 3 Marks) Implicit Locking: Implicit locks are generally placed by the DBMS automatically. Explicit Locking: The technique of lock taken on a table or its resources by a user is called Explicit Locking. Users can lock tables they own or any tables on which they have been granted table privileges (such as select, insert, update, delete). Explicit locking done by two ways as 1) The Select...For Update statement It is used for acquiring exclusive row level locks in anticipation of performing updates on records. 2) Using lock table statement: To manually override Oracle s default locking strategy by creating a data lock in a specific mode. Syntax: LOCK TABLE <TableName> [, <TableName>] IN { ROW SHARE ROW EXCLUSIVE SHARE UPDATE SHARE SHARE ROW EXCLUSIVE EXCLUSIVE} [NOWAIT] Q. Write PL/SQL program to print even or odd numbers from given range. (Accept number from user.) (Correct logic - 2 Marks, correct syntax 2 Marks) [** Note: Any relevant logic can be considered] Logic 1 : Declare n1 number := &n1;

26 n2 number :=&n2; i number ; begin dbms_output.put_line( Even numbers are : ); for i in n1..n2 loop if mod(i,2)=0 then dbms_output.put_line(i); end if; end loop; dbms_output.put_line( Odd numbers are : ); for i in n1..n2 loop if mod(i,2)!=0 then dbms_output.put_line(i); end if; end loop; end; Logic 2 : Declare n1 number := &n1; n2 number :=&n2; i number ; begin for i in n1..n2 loop if mod(i,2)=0 then dbms_output.put_line( Even : i); else dbms_output.put_line( Odd : i); end if; end loop; end; Q. Explain conditional control structure in PL/SQL. (Explanation of each structure - 1 Mark, syntax of each - 1 Mark) Conditional control statements in PL/SQL: 1. If then Else End if statement:

27 PL/SQL provide if statement to check conditions in program. If the given condition is true, then the part after If statement gets executed, otherwise, part below else gets executed. Syntax: If <condition> then <action> Else <action> End if; 2. Case Evaluates a list of conditions and returns one of multiple possible result expressions. CASE can be used in any statement or clause that allows a valid expression Syntax: CASE [ expression ] WHEN condition_1 THEN result_1 WHEN condition_2 THEN result_2... WHEN condition_n THEN result_n ELSE result END CASE; Q. What is lock based protocol? Explain share and exclusive mode protocols in lock based protocol. (Lock based protocol explanation 2 Marks, shared and exclusive lock explanation 2 Marks) Two phase locking protocol: This protocol is for ensuring serializability. It requires the locking and unlocking of the transaction to be done in two phases. 1) Growing phase: In this phase, a transaction may obtain locks, but may not release locks. 2) Shrinking phase: In this phase, a transaction may release locks, but may not acquire any new locks. The two commonly used locks are 1) shared and 2) Exclusive 1) Shared lock: It can lock the transaction only for reading. 2) Exclusive Lock: It can lock the transaction for reading as well as writing. 1) The compatibility table for these two locks can be given as:

28 Q. What are adv.of PL/SQL? (Any four advantages 1 Mark each) Advantages of PL/SQL: 1. PL/SQL is that development tool which not only supports SQL data manipulations but also provides facilities of conditional checking and looping. 2. PL/SQL sends an entire block of SQL statement to the ORACLE engine all in one go. 3. PL/SQL also permits dealing with errors as required, and facilitates displaying user friendly messages, when errors are encountered. 4. PL/SQL allows declaration and use of variables in blocks of code. These variables can be used to store intermediate results of a query for later processing, or calculate values and insert them into an ORACLE table later. PL/SQL variables can be used anywhere, either in SQL statements or in PL/SQL blocks. 5. Applications written in PL/SQL are portable to any computer hardware and operating system, where Oracle is operational. Q. Write PL/SQL program to display factorial of any number. (Correct logic 2 Marks, correct syntax 2 Marks) [**Note: Any other relevant logic can be considered] declare f number :=1; n number := &n; begin for i in 1..n loop f := f * i; end loop; dbms_output.put_line(f); end; / Q. Explain implicit and explicit cursors. (Implicit cursor 2 Marks, Explicit cursor 2 Marks)

29 Implicit Cursor: Implicit cursors are automatically created by Oracle whenever an SQL statement is executed, when there is no explicit cursor for the statement. Whenever a DML statement (INSERT, UPDATE and DELETE) is issued, an implicit cursor is associated with this statement. For INSERT operations, the cursor holds the data that needs to be inserted. For UPDATE and DELETE operations, the cursor identifies the rows that would be affected. In PL/SQL, you can refer to the most recent implicit cursor as the SQL cursor, which always has the attributes like %FOUND, %ISOPEN, %NOTFOUND, and %ROWCOUNT. The following table provides the description of the most used attributes Explicit cursor: Explicit cursors are programmer defined cursors for gaining more control over the context area. An explicit cursor should be defined in the declaration section of the PL/SQL Block. It is created on a SELECT Statement which returns more than one row. Working with an explicit cursor involves four steps: Declaring the cursor for initializing in the memory Cursor cursor_name IS select_statement; Opening the cursor for allocating memory Open cursorname; Fetching the cursor for retrieving data Fetch cursorname INTO variable1,variable2 Closing the cursor to release allocated memory Close cursorname; Q. Explain parameterized cursor with example. (Explanation - 2 Marks, Any relevant Example - 2 Marks) PL/SQL Parameterized cursor pass the parameters into a cursor and use them in to query. PL/SQL Parameterized cursor define only datatype of parameter and not need to define it's length.

30 Default values is assigned to the Cursor parameters and scope of the parameters are locally. Parameterized cursors are also saying static cursors that can passed parameter value when cursor are opened. Syntax to declare parameterized cursor: CURSOR CursorName(VariableName Datatype)IS<SELECT statement > Opening A parameterized Cursor And Passing Values to the Cursor OPEN CursorName(Value / Variable / Expression); Example Cursor display employee information from emp_information table whose emp_no is four (4). DECLARE cursor c(no number) is select * from emp_information where emp_no = no; tmp emp_information%rowtype; OPEN c(4); FOR tmp IN c(4) LOOP dbms_output.put_line('emp_no: ' tmp.emp_no); dbms_output.put_line('emp_name: ' tmp.emp_name); dbms_output.put_line('emp_dept: ' tmp.emp_dept); dbms_output.put_line('emp_salary:' tmp.emp_salary); END Loop; CLOSE c; / Q. Give block structure of PL/SQL and explain main components. (Block structure - 2 Marks, Explanation - 2 Marks) Declare Declaration of memory variables (Mandatory) SQL executable statements Exception Handling errors (Mandatory)

31 A block begins with a declarative section where variables are declared. This is followed by a section containing the procedural statements surrounded by and END keywords. Each block must have Begin and End statements and may optionally include an exception section tohandle errors.

PL/SQL is a combination of SQL along with the procedural features of programming languages.

PL/SQL is a combination of SQL along with the procedural features of programming languages. (24 Marks) 5.1 What is PLSQL? PLSQL stands for Procedural Language extension of SQL. PLSQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle

More information

PL/SQL Block structure

PL/SQL Block structure PL/SQL Introduction Disadvantage of SQL: 1. SQL does t have any procedural capabilities. SQL does t provide the programming technique of conditional checking, looping and branching that is vital for data

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 15 EXAMINATION Model Answer

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) WINTER 15 EXAMINATION Model Answer Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may

More information

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine.

ADVANTAGES. Via PL/SQL, all sorts of calculations can be done quickly and efficiently without use of Oracle engine. 1 PL/SQL INTRODUCTION SQL does not have procedural capabilities. SQL does not provide the programming techniques of condition checking, looping and branching that is required for data before permanent

More information

Procedural Language Structured Query Language (PL/SQL)

Procedural Language Structured Query Language (PL/SQL) The Islamic University of Gaza Faculty of Engineering Dept. of Computer Engineering Database Lab (ECOM 4113) Lab 7 Procedural Language Structured Query Language (PL/SQL) Eng. Ibraheem Lubbad Structured

More information

1. A) Attempt any six of following: 12

1. A) Attempt any six of following: 12 Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

Slides by: Ms. Shree Jaswal

Slides by: Ms. Shree Jaswal Slides by: Ms. Shree Jaswal A trigger is a statement that is executed automatically by the system as a side effect of a modification to the database. To design a trigger mechanism, we must: Specify the

More information

INDEX. 1 Introduction. 2 Types of Cursors 2.1 Explicit cursor 2.2 Attributes 2.3 Implicit cursor 2.4 Attributes. 3 Parameterized cursor

INDEX. 1 Introduction. 2 Types of Cursors 2.1 Explicit cursor 2.2 Attributes 2.3 Implicit cursor 2.4 Attributes. 3 Parameterized cursor INDEX 1 Introduction 2 Types of Cursors 2.1 Explicit cursor 2.2 Attributes 2.3 Implicit cursor 2.4 Attributes 3 Parameterized cursor INTRODUCTION what is cursor? we have seen how oracle executes an SQL

More information

Control Structures. Control Structures 3-1

Control Structures. Control Structures 3-1 3 Control Structures One ship drives east and another drives west With the selfsame winds that blow. Tis the set of the sails and not the gales Which tells us the way to go. Ella Wheeler Wilcox This chapter

More information

Lecture 08. Spring 2018 Borough of Manhattan Community College

Lecture 08. Spring 2018 Borough of Manhattan Community College Lecture 08 Spring 2018 Borough of Manhattan Community College 1 The SQL Programming Language Recent versions of the SQL standard allow SQL to be embedded in high-level programming languages to help develop

More information

UNIT II PL / SQL AND TRIGGERS

UNIT II PL / SQL AND TRIGGERS UNIT II PL / SQL AND 1 TRIGGERS TOPIC TO BE COVERED.. 2.1 Basics of PL / SQL 2.2 Datatypes 2.3 Advantages 2.4 Control Structures : Conditional, Iterative, Sequential 2.5 Exceptions: Predefined Exceptions,User

More information

Question Bank PL/SQL Fundamentals-I

Question Bank PL/SQL Fundamentals-I Question Bank PL/SQL Fundamentals-I UNIT-I Fundamentals of PL SQL Introduction to SQL Developer, Introduction to PL/SQL, PL/SQL Overview, Benefits of PL/SQL, Subprograms, Overview of the Types of PL/SQL

More information

The PL/SQL Engine: PL/SQL. A PL/SQL Block: Declaration Section. Execution Section. Declaration Section 3/24/2014

The PL/SQL Engine: PL/SQL. A PL/SQL Block: Declaration Section. Execution Section. Declaration Section 3/24/2014 PL/SQL The PL/SQL Engine: PL/SQL stands for Procedural Language extension of SQL. PL/SQL is a combination of SQL along with the procedural features of programming languages. It was developed by Oracle

More information

UNIT-IV (Relational Database Language, PL/SQL)

UNIT-IV (Relational Database Language, PL/SQL) UNIT-IV (Relational Database Language, PL/SQL) Section-A (2 Marks) Important questions 1. Define (i) Primary Key (ii) Foreign Key (iii) unique key. (i)primary key:a primary key can consist of one or more

More information

PL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number

PL/SQL. Exception. When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number PL/SQL Exception When the PL/SQL engine cannot execute the PLSQL block it raise an error. Every Oracle error has an error number Exceptions must be handled by name. PL/SQL predefines some common Oracle

More information

UNIT 2 Set Operators

UNIT 2 Set Operators Course Title: Database Systems ( M.C.A 1 st Semester ) (Evening Batch) UNIT 2 Set Operators Set operators are used to join the results of two (or more) SELECT statements.the SET operators available in

More information

Section I : Section II : Question 1. Question 2. Question 3.

Section I : Section II : Question 1. Question 2. Question 3. Computer Science, 60-415 Midterm Examiner: Ritu Chaturvedi Date: Oct. 27 th, 2011 Student Name: Student Number: INSTRUCTIONS (Please Read Carefully) Examination Period is 1 hour and 15 minutes Answer all

More information

Overview of PL/SQL. About PL/SQL. PL/SQL Environment. Benefits of PL/SQL. Integration

Overview of PL/SQL. About PL/SQL. PL/SQL Environment. Benefits of PL/SQL. Integration About PL/ Overview of PL/ PL/ is an extension to with design features of programming languages. Data manipulation and query statements of are included within procedural units of code. PL/ Environment Benefits

More information

PLSQL Interview Questions :

PLSQL Interview Questions : PLSQL Interview Questions : In my previous articles I have explained the SQL interview questions,bi Interview questions which will give the best idea about the question that may ask in interview.in this

More information

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks)

RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks) 2017 RDBMS Topic 4 Adv. SQL, MSBTE Questions and Answers ( 12 Marks) 2016 Q. What is view? Definition of view: 2 marks) Ans : View: A view is a logical extract of a physical relation i.e. it is derived

More information

Introduction to Computer Science and Business

Introduction to Computer Science and Business Introduction to Computer Science and Business The Database Programming with PL/SQL course introduces students to the procedural language used to extend SQL in a programatic manner. This course outline

More information

ORACLE: PL/SQL Programming

ORACLE: PL/SQL Programming %ROWTYPE Attribute... 4:23 %ROWTYPE... 2:6 %TYPE... 2:6 %TYPE Attribute... 4:22 A Actual Parameters... 9:7 Actual versus Formal Parameters... 9:7 Aliases... 8:10 Anonymous Blocks... 3:1 Assigning Collection

More information

5. Single-row function

5. Single-row function 1. 2. Introduction Oracle 11g Oracle 11g Application Server Oracle database Relational and Object Relational Database Management system Oracle internet platform System Development Life cycle 3. Writing

More information

Meet MariaDB Vicențiu Ciorbaru Software MariaDB Foundation * * 2017 MariaDB Foundation

Meet MariaDB Vicențiu Ciorbaru Software MariaDB Foundation * * 2017 MariaDB Foundation Meet MariaDB 10.3 Vicențiu Ciorbaru Software Engineer @ MariaDB Foundation vicentiu@mariadb.org * * What is MariaDB? MariaDB 5.1 (Feb 2010) - Making builds free MariaDB 5.2 (Nov 2010) - Community features

More information

Programming in Oracle with PL/SQL. Procedural Language Extension to SQL

Programming in Oracle with PL/SQL. Procedural Language Extension to SQL Programming in Oracle with PL/SQL Procedural Language Extension to SQL PL/SQL Allows using general programming tools with SQL, for example: loops, conditions, functions, etc. This allows a lot more freedom

More information

Oracle Class VI. Exception Block Cursors For Loops

Oracle Class VI. Exception Block Cursors For Loops Oracle Class VI Exception Block Cursors For Loops Pl/sql some more basics Loop through records, manipulating them one at a time. Keep code secure by offering encryption, and storing code permanently on

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified)

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

Sisteme Informatice şi Standarde Deschise (SISD) Curs 7 Standarde pentru programarea bazelor de date (1)

Sisteme Informatice şi Standarde Deschise (SISD) Curs 7 Standarde pentru programarea bazelor de date (1) Administrarea Bazelor de Date Managementul în Tehnologia Informaţiei Sisteme Informatice şi Standarde Deschise (SISD) 2009-2010 Curs 7 Standarde pentru programarea bazelor de date (1) 23.11.2009 Sisteme

More information

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL)

PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 3 Database Programming PROCEDURAL DATABASE PROGRAMMING ( PL/SQL AND T-SQL) AGENDA 3. Declaring Variables/Constants 4. Flow Control

More information

Database links: Views:

Database links: Views: Database links: Views: Allows to connect to remote databases Can be public or private Public can be used by anyone and private is available only for owner of the object. Can point to host in the tns entry

More information

1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL

1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL CertBus.com 1Z0-144 Q&As Oracle Database 11g: Program with PL/ SQL Pass Oracle 1Z0-144 Exam with 100% Guarantee Free Download Real Questions & Answers PDF and VCE file from: 100% Passing Guarantee 100%

More information

Oracle Database 11g: Program with PL/SQL Release 2

Oracle Database 11g: Program with PL/SQL Release 2 Oracle University Contact Us: +41- (0) 56 483 31 31 Oracle Database 11g: Program with PL/SQL Release 2 Duration: 5 Days What you will learn This course introduces students to PL/SQL and helps them understand

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in the model answer scheme. 2) The model answer and the answer written by candidate

More information

PL/SQL-TYCS. The 'Hello World' Example

PL/SQL-TYCS. The 'Hello World' Example PLSQL-TYCS In this chapter, we will discuss the Basic Syntax of PLSQL which is a block-structured language; this means that the PLSQL programs are divided and written in logical blocks of code. Each block

More information

Relational Database Management System 2014

Relational Database Management System 2014 Unit-1: Procedural SQL data types Fill in the blank: 1. are used to defining a fully relational database. 2. Data can be presented to the user in different logical combinations, called. 3. Changes to the

More information

Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired.

Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired. Aim:- TRIGGERS Trigger is a stored procedure which is called implicitly by oracle engine whenever a insert, update or delete statement is fired. Advantages of database triggers: ---> Data is generated

More information

Actual4Test. Actual4test - actual test exam dumps-pass for IT exams

Actual4Test.   Actual4test - actual test exam dumps-pass for IT exams Actual4Test http://www.actual4test.com Actual4test - actual test exam dumps-pass for IT exams Exam : 1z0-144 Title : Oracle Database 11g: Program with PL/SQL Vendor : Oracle Version : DEMO Get Latest &

More information

Contents I Introduction 1 Introduction to PL/SQL iii

Contents I Introduction 1 Introduction to PL/SQL iii Contents I Introduction Lesson Objectives I-2 Course Objectives I-3 Human Resources (HR) Schema for This Course I-4 Course Agenda I-5 Class Account Information I-6 Appendixes Used in This Course I-7 PL/SQL

More information

SQL Interview Questions

SQL Interview Questions SQL Interview Questions SQL stands for Structured Query Language. It is used as a programming language for querying Relational Database Management Systems. In this tutorial, we shall go through the basic

More information

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION

MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may

More information

Chapter 1 CONTROL STRUCTURES. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 CONTROL STRUCTURES. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 CONTROL STRUCTURES SYS-ED/ Computer Education Techniques, Inc. ORACLE: PL/SQL: Programming - Advanced Objectives You will learn: Uses and types of control structures. Constructing an IF statement.

More information

M.SC(IT) I YEAR( ) CORE: ADVANCED DBMS-163B Semester : I Multiple Choice Questions

M.SC(IT) I YEAR( ) CORE: ADVANCED DBMS-163B Semester : I Multiple Choice Questions M.SC(IT) I YEAR(2017-2019) CORE: ADVANCED DBMS-163B Semester : I Multiple Choice Questions 1) storage lose contents when power is switched off. a) Volatile storage. b) Nonvolatile storage. c) Disk storage.

More information

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led

Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led Oracle Database 12c: Program with PL/SQL Duration: 5 Days Method: Instructor-Led Course Description This training starts with an introduction to PL/SQL and then explores the benefits of this powerful programming

More information

Oracle Database: Program with PL/SQL

Oracle Database: Program with PL/SQL Oracle University Contact Us: + 420 2 2143 8459 Oracle Database: Program with PL/SQL Duration: 5 Days What you will learn This Oracle Database: Program with PL/SQL training starts with an introduction

More information

Oracle Database: Program with PL/SQL Ed 2

Oracle Database: Program with PL/SQL Ed 2 Oracle University Contact Us: +38 61 5888 820 Oracle Database: Program with PL/SQL Ed 2 Duration: 5 Days What you will learn This Oracle Database: Program with PL/SQL training starts with an introduction

More information

Persistent Stored Modules (Stored Procedures) : PSM

Persistent Stored Modules (Stored Procedures) : PSM 1 Persistent Stored Modules (Stored Procedures) : PSM Stored Procedures What is stored procedure? SQL allows you to define procedures and functions and store them in the database server Executed by the

More information

Conditionally control code flow (loops, control structures). Create stored procedures and functions.

Conditionally control code flow (loops, control structures). Create stored procedures and functions. TEMARIO Oracle Database: Program with PL/SQL Ed 2 Duration: 5 Days What you will learn This Oracle Database: Program with PL/SQL training starts with an introduction to PL/SQL and then explores the benefits

More information

Creating and Managing Tables Schedule: Timing Topic

Creating and Managing Tables Schedule: Timing Topic 9 Creating and Managing Tables Schedule: Timing Topic 30 minutes Lecture 20 minutes Practice 50 minutes Total Objectives After completing this lesson, you should be able to do the following: Describe the

More information

Table of Contents. PDF created with FinePrint pdffactory Pro trial version

Table of Contents. PDF created with FinePrint pdffactory Pro trial version Table of Contents Course Description The SQL Course covers relational database principles and Oracle concepts, writing basic SQL statements, restricting and sorting data, and using single-row functions.

More information

1 Prepared By Heena Patel (Asst. Prof)

1 Prepared By Heena Patel (Asst. Prof) Topic 1 1. What is difference between Physical and logical data 3 independence? 2. Define the term RDBMS. List out codd s law. Explain any three in detail. ( times) 3. What is RDBMS? Explain any tow Codd

More information

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views

Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views Oracle Class VII More on Exception Sequence Triggers RowID & Rownum Views Sequence An Oracle sequence is an Oracle database object that can be used to generate unique numbers. You can use sequences to

More information

Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia

Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia Topics Fundamentals of PL/SQL, Integration with PROIV SuperLayer and use within Glovia 1. Creating a Database Alias 2. Introduction to SQL Relational Database Concept Definition of Relational Database

More information

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo

Vendor: Oracle. Exam Code: 1Z Exam Name: Oracle Database 11g: Program with PL/ SQL. Version: Demo Vendor: Oracle Exam Code: 1Z0-144 Exam Name: Oracle Database 11g: Program with PL/ SQL Version: Demo QUESTION NO: 1 View the Exhibit to examine the PL/SQL code: SREVROUPUT is on for the session. Which

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Views Creating views Using

More information

Sample Test #1 Questions

Sample Test #1 Questions Sample Test #1 Questions 1. Fibonacci numbers & Iteration Structures/using elsif a. Another program to generate Fibonacci numbers b. Makes use of the elsif selection structure c. It saves us of repeated

More information

2. Programming written ( main theme is to test our data structure knowledge, proficiency

2. Programming written ( main theme is to test our data structure knowledge, proficiency ORACLE Job Placement Paper Paper Type : General - other 1. Tech + Aptitude written 2. Programming written ( main theme is to test our data structure knowledge, proficiency sorting searching algorithms

More information

Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days

Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days Oracle Database 12c R2: Program with PL/SQL Ed 2 Duration: 5 Days This Database Program with PL/SQL training shows you how to develop stored procedures, functions, packages and database triggers. You'll

More information

ORACLE Job Placement Paper. Paper Type : General - other

ORACLE Job Placement Paper. Paper Type : General - other ORACLE Job Placement Paper Paper Type : General - other 1. Tech + Aptitude written 2. Programming written ( main theme is to test our data structure knowledge, proficiency sorting searching algorithms

More information

Introduction to Explicit Cursors. Copyright 2008, Oracle. All rights reserved.

Introduction to Explicit Cursors. Copyright 2008, Oracle. All rights reserved. Introduction to Explicit Cursors Introduction to Explicit Cursors 2 What Will I Learn? In this lesson, you will learn to: Distinguish between an implicit and an explicit cursor Describe why and when to

More information

Oracle PLSQL Training Syllabus

Oracle PLSQL Training Syllabus Oracle PLSQL Training Syllabus Introduction Course Objectives Course Agenda Human Resources (HR) Schema Introduction to SQL Developer Introduction to PL/SQL PL/SQL Overview Benefits of PL/SQL Subprograms

More information

Oracle SQL & PL SQL Course

Oracle SQL & PL SQL Course Oracle SQL & PL SQL Course Complete Practical & Real-time Training Job Support Complete Practical Real-Time Scenarios Resume Preparation Lab Access Training Highlights Placement Support Support Certification

More information

Oracle PLSQL Study Material ORACLE & PL/SQL STUDY MATERIAL

Oracle PLSQL Study Material ORACLE & PL/SQL STUDY MATERIAL ORACLE & PL/SQL STUDY MATERIAL Table of Contents 1 OVERVIEW OF ORACLE... 5 1.1 THE DATABASE... 5 1.2 THE ORACLE INSTANCE... 8 2 BASIC ORACLE OBJECTS... 12 3 TRANSACTIONS IN ORACLE... 14 4 OVERVIEW OF PL/SQL...

More information

IZ0-144Oracle 11g PL/SQL Certification (OCA) training

IZ0-144Oracle 11g PL/SQL Certification (OCA) training IZ0-144Oracle 11g PL/SQL Certification (OCA) training Advanced topics covered in this course: Managing Dependencies of PL/SQL Objects Direct and Indirect Dependencies Using the PL/SQL Compiler Conditional

More information

Sample Question Paper

Sample Question Paper Sample Question Paper Marks : 70 Time:3 Hour Q.1) Attempt any FIVE of the following. a) List any four applications of DBMS. b) State the four database users. c) Define normalization. Enlist its type. d)

More information

Database Programming with PL/SQL

Database Programming with PL/SQL Database Programming with PL/SQL 5-3 Objectives This lesson covers the following objectives: List and explain the benefits of using cursor FOR loops Create PL/SQL code to declare a cursor and manipulate

More information

Question No : 1 Which statement is true about triggers on data definition language (DDL) statements?

Question No : 1 Which statement is true about triggers on data definition language (DDL) statements? Volume: 103 Questions Question No : 1 Which statement is true about triggers on data definition language (DDL) statements? A. They can be used to track changes only to a table or index. B. They can be

More information

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query

Oracle. SQL(Structured Query Language) Introduction of DBMS. Build In Function. Introduction of RDBMS. Grouping the Result of a Query Oracle SQL(Structured Query Language) Introduction of DBMS Approach to Data Management Introduction to prerequisites File and File system Disadvantages of file system Introduction to TOAD and oracle 11g/12c

More information

4 Application Programming

4 Application Programming 4 Application Programming 4.1 PL/SQL 4.1.1 Introduction The development of database applications typically requires language constructs similar to those that can be found in programming languages such

More information

Programming the Database

Programming the Database Programming the Database Today s Lecture 1. Stored Procedures 2. Functions BBM471 Database Management Systems Dr. Fuat Akal akal@hacettepe.edu.tr 3. Cursors 4. Triggers 5. Dynamic SQL 2 Stored Procedures

More information

Lesson B Objectives IF/THEN. Chapter 4B: More Advanced PL/SQL Programming

Lesson B Objectives IF/THEN. Chapter 4B: More Advanced PL/SQL Programming Chapter 4B: More Advanced PL/SQL Programming Monday 2/23/2015 Abdou Illia MIS 4200 - Spring 2015 Lesson B Objectives After completing this lesson, you should be able to: Create PL/SQL decision control

More information

Database Programming with PL/SQL

Database Programming with PL/SQL Database Programming with PL/SQL Cursor FOR Loops 1 Copyright 2013, Oracle and/or its affiliates. All rights Objectives This lesson covers the following objectives: List and explain the benefits of using

More information

4 Application Programming

4 Application Programming 4 Application Programming 4.1 PL/SQL 4.1.1 Introduction The development of database applications typically requires language constructs similar to those that can be found in programming languages such

More information

Oracle Database 11g: Program with PL/SQL

Oracle Database 11g: Program with PL/SQL Oracle University Contact: +31 (0)30 669 9244 Oracle Database 11g: Program with PL/SQL Duration: 5 Dagen What you will learn This course introduces students to PL/SQL and helps them understand the benefits

More information

DATABASE DESIGN - 1DL400

DATABASE DESIGN - 1DL400 DATABASE DESIGN - 1DL400 Fall 2015 A course on modern database systems http://www.it.uu.se/research/group/udbl/kurser/dbii_ht15 Kjell Orsborn Uppsala Database Laboratory Department of Information Technology,

More information

Oracle Developer Track Course Contents. Mr. Sandeep M Shinde. Oracle Application Techno-Functional Consultant

Oracle Developer Track Course Contents. Mr. Sandeep M Shinde. Oracle Application Techno-Functional Consultant Oracle Developer Track Course Contents Sandeep M Shinde Oracle Application Techno-Functional Consultant 16 Years MNC Experience in India and USA Trainer Experience Summary:- Sandeep M Shinde is having

More information

Introduction to SQL/PLSQL Accelerated Ed 2

Introduction to SQL/PLSQL Accelerated Ed 2 Oracle University Contact Us: Local: 1800 103 4775 Intl: +91 80 67863102 Introduction to SQL/PLSQL Accelerated Ed 2 Duration: 5 Days What you will learn This Introduction to SQL/PLSQL Accelerated course

More information

5 Integrity Constraints and Triggers

5 Integrity Constraints and Triggers 5 Integrity Constraints and Triggers 5.1 Integrity Constraints In Section 1 we have discussed three types of integrity constraints: not null constraints, primary keys, and unique constraints. In this section

More information

Question: Which statement would you use to invoke a stored procedure in isql*plus?

Question: Which statement would you use to invoke a stored procedure in isql*plus? What are the two types of subprograms? procedure and function Which statement would you use to invoke a stored procedure in isql*plus? EXECUTE Which SQL statement allows a privileged user to assign privileges

More information

Chapter 2. DB2 concepts

Chapter 2. DB2 concepts 4960ch02qxd 10/6/2000 7:20 AM Page 37 DB2 concepts Chapter 2 Structured query language 38 DB2 data structures 40 Enforcing business rules 49 DB2 system structures 52 Application processes and transactions

More information

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague

RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague course: Database Applications (NDBI026) WS2015/16 RNDr. Michal Kopecký, Ph.D. Department of Software Engineering, Faculty of Mathematics and Physics, Charles University in Prague Triggers Triggers Overview

More information

EDUVITZ TECHNOLOGIES

EDUVITZ TECHNOLOGIES EDUVITZ TECHNOLOGIES Oracle Course Overview Oracle Training Course Prerequisites Computer Fundamentals, Windows Operating System Basic knowledge of database can be much more useful Oracle Training Course

More information

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C

CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C CS6312 DATABASE MANAGEMENT SYSTEMS LABORATORY L T P C 0 0 3 2 LIST OF EXPERIMENTS: 1. Creation of a database and writing SQL queries to retrieve information from the database. 2. Performing Insertion,

More information

The following practical s have to be performed and journal should contain the output with aim as per syllabus. This is just for reference

The following practical s have to be performed and journal should contain the output with aim as per syllabus. This is just for reference The following practical s have to be performed and journal should contain the output with aim as per syllabus. This is just for reference Solution for cursors 1. Write PLSQL block to create a cursor to

More information

PL / SQL Basics. Chapter 3

PL / SQL Basics. Chapter 3 PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic

More information

2 PL/SQL - fundamentals Variables and Constants Operators SQL in PL/SQL Control structures... 7

2 PL/SQL - fundamentals Variables and Constants Operators SQL in PL/SQL Control structures... 7 Table of Contents Spis treści 1 Introduction 1 2 PLSQL - fundamentals 1 2.1 Variables and Constants............................ 2 2.2 Operators.................................... 5 2.3 SQL in PLSQL.................................

More information

Oracle Database: Introduction to SQL/PLSQL Accelerated

Oracle Database: Introduction to SQL/PLSQL Accelerated Oracle University Contact Us: Landline: +91 80 67863899 Toll Free: 0008004401672 Oracle Database: Introduction to SQL/PLSQL Accelerated Duration: 5 Days What you will learn This Introduction to SQL/PLSQL

More information

Full file at

Full file at ch02 True/False Indicate whether the statement is true or false. 1. The term anonymous blocks refers to blocks of code that are not stored for reuse and do not exist after being executed. 2. The only required

More information

Active Databases Part 1: Introduction CS561

Active Databases Part 1: Introduction CS561 Active Databases Part 1: Introduction CS561 1 Active Databases n Triggers and rules are developed for data integrity and constraints n Triggers make passive database active Database reacts to certain situations

More information

Oracle PL/SQL - 12c & 11g [Basic PL/SQL & Advanced PL/SQL]

Oracle PL/SQL - 12c & 11g [Basic PL/SQL & Advanced PL/SQL] Chapter Overview of PL/SQL Programs Control Statements Using Loops within PLSQL Oracle PL/SQL - 12c & 11g [Basic PL/SQL & Advanced PL/SQL] Table of Contents Describe a PL/SQL program construct List the

More information

Oracle PLSQL. Course Summary. Duration. Objectives

Oracle PLSQL. Course Summary. Duration. Objectives Oracle PLSQL Course Summary Use conditional compilation to customize the functionality in a PL/SQL application without removing any source code Design PL/SQL packages to group related constructs Create

More information

Oracle - Oracle Database: Program with PL/SQL Ed 2

Oracle - Oracle Database: Program with PL/SQL Ed 2 Oracle - Oracle Database: Program with PL/SQL Ed 2 Code: Lengt h: URL: DB-PLSQL 5 days View Online This Oracle Database: Program with PL/SQL training starts with an introduction to PL/SQL and then explores

More information

COSC344 Database Theory and Applications. Lecture 11 Triggers

COSC344 Database Theory and Applications. Lecture 11 Triggers COSC344 Database Theory and Applications Lecture 11 Triggers COSC344 Lecture 11 1 Overview Last Lecture - PL/SQL This Lecture - Triggers - Source: Lecture notes, Oracle documentation Next Lecture - Java

More information

Oracle Database 11g: SQL and PL/SQL Fundamentals

Oracle Database 11g: SQL and PL/SQL Fundamentals Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle Database 11g: SQL and PL/SQL Fundamentals Duration: 5 Days What you will learn In this course, students learn the fundamentals of SQL and PL/SQL

More information

Table of Contents. Oracle SQL PL/SQL Training Courses

Table of Contents. Oracle SQL PL/SQL Training Courses Table of Contents Overview... 7 About DBA University, Inc.... 7 Eligibility... 8 Pricing... 8 Course Topics... 8 Relational database design... 8 1.1. Computer Database Concepts... 9 1.2. Relational Database

More information

Now, we can refer to a sequence without having to use any SELECT command as follows:

Now, we can refer to a sequence without having to use any SELECT command as follows: Enhancement in 11g Database PL/SQL Sequence: Oracle Database 11g has now provided support for Sequence in PL/SQL. Earlier to get a number from a sequence in PL/SQL we had to use SELECT command with DUAL

More information

OVERVIEW OF THE TYPES OF PL/SQL BLOCKS:

OVERVIEW OF THE TYPES OF PL/SQL BLOCKS: OVERVIEW OF THE TYPES OF PL/SQL BLOCKS: The P/L SQL blocks can be divided into two broad categories: Anonymous Block: The anonymous block is the simplest unit in PL/SQL. It is called anonymous block because

More information

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code:

M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools. Faculty Code: 003 Subject Code: 003-007304 M.C.A. (CBCS) Sem.-III Examination November-2013 CCA-3004 : Database Concepts and Tools Faculty Code: 003 Subject Code: 007304 Time: 21/2 Hours] [Total Marks: 70 I. Answer the following multiple

More information

Database Programming with PL/SQL

Database Programming with PL/SQL Database Programming with PL/SQL Trapping Oracle Server Exceptions 1 Copyright 2013, Oracle and/or its affiliates. All rights Objectives This lesson covers the following objectives: Describe and provide

More information

Course 492 Supplementary Materials. Mutating Tables

Course 492 Supplementary Materials. Mutating Tables Course 492 Supplementary Materials Mutating Tables 1 Mutating Table Restriction A mutating table is a table that is currently being modified by an UPDATE, DELETE, or INSERT In the following example, the

More information

Downloaded from

Downloaded from Lesson 16: Table and Integrity Constraints Integrity Constraints are the rules that a database must follow at all times. Various Integrity constraints are as follows:- 1. Not Null: It ensures that we cannot

More information