1.
Examine this function: CREATE OR REPLACE FUNCTION CALC_PLAYER_AVG (V_ID in PLAYER_BAT_STAT.PLAYER_ID%TYPE) RETURN NUMBER IS V_AVG NUMBER; BEGIN SELECT HITS / AT_BATS INTO V_AVG FROM PLAYER_BAT_STAT WHERE PLAYER_ID = V_ID; RETURN (V_AVG); END; Which statement will successfully invoke this function in SQL *Plus?
Correct Answer
A. SELECT CALC_PLAYER_AVG(PLAYER_ID) FROM PLAYER_BAT_STAT;
Explanation
B. You can't call a function in this way, in this way you can call a procedure, because function must return a value, to call a function using EXECUTE command you should declare a bind variable using the VARIABLE command then assign the value returned from the function to this variable, in the following way: SQL> VARIABLE v_get_value NUMBER SQL> EXECUTE :v_get_value := CALC_PLAYER_AVG(31) PL/SQL procedure successfully completed. SQL> PRINT v_get_value V_GET_VALUE
C. Again this way can't be use for calling a function in PL/SQL block because the function return a value and this values must be assigned to PL/SQL variable or to bind variable. Like this DECLARE v_get_from_fn NUMBER; BEGIN v_get_from := CALC_PLAYER_AVG(31); END; 1z0-147 /
D. Same as C.
E. START is use to execute a script
2.
Examine this code: CREATE OR REPLACE PRODECURE add_dept (p_dept_name VARCHAR2 DEFAULT 'placeholder', p_location VARCHAR2 DEFAULT 'Boston')IS BEGIN INSERT INTO departments VALUES (dept_id_seq.NEXTVAL, p_dept_name, p_location); END add_dept; / Which three are valid calls to the add_dep procedure? (Choose three)
Correct Answer(s)
A. Add_dept;
B. Add_dept('Accounting');
D. Add_dept(p_location=>'New York');
Explanation
A is correct because both of the parameter have a default values.
B is correct because here we call the procedure using position notation, and the first parameter for the procedure will have the value 'Accounting', and since the second parameter has a default value then we can skip it, and in this case it will take the default value.
D is correct because here we are calling the procedure using naming notation, the value 'New York' will go to the parameter p_location, and the parameter p_dept_name will have the default value. The following table list the for passing parameters to a procedure: Incorrect Answer
C: You can't use this way and assume that the PL/SQL will understand that he should assign the default value for the first parameter. This is incorrect way for calling
3.
Which two statements about packages are true? (Choose two)
Correct Answer(s)
D. The contents of packages can be shared by many applications.
E. You can achieve information hiding by making package constructs private
Explanation
Actually theses are some of the advantages of the package, sharing the package among applications and
hide the logic of the procedures and function that are inside the package by declaring them in the package
header and write the code of these procedures and functions inside the package body.
Incorrect Answers:
A: Packages can not be nested
B: Parameters can't be passed to a package; parameters can be passed to procedures and functions only.
C: By the first time you call a procedure, function, or reference a global variable within the package, the whole package will be loaded into the memory and stay there, so when ever you need to reference any of the package's constructs again you will find it in the memory
4.
Which two programming constructs can be grouped within a package? (Choose two)
Correct Answer(s)
A. Cursor
B. Constant
Explanation
Incorrect Answers
C: Triggers are objects that we create are created on the tables.
D: Sequences can't be grouped inside the packages, but we can reference then inside the package.
E: Views are created and they are database objects, and they can't be grouped inside the packages
5.
Which two statements describe the state of a package variable after executing the package in which it is declared? (Choose two)
Correct Answer(s)
A. It persists across transactions within a session.
E. It does not persist from session to session for the same user.
Explanation
You can keep track of the state of a package variable or cursor, which persists throughout the user session,
from the time the user first references the variable or cursor to the time the user disconnects.
1 Initialize the variable within its declaration or within an automatic, one-time-only procedure.
2 Change the value of the variable by means of package procedures.
3 The value of the variable is released when the user disconnects. Incorrect Answers
B: Each session will have its own value for the variables
C: It persists across the transactions and through the user session.
D: Each user has his own values and results, because each user has his own users.
6.
Which code can you use to ensure that the salary is not increased by more than 10% at a time nor is it ever decreased?
Correct Answer
B. CREATE OR REPLACE TRIGGER check_sal
BEFORE UPDATE OF sal ON emp
FOR EACH ROW
WHEN (new.sal < old.sal OR
new.sal > old.sal * 1.1)
BEGIN
RAISE_APPLICATION_ERROR ( - 20508, 'Do not decrease
salary not increase by more than 10%');
END;
Explanation
Row triggers are the correct chose for solving the problem. A row trigger fires each time the table is affected by the triggering event. If the triggering event affects no rows, a row trigger is not executed. Row triggers are useful if the trigger action depends on data of rows that are affected or on data provided by the triggering event itself. You can create a BEFORE row trigger in order to prevent the triggering operation from succeeding if a certain condition is violated. Within a ROW trigger, reference the value of a column before and after the data change by prefixing it with the OLD and NEW qualifier. Incorrect Answers:
A: Check constaint can't do this job lets take a look:
SQL> ALTER TABLE emp ADD
2 CONSTRAINT ck_sal CHECK (sal BETWEEN sal AND sal*1.1)
3 /
Table altered.
SQL> select ename, sal
2 from emp
3 where ename = 'KING';
ENAME SAL
KING 5000 Now let's issue an update statement SQL> update emp 2 set sal = 10 3 where ename = 'KING'; 1 row updated. As you can see the check constraint can't compare the old value with the new value. D,C: You can use NEW and OLD qualifier with row level triggers, If in the CREATE TRIGGER statement you didn't say FOR EACH ROW then the trigger will be statement level trigger
7.
Which statement is valid when removing procedures?
Correct Answer
A. Use a drop procedure statement to drop a standalone procedure.
Explanation
The DROP DROCEDURE statement is used to drop a stand alone procedure Incorrect Answers:
B: You can't drop a procedure that's inside a package, you have to drop the package, and in this case the whole procedures, functions,... that are inside the packages will be droped.
C: Same as B.
D: REUSE SETTINGS is used to to prevent Oracle from dropping and reacquiring compiler switch settings.With this clause, Oracle preserves the existing settings and uses them for the recompilation.
8.
Examine this package: CREATE OR REPLACE PACKAGE BB_PACK IS V_MAX_TEAM_SALARY NUMBER(12,2); PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER); END BB_PACK; / CREATE OR REPLACE PACKAGE BODY BB_PACK IS PROCEDURE UPD_PLAYER_STAT (V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITSWHERE PLAYER_ID = V_ID; COMMIT; END UPD_PLAYER_STAT; PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER) IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY); UPD_PLAYER_STAT(V_ID,0,0); END ADD_PLAYER; END BB_PACK; You make a change to the body of the BB_PACK package. The BB_PACK body is recompiled. What happens if the stand alone procedure VALIDATE_PLAYER_STAT references this package?
Correct Answer
B. VALIDATE_PLAYER_STAT is not invalidated
Explanation
You can greatly simplify dependency management with packages when referencing a package procedure or function from a stand-alone procedure or function.
If the package body changes and the package specification does not change, the stand-alone procedure referencing a package construct remains valid.
If the package specification changes, the outside procedure referencing a package construct is invalidated, as is the package body
9.
You need to create a trigger on the EMP table that monitors every row that is changed and places this information into the AUDIT_TABLE. What type of trigger do you create?
Correct Answer
A. FOR EACH ROW trigger on the EMP table.
Explanation
FOR EACH ROW trigger on the updated table(emp) should be create to record each update row in the AUDIT_TABLE.
10.
Which statements are true? (Choose all that apply)
Correct Answer(s)
A. If errors occur during the compilation of a trigger, the trigger is still created.
C. If errors occur during the compilation of a trigger you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors
D. If errors occur during the compilation of a trigger you can go into SQL *Plus and query the USER_ERRORS data dictionary view to see compilation errors.
Explanation
The given answer is correct. If errors occur during the compilation of a trigger, the trigger is still created. This means that even if there are compilation errors, the trigger will still be created in the database. Additionally, you can use the SHOW ERRORS command within iSQL *Plus to see the compilation errors. This command allows you to view the specific errors that occurred during the compilation process. Another option is to go into SQL *Plus and query the USER_ERRORS data dictionary view. This view provides information on the compilation errors for all triggers in the current user's schema.
11.
Which two dictionary views track dependencies? (Choose two)
Correct Answer(s)
D. DEPTREE_TEMPTAB
E. USER_DEPENDENCIES
Explanation
The two dictionary views that track dependencies are DEPTREE_TEMPTAB and USER_DEPENDENCIES. DEPTREE_TEMPTAB is a temporary table that is created during the analysis of dependencies in the database. It stores information about the dependencies between objects. USER_DEPENDENCIES is a view that shows the dependencies between objects owned by the current user. It provides information about the objects that depend on a particular object and the objects that the particular object depends on.
12.
Given a function CALCTAX: CREATE OR REPLACE FUNCTION calctax (sal NUMBER) RETURN NUMBER IS BEGIN 1z0-147 RETURN (sal * 0.05); END; If you want to run the above function from the SQL *Plus prompt, which statement is true?
Correct Answer
E. You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX(1000);
Explanation
When you call a function from SQL*PLUS you need to assign the returned value a bind variable, and you need the EXECUTE command to execute the function
13.
What happens during the execute phase with dynamic SQL for INSERT, UPDATE, and DELETE operations?
Correct Answer
D. The SQL statement is run and the number of rows processed is returned.
Explanation
All SQL statements have to go through various stages. Some stages may be skipped.
1 Parse Every SQL statement must be parsed. Parsing the statement includes checking the statement's syntax and validating the statement, ensuring that all references to objects are correct, and ensuring that the relevant privileges to those objects exist.
2 Bind
After parsing, the Oracle server knows the meaning of the Oracle statement but still may not have enough
information to execute the statement. The Oracle server may need values for any bind variable in the
statement. The process of obtaining these values is called binding variables.
3 Execute
At this point, the Oracle server has all necessary information and resources, and the statement is executed.
4 Fetch
In the fetch stage, rows are selected and ordered (if requested by the query), and each successive fetch
retrieves another row of the result, until the last row has been fetched. You can fetch queries, but not the
DML statements.
14.
What part of a database trigger determines the number of times the trigger body executes?
Correct Answer
A. Trigger type
Explanation
The correct answer is "Trigger type". The trigger type determines the number of times the trigger body executes. Different trigger types have different behaviors when it comes to execution, such as being fired once per statement, once per row, or once per transaction. Therefore, the trigger type is crucial in determining how many times the trigger body will be executed.
15.
Examine this code: CREATE OR REPLACE FUNCTION gen_email_name(p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER) RETURN VARCHAR2is v_email_name VARCHAR2(19); BEGIN v_email_home := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) || '@Oracle.com'; UPDATE employees SET email = v_email_nameWHERE employee_id = p_id; RETURN v_email_name; END; You run this SELECT statement: SELECT first_name, last_namegen_email_name(first_name, last_name, 108) EMAIL FROM employees; What occurs?
Correct Answer
B. The statement fails because functions called from SQL expressions cannot perform DML.
Explanation
When called from a SELECT statement or a parallelized UPDATE or DELETE statement, the function cannot modify any database tables
When called from an UPDATE, or DELETE statement, the function cannot query or modify any database tables modified by that statement.
When called from a SELECT, INSERT, UPDATE, or DELETE statement, the function cannot execute SQL transaction control statements (such as COMMIT), session control statements (such as SET ROLE), or system control statements (such as ALTER SYSTEM). Also, it cannot execute DDL statements (such as CREATE) because they are followed by an automatic commit.
The function cannot call another subprogram that breaks one of the above restrictions.
16.
Which table should you query to determine when your procedure was last compiled?
Correct Answer
C. USER_OBJECTS
Explanation
A. USER_PROCEDURES lists all functions and procedures, along with associated properties. For example, ALL_PROCEDURES indicates whether or not a function is pipelined, parallel enabled or an aggregate function. If a function is pipelined or an aggregate function, the associated implementation type (if any) is
also identified. It doesn't have when the object was last complied.
B. There is nothing called USER_PROCS.
D. There is nothing called USER_PLSQL_UNITS
17.
Examine this code: CREATE OR REPLACE TRIGGER secure_emp BEFORE LOGON ON employees BEGIN IF (TO_CHAR(SYSDATE, 'DY') IN ('SAT', 'SUN')) OR (TO_CHAR(SYSDATE, 'HH24:MI') NOT BETWEEN '08:00' AND '18:00') THEN RAISE_APPLICATION_ERROR (-20500, 'You may insert into the EMPLOYEES table only during business hours.');
END IF;
END;
/
What type of trigger is it?
Correct Answer
E. This is an invalid trigger
Explanation
As you can see there is nothing called BEFORE LOGON
18.
Examine this package: CREATE OR REPLACE PACKAGE discounts IS g_id NUMBER := 7829; discount_rate NUMBER := 0.00; PROCEDURE display_price (p_price NUMBER); END discounts; / CREATE OR REPLACE PACKAGE BODY discounts IS PROCEDURE display_price (p_price NUMBER) IS BEGIN DBMS_OUTPUT.PUT_LINE('Discounted '|| TO_CHAR(p_price*NVL(discount_rate, 1))); END display_price; BEGIN discount_rate := 0.10; END discounts; / Which statement is true?
Correct Answer
D. The value of DISCOUNT_RATE is set to 0.10 when the package is invoked for the first time in a session.
Explanation
A one-time-only procedure is executed only once, when the package is first invoked within the user session
19.
Examine this code: CREATE OR REPLACE TRIGGER update_emp AFTER UPDATE ON emp BEGIN INSERT INTO audit_table (who, dated) VALUES (USER, SYSDATE); END; You issue an UPDATE command in the EMP table that results in changing 10 rows. How many rows are inserted into the AUDIT_TABLE?
Correct Answer
A. 1
Explanation
The code creates a trigger named "update_emp" that fires after an update operation on the "emp" table. The trigger inserts a single row into the "audit_table" with the current user and the current date. Therefore, regardless of the number of rows updated in the "emp" table, only one row will be inserted into the "audit_table".
20.
There is a CUSTOMER table in a schema that has a public synonym CUSTOMER and you are granted all object privileges on it. You have a procedure PROCESS_CUSTOMER that processes customer information that is in the public synonym CUSTOMER table. You have just created a new table called CUSTOMER within your schema. Which statement is true?
Correct Answer
D. . If the structure of your CUSTOMER table is the same as the public synonym CUSTOMER table then the procedure PROCESS_CUSTOMER successfully recompiles when invoked and accesses your CUSTOMER table.
Explanation
The procedure will first look in the owner of the procedure schema before looking for the public synonym.
21.
Which two statements about packages are true? (Choose two)
Correct Answer(s)
C. The package specification is required, but the package body is optional.
E. The specification and body of the package are stored separately in the database.
Explanation
The package specification is required because it contains the declaration of the package, including its public variables, constants, types, exceptions, and subprograms. On the other hand, the package body is optional because it contains the implementation of the package, including the code for the subprograms declared in the specification.
The specification and body of the package are stored separately in the database to allow for modularity and reusability. This means that the package specification can be compiled and stored in the database without the need for the package body, allowing other programs to reference and use the package's public components. The package body can then be compiled and stored separately, providing the implementation details for the package.
22.
When creating a function in SQL *Plus, you receive this message: "Warning: Function created with compilation errors." Which command can you issue to see the actual error message?
Correct Answer
C. SHOW ERRORS
Explanation
The correct answer is SHOW ERRORS. When creating a function in SQL *Plus, if there are any compilation errors, the message "Warning: Function created with compilation errors" is displayed. To see the actual error message, the command SHOW ERRORS can be issued. This command will provide detailed information about the errors that occurred during the creation of the function.
23.
Which four triggering events can cause a trigger to fire? (Choose four)
Correct Answer(s)
A. A specific error or any errors occurs
B. A database is shut down or started up.
C. A specific user or any user logs on or off.
D. A user executes a CREATE or an ALTER table statement
Explanation
The four triggering events that can cause a trigger to fire are:
1) A specific error or any errors occurs - This means that when a specific error or any error occurs, the trigger will be triggered.
2) A database is shut down or started up - When the database is shut down or started up, the trigger will be fired.
3) A specific user or any user logs on or off - Whenever a specific user or any user logs on or off, the trigger will be triggered.
4) A user executes a CREATE or an ALTER table statement - If a user executes a CREATE or ALTER table statement, the trigger will fire.
24.
Examine this procedure: CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2) IS BEGIN INSERT INTO PLAYER (ID,LAST_NAME) VALUES (V_ID, V_LAST_NAME); COMMIT; END; This procedure must invoke the APD_BAT_STAT procedure and pass a parameter. Which statement, when added to the above procedure will successfully invoke the UPD_BAT_STAT procedure?
Correct Answer
B. UPD_BAT_STAT(V_ID
Explanation
The correct statement to successfully invoke the UPD_BAT_STAT procedure is UPD_BAT_STAT(V_ID). This statement calls the UPD_BAT_STAT procedure and passes the parameter V_ID to it.
25.
Which statement about triggers is true?
Correct Answer
B. You use a database trigger to fire when an INSERT statement occurs
Explanation
A database trigger is a stored procedure that automatically executes when a specific event occurs within a database. In this case, the trigger is set to fire when an INSERT statement occurs, meaning that whenever a new record is inserted into the database, the trigger will be activated and execute the specified actions. This allows for automated processes or validations to be performed whenever new data is added to the database.
26.
You want to create a PL/SQL block of code that calculates discounts on customer orders. -This code will be invoked from several places, but only within the program unit ORDERTOTAL. What is the most appropriate location to store the code that calculates the discounts?
Correct Answer
E. A local subprogram defined within the program unit ORDERTOTAL
Explanation
A local subprogram defined within the program unit ORDERTOTAL is the most appropriate location to store the code that calculates the discounts. This ensures that the code is easily accessible and can be invoked from within the program unit ORDERTOTAL, as required. Storing it as a local subprogram also keeps the code organized and encapsulated within the program unit, making it easier to maintain and understand. Additionally, using a local subprogram allows for better code reusability within the program unit ORDERTOTAL.
27.
Which type of argument passes a value from a procedure to the calling environment?
Correct Answer
C. OUT
Explanation
The type of argument that passes a value from a procedure to the calling environment is the OUT argument. When a procedure has an OUT argument, it means that the procedure will modify the value of the argument and pass it back to the calling environment. This allows the procedure to return a value or multiple values to the caller.
28.
You are about to change the arguments of the CALC_TEAM_AVG function. Which dictionary view can you query to determine the names of the procedures and functions that invoke the CALC_TEAM_AVG function?
Correct Answer
B. USER_DEPENDENCIES
Explanation
The USER_DEPENDENCIES dictionary view can be queried to determine the names of the procedures and functions that invoke the CALC_TEAM_AVG function. This view provides information about the dependencies between database objects, including procedures, functions, and packages. By querying this view, you can identify the objects that depend on the CALC_TEAM_AVG function and determine which procedures and functions invoke it.
29.
A CALL statement inside the trigger body enables you to call ______.
Correct Answer
C. A stored procedure
Explanation
A. Package can't be called, we call a procedure inside the package.
B. We can't call a function use CALL statement because function must return a value.
D. Trigger can't be called, they are execute automatically when the trigger event occur.
30.
You need to remove the database trigger BUSINESS_HOUR. Which command do you use to remove the trigger in the SQL *Plus environment?
Correct Answer
A. DROP TRIGGER business_hour;
Explanation
The correct command to remove a trigger in the SQL *Plus environment is "DROP TRIGGER business_hour;". This command will delete the specified trigger from the database.
31.
Examine this procedure: CREATE OR REPLACE PROCEDURE INSERT_TEAM(V_ID in NUMBER, V_CITY in VARCHAR2 DEFAULT 'AUSTIN', V_NAME in VARCHAR2) IS BEGIN INSERT INTO TEAM (id, city, name) VALUES (v_id, v_city, v_name); COMMIT; END Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two)
Correct Answer(s)
B. EXECUTE INSERT_TEAM(3, V_NAME=>'LONGHORNS', V_CITY=>'AUSTIN');
C. EXECUTE INSERT_TEAM(3, 'AUSTIN','LONGHORNS');
Explanation
The procedure INSERT_TEAM has three parameters: V_ID, V_CITY, and V_NAME. The first statement EXECUTE INSERT_TEAM(3, V_NAME=>'LONGHORNS', V_CITY=>'AUSTIN') successfully invokes the procedure by passing the values 3, 'LONGHORNS', and 'AUSTIN' to the respective parameters. The second statement EXECUTE INSERT_TEAM(3, 'AUSTIN','LONGHORNS') also successfully invokes the procedure by passing the values 3, 'AUSTIN', and 'LONGHORNS' to the respective parameters.
32.
To be callable from a SQL expression, a user-defined function must do what?
Correct Answer
A. Be stored only in the database.
Explanation
A user-defined function must be stored only in the database in order to be callable from a SQL expression. This means that the function should be created and stored within the database system, rather than being defined and stored outside of it. By being stored in the database, the function becomes accessible and can be invoked within SQL queries and expressions.
33.
Which two describe a stored procedure? (Choose two)
Correct Answer(s)
B. A stored procedure is a named PL/SQL block that can accept parameters.
C. A stored procedure is a type of PL/SQL subprogram that performs an action.
Explanation
A procedure is a named PL/SQL block that can accept parameters (sometimes referred to as arguments), and be invoked. Generally speaking, you use a procedure to perform an action. A procedure has a header, a declaration section, an executable section, and an optional exception-handling section. A procedure can be compiled and stored in the database as a schema object. Procedures promote reusability and maintainability. When validated, they can be used in any number of applications. If the requirements change, only the procedure needs to be updated.
34.
Examine this code: CREATE OR REPLACE PROCEDURE add_dept ( p_name departments.department_name%TYPE DEFAULT 'unknown', p_loc departments.location_id%TYPE DEFAULT 1700) IS BEGIN INSERT INTO departments(department_id, department_name, loclation_id)VALUES(dept_seq.NEXTVAL,p_name, p_loc); END add_dept; / You created the add_dept procedure above, and you now invoke the procedure in SQL *Plus. Which four are valid invocations? (Choose four)
Correct Answer(s)
A. EXECUTE add_dept(p_loc=>2500)
B. EXECUTE add_dept('Education', 2500)
C. EXECUTE add_dept('2500', p_loc =>2500)
E. EXECUTE add_dept(p_loc=>2500, p_name=>'Education')
35.
Which three are valid ways to minimize dependency failure? (Choose three)
Correct Answer(s)
A. Querying with the SELECT * notification.
B. Declaring variables with the %TYPE attribute
D. Declaring records by using the %ROWTYPE attribute.
36.
Which two dopes the INSTEAD OF clause in a trigger identify? (Choose two)
Correct Answer(s)
A. The view associated with the trigger
C. The event associated with the trigger.
37.
Examine this package: CREATE OR REPLACE PACKAGE manage_emps IS tax_rate CONSTANT NUMBER(5,2) := .28; v_id NUMBER; PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER); PROCEDURE delete_emp; PROCEDURE update_emp;
FUNCTION calc_tax (p_sal NUMBER) RETURN NUMBER; END manage_emps; / CREATE OR REPLACE PACKAGE BODY manage_emps IS PROCEDURE update_sal (p_raise_amt NUMBER) IS BEGIN UPDATE emp SET sal = (sal * p_raise_emt) + sal WHERE empno = v_id; END; PROCEDURE insert_emp (p_deptno NUMBER, p_sal NUMBER) IS BEGIN INSERT INTO emp(empno, deptno, sal) VALYES(v_id, p_depntno, p_sal); END insert_emp; PROCEDURE delete_emp IS BEGIN DELETE FROM emp WHERE empno = v_id; END delete_emp; PROCEDURE update_emp IS v_sal NUMBER(10, 2); v_raise NUMBER(10, 2); BEGIN SELECT sal INTO v_sal FROM emp WHERE empno = v_id; IF v_sal < 500 THEN v_raise := .05; ELSIP v_sal < 1000 THEN v_raise := .07; ELSE v_raise := .04; END IF; update_sal(v_raise); END update_emp; 1z0-147
FUNCTION calc_tax (p_sal NUMBER) RETURN NUMBER IS BEGIN RETURN p_sal * tax_rate; END calc_tax; END manage_emps; / What is the name of the private procedure in this package?
Correct Answer
C. UPDATE_SAL
38.
What can you do with the DBMS_LOB package?
Correct Answer
D. Use the DBMS_LOB.FILECLOSE procedure to close the file being accessed.
Explanation
A. DBMS_LOB.WRITE is used to write to Internal LOBs.
The internal LOB is stored inside the Oracle server. A BLOB, NCLOB, or CLOB can be one of the
following:
An attribute of a user-defined type
A column in a table
A bind or host variable
A PL/SQL variable, parameter, or result
Internal LOBs can take advantage of Oracle features such as:
Concurrency mechanisms
Redo logging and recovery mechanisms
Transactions with commit or rollbacks
BFILENAME is a built-in function that initializes a BFILE column to point to an external file. Use the
BFILENAME function as part of an INSERT statement to initialize a BFILE column by associating it with a
physical file in the server file system. You can use the UPDATE statement to change the reference target of the BFILE. A BFILE can be initialized to NULL and updated later by using the BFILENAME function.
C. DBMS_LOB.FILEEXISTS function to find if the file exits on the server
39.
Examine this package: CREATE OR REPLACE PACKAGE BB_PACK APPEND Append the contents of the source LOB to the destination LOB COPY Copy all or part of the source LOB to the destination LOB ERASE Erase all or part of a LOB LOADFROMFILE Load BFILE data into an internal LOB TRIM Trim the LOB value to a specified shorter length WRITE Write data to the LOB from a specified offset GETLENGTH Get the length of the LOB value INSTR Return the matching position of the nth occurrence of the pattern in the LOB READ Read data from the LOB starting at the specified offset SUBSTR Return part of the LOB value starting at the specified offset FILECLOSE Close the file FILECLOSEALL Close all previously opened files FILEEXISTS Check if the file exists on the server FILEGETNAME Get the directory alias and file name FILEISOPEN Check if the file was opened using the input BFILE locators FILEOPEN Open a file 1z0-147 IS V_MAX_TEAM_SALARY NUMBER(12,2); PROCEDURE ADD_PLAYER(V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER); END BB_PACK; / CREATE OR REPLACE PACKAGE BODY BB_PACK IS V_PLAYER_AVG NUMBER(4,3); PROCEDURE UPD_PLAYER_STAT V_ID IN NUMBER, V_AB IN NUMBER DEFAULT 4, V_HITS IN NUMBER) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB, HITS = HITS + V_HITS WHERE PLAYER_ID = V_ID; COMMIT; VALIDATE_PLAYER_STAT(V_ID); END UPD_PLAYER_STAT; PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHAR2, V_SALARY NUMBER)
IS BEGIN INSERT INTO PLAYER(ID,LAST_NAME,SALARY) VALUES (V_ID, V_LAST_NAME, V_SALARY); UPD_PLAYER_STAT(V_ID,0,0); END ADD_PLAYER; END BB_PACK / Which statement will successfully assign .333 to the V_PLAYER_AVG variable from a procedure outside the package?
Correct Answer
D. This variable cannot be assigned a value from outside of the package.
40.
Examine this code: CREATE OR REPLACE PACKAGE comm_package 1z0-147 IS g_comm NUMBER := 10; PROCEDURE reset_comm(p_comm IN NUMBER); END comm_package; / User Jones executes the following code at 9:01am: EXECUTE comm_package.g_comm := 15 User Smith executes the following code at 9:05am: EXECUTE comm_paclage.g_comm := 20 Which statement is true?
Correct Answer
B. G_comm has a value of 15 at 9:06am for Jones
41.
Examine this code:
CREATE OR REPLACE FUNCTION gen_email_name (p_first_name VARCHAR2, p_last_name VARCHAR2, p_id NUMBER)
RETURN VARCHAR2 IS
v_email_name VARCHAR2(19); 6
BEGIN v_email_name := SUBSTR(p_first_name, 1, 1) || SUBSTR(p_last_name, 1, 7) || [email protected] .;
UPDATE employees SET email = v_email_name
WHERE employee_id = p_id; RETURN v_email_name;
END;
Which statement removes the function?
Correct Answer
D. DROP FUNCTION gen_email_name;
42.
Examine this procedure: CREATE OR REPLACE PROCEDURE UPD_BAT_STAT (V_ID IN NUMBER DEFAULT 10, V_AB IN NUMBER DEFAULT 4) IS BEGIN UPDATE PLAYER_BAT_STAT SET AT_BATS = AT_BATS + V_AB WHERE PLAYER_ID = V_ID; COMMIT; END; Which two statements will successfully invoke this procedure in SQL *Plus? (Choose two)
Correct Answer(s)
A. EXECUTE UPD_BAT_STAT;
B. EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31);
Explanation
The procedure UPD_BAT_STAT is created with two input parameters, V_ID and V_AB, with default values of 10 and 4 respectively. The procedure updates the AT_BATS column in the PLAYER_BAT_STAT table, adding the value of V_AB to the existing value, for the row where PLAYER_ID matches V_ID. It then commits the changes.
To successfully invoke this procedure in SQL *Plus, the EXECUTE command is used. The first statement, EXECUTE UPD_BAT_STAT;, will invoke the procedure with the default values for V_ID and V_AB. The second statement, EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31);, will invoke the procedure with specific values for V_ID and V_AB.
43.
Examine this code: CREATE OR REPLACE PROCEDURE audit_action
(p_who VARCHAR2) AS BEGIN INSERT INTO audit(schema_user) VALUES(p_who); END audit_action; / CREATE OR REPLACE TRIGGER watch_it AFTER LOGON ON DATABASE CALL audit_action(ora_login_user) 1z0-147 / What does this trigger do?
Correct Answer
D. The trigger invokes the procedure audit_action each time a user logs on to the database and adds the username to the audit table.
Explanation
The given trigger invokes the procedure audit_action every time a user logs on to the database and adds the username to the audit table. This means that whenever a user logs in, their username will be recorded in the audit table, creating an audit trail of user logins.
44.
Which view displays indirect dependencies, indenting each dependency?
Correct Answer
B. IDEPTREE
Explanation
The correct answer is IDEPTREE. IDEPTREE view displays indirect dependencies by indenting each dependency. This means that it shows the hierarchical relationship between dependencies, making it easier to understand the dependencies of a particular item.
45.
Examine the trigger: CREATE OR REPLACE TRIGGER Emp_count AFTER DELETE ON Emp_tab FOR EACH ROW DELCARE n INTEGER; BEGIN SELECT COUNT(*) INTO n FROM Emp_tab; DBMS_OUTPUT.PUT_LINE(' There are now ' || a || ' employees,'); END; This trigger results in an error after this SQL statement is entered: DELETE FROM Emp_tab WHERE Empno = 7499; How do you correct the error?
Correct Answer
D. Change the trigger to a statement-level trigger by removing FOR EACH ROW
Explanation
Removing the "FOR EACH ROW" clause will change the trigger to a statement-level trigger. In a statement-level trigger, the trigger fires once for each SQL statement, rather than for each row affected by the statement. This change will correct the error because the trigger is currently expecting to work with individual rows, but the DELETE statement is affecting multiple rows at once. By making the trigger a statement-level trigger, it will be able to handle the DELETE statement correctly.
46.
Which two program declarations are correct for a stored program unit? (Choose two)
Correct Answer(s)
A. CREATE OR REPLACE FUNCTION tax_amt
(p_id NUMBER)
RETURN NUMBER
C. . CREATE OR REPLACE PROCEDURE tax_amt
(p_id NUMBER, p_amount OUT NUMBER)
Explanation
The two program declarations that are correct for a stored program unit are:
1. CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER
This declaration creates a function named tax_amt that takes in a parameter p_id of type NUMBER and returns a value of type NUMBER.
2. CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER)
This declaration creates a procedure named tax_amt that takes in two parameters - p_id of type NUMBER and p_amount of type OUT NUMBER. The OUT keyword indicates that the p_amount parameter is an output parameter.
These two declarations are correct because they follow the syntax rules for creating a function and a procedure in a stored program unit.
47.
You have a row level BEFORE UPDATE trigger on the EMP table. This trigger contains a SELECT statement on the EMP table to ensure that the new salary value falls within the minimum and maximum salary for a given job title. What happens when you try to update a salary value in the EMP table?
Correct Answer
C. The trigger fails because a SELECT statement on the table being updated is not allowed.
Explanation
When you try to update a salary value in the EMP table, the trigger fails because a SELECT statement on the table being updated is not allowed. In other words, you cannot perform a SELECT operation on the same table that is being updated in a trigger.
48.
Examine this code: CREATE OR REPLACE STORED FUNCTION get_sal (p_raise_amt NUMBER, p_employee_id employees.employee_id%TYPE) RETURN NUMBER 1z0-147 IS v_salary NUMBER; v_raise NUMBER(8,2); BEGIN SELECT salary INTO v_salary FROM employees WHERE employee_id = p_employee_id; v_raise := p_raise_amt * v_salary;RETURN v_raise; END; Which statement is true?
Correct Answer
E. This statement fails.
Explanation
The given code is incorrect and will fail. The function declaration is missing the keyword "FUNCTION" after the return type declaration. The correct syntax should be "CREATE OR REPLACE FUNCTION get_sal (p_raise_amt NUMBER, p_employee_id employees.employee_id%TYPE) RETURN NUMBER IS". Without this keyword, the code will fail to compile.
49.
You need to disable all triggers on the EMPLOYEES table. Which command accomplishes this?
Correct Answer
D. ALTER TABLE employees DISABLE ALL TRIGGERS;
Explanation
The correct answer is "ALTER TABLE employees DISABLE ALL TRIGGERS;". This command specifically targets the EMPLOYEES table and disables all triggers associated with it. The other options are incorrect because they either do not target the table or do not disable all triggers.
50.
An internal LOB is _____.
Correct Answer
C. Stored in the database.
Explanation
An internal LOB refers to a Large Object that is stored within the database. It can be any type of data such as text, images, or videos that are too large to be stored in a regular table column. Storing the LOB in the database allows for efficient management and retrieval of the data, as it is directly accessible through the database system.