0% found this document useful (0 votes)
338 views3 pages

Database Module 4 5

The document discusses PL/SQL procedures and functions. It provides examples of correct and incorrect procedure and function headers, parameters, and invocations. It also answers multiple choice questions about features like default parameter values, private variables, and how functions can be used in SQL statements and expressions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
338 views3 pages

Database Module 4 5

The document discusses PL/SQL procedures and functions. It provides examples of correct and incorrect procedure and function headers, parameters, and invocations. It also answers multiple choice questions about features like default parameter values, private variables, and how functions can be used in SQL statements and expressions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

● The return statement in a function returns What is missing in the procedure header?

control to the calling program and returns CREATE PROCEDURE raise_sal(p_id IN


the results of the function. NUMBER, p_sal IN NUMBER) IS
BEGIN

- An IN OUT parameter supplies an input END;
value, which can be returned (output) as a
modified value. ● Parameter data type size
● Nothing is missing
The ____ is added to CREATE PROCEDURE ● Procedure name after END (optional)
clause to overwrite an existing procedure. - OR ● ;
REPLACE

Subprograms are named PL/SQL blocks that are What is missing in the given code below?
compiled and stored in the ____. - DATABASE CREATE or replace procedure raise_sal
empid my_employees.employee_id%TYPE := 1234,
emp_raise number IS
In anonymous block, DECLARE states “this is the BEGIN
start of a block”. In Procedure, ___ states “this is update employees
set salary = salary + (salary * (emp_raise/100) where employee_id =
the start of a subprogram”. - CREATE
emp;
PROCEDURE END;

Subprograms are implicitly shared. - False ● Not in the options


(explicitly) ● Incomplete declaration of emp_raise
parameter
Subprograms become the building blocks of ● Nothing is missing
packages and triggers. - True ● IN (emp_raise IN number is optional)
● Procedure name after END keyword

The code below is a correct example of passing Which can be used to assign a default value to IN
parameters by combination notation. - False parameters?
add_dept (p_loc=>1400, ‘EDUCATION’ ); ● :=
Correct: add_dept ('EDUCATION', p_loc=>1400); ● DEFAULT
● Assignment operator
If combination notation is used, the positional ● All the options
parameters must come first before the named
parameters. - True How many parameters are there in the given code?
CREATE or replace procedure raise_sal
The formal parameters can be literal values, empid my_employees.employee_id%TYPE := 1234,
emp_raise number IS
variables, or expressions that are sent to the BEGIN
parameter list of a called subprogram. - False update employees
(actual parameters) set salary = salary + (salary * (emp_raise/100) where employee_id =
emp;
END;
The positional parameter passing uses the
associate operator - False ● 1
● 0
The positional parameter passing is the common ● 2
method of passing parameters – True ● 3

This study source was downloaded by 100000848084631 from CourseHero.com on 06-21-2022 00:50:37 GMT -05:00

https://www.coursehero.com/file/129616780/DATABASE-MODULE-4-5docx/
Given the procedure below, what is the correct way In the given Procedure header, the underlined
of invoking the procedure? clause/keyword is optional
CREATE OR REPLACE PROCEDURE show_emps CREATE OR REPLACE PROCEDURE name
(p_emp_id IN NUMBER, p_department_id IN number,
p_hiredate IN DATE) IS [parameters] IS|AS - True
BEGIN
...
The DEFAULT keyword is used to assign a default
END;
● show_emps(p_department_id => 10, p_hiredate => ‘01-dec- value for formal parameters - True
1007’, p_emp_id => 101)
● show_emps(101, 10, ‘01-dec-2006’);
● show_emps(101, p_hiredate => ‘01-dec-2007’,
● Usually, you can use named notation to
p_department_id = 10) override the default values of formal
● All the options parameters./
● You can set a default value of a formal
In stored function, the ___ clause is used instead of parameter by including the DEFAULT clause
OUT mode. - RETURN or using the assignment operator (:=) in the
CREATE PROCEDURE or CREATE
The functions used in SQL statements cannot use FUNCTION statement.
OUT or ___ modes. - IN OUT
What is missing in the given code below?
CREATE or replace procedure raise_sal
Which of the statement below is valid? Assuming (empid my_employees.employee_id%TYPE := 1234,
emp_raise number)
that get_sal function exists with parameter. BEGIN
● get_sal + 50; update employees
set salary = salary + (salary * (emp_raise/100) where employee_id =
● not in the options
emp;
● v_salary := get_sal() + 50; END;
● get_sal() + 50; ● Procedure name after END keyword
● Not in the options (IS)
A function is called as part of an expression ● Nothing is missing
(example): ● IN
promotable := sal_ok(new_sal, new_title) AND (rating
● Incomplete declaration of emp_raise
> 3);
parameter

Functions that take no parameters are written


without parentheses. How many private variables are there in the given
code?
A function can be called as a part of: CREATE or replace procedure raise_sal
● SQL statement (empid my_employees.employee_id%TYPE := 1234,
● PL/SQL expression emp_raise number) IS
BEGIN
● Both options
update employees
set salary = salary + (salary * (emp_raise/100) where
Which keyword is omitted in the declaration section employee_id = emp;
of the procedure? - DECLARE END;
● 0
The ___ are named PL/SQL blocks that are ● 3
compiled and stored in the database. - ● 1
SUBPROGRAMS ● 2

The executable section of the procedure body In stored function, the parameter mode should only
requires a minimum of ___ statement - one be __ - IN

This study source was downloaded by 100000848084631 from CourseHero.com on 06-21-2022 00:50:37 GMT -05:00

https://www.coursehero.com/file/129616780/DATABASE-MODULE-4-5docx/
What is missing in the code below?
create or replace function sample
return number
is num number(2);
begin
num:=5+5;
end;
● Incomplete expression
● No return value
● Formal parameter
● Size of the returning value

This study source was downloaded by 100000848084631 from CourseHero.com on 06-21-2022 00:50:37 GMT -05:00

https://www.coursehero.com/file/129616780/DATABASE-MODULE-4-5docx/
Powered by TCPDF (www.tcpdf.org)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy