databases Online Quiz - 233
Description: databases Online Quiz - 233 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: databases |
The following statement will raise an exception on which line? select dept_name, avg(all salary) ,count() “number of employees” from emp , dept where deptno = dept_no and count() > 5 group by dept_name order by 2 desc;
-
select dept_name, avg(all salary), count(*) “number of employees"
-
where deptno = dept_no
-
and count(*) > 5
-
group by dept_name
-
order by 2 desc;
Which two program declarations are correct for a stored program unit? (Choose two)
-
a) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER
-
b) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER
-
c) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER)
-
d) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2)
-
e) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2))
AI Explanation
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) a) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER - This option is correct because it declares a stored function named "tax_amt" that takes a parameter "p_id" of type NUMBER and returns a value of type NUMBER.
Option B) b) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER) RETURN NUMBER - This option is incorrect because it declares a stored procedure, not a function. The keyword "RETURN NUMBER" is not applicable for a procedure declaration.
Option C) c) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER) - This option is correct because it declares a stored procedure named "tax_amt" that takes two parameters "p_id" and "p_amount". The "p_amount" parameter is an OUT parameter, which means it will be used to return a value.
Option D) d) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER(10,2) - This option is incorrect because it declares a stored function with a return type of NUMBER(10,2), which is not valid syntax. The return type should be just NUMBER without any precision or scale specified.
Option E) e) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER(10, 2)) - This option is incorrect because it declares a stored procedure with an OUT parameter "p_amount" of type NUMBER(10, 2), which is not valid syntax. The parameter type should be just NUMBER without any precision or scale specified.
The correct answers are A) CREATE OR REPLACE FUNCTION tax_amt (p_id NUMBER) RETURN NUMBER and C) CREATE OR REPLACE PROCEDURE tax_amt (p_id NUMBER, p_amount OUT NUMBER). These options correctly declare a stored function and a stored procedure, respectively.
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)
-
a) EXECUTE UPD_BAT_STAT;
-
b) EXECUTE UPD_BAT_STAT(V_AB=>10, V_ID=>31);
-
c) EXECUTE UPD_BAT_STAT(31, 'FOUR', 'TWO');
-
d) UPD_BAT_STAT(V_AB=>10, V_ID=>31);
-
e) RUN UPD_BAT_STAT;
- Examine this code: CREATE OR REPLACE PACKAGE comm_package 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?
-
a) g_comm has a value of 15 at 9:06am for Smith.
-
b) g_comm has a value of 15 at 9:06am for Jones.
-
c) g_comm has a value of 20 at 9:06am for both Jones and Smith.
-
d) g_comm has a value of 15 at 9:03 am for both Jones and Smith.
-
e) g_comm has a value of 10 at 9:06am for both Jones and Smith.
AI Explanation
To answer this question, let's analyze the provided code and the sequence of events:
The code defines a package named "comm_package" with a global variable "g_comm" initialized to 10 and a procedure "reset_comm" that takes a parameter "p_comm" of type NUMBER.
User Jones executes the following code at 9:01am:
EXECUTE comm_package.g_comm := 15;
This code attempts to assign a new value of 15 to the global variable "g_comm".
User Smith executes the following code at 9:05am:
EXECUTE comm_package.g_comm := 20;
This code also attempts to assign a new value of 20 to the global variable "g_comm".
Now let's evaluate each option to determine which one is true:
Option A) g_comm has a value of 15 at 9:06am for Smith. This option is incorrect because Smith's code executed at 9:05am, not 9:06am.
Option B) g_comm has a value of 15 at 9:06am for Jones. This option is correct. Since Jones executed the code at 9:01am to assign a value of 15 to g_comm, the value of g_comm will be 15 at 9:06am for Jones.
Option C) g_comm has a value of 20 at 9:06am for both Jones and Smith. This option is incorrect. Since Smith executed the code at 9:05am to assign a value of 20 to g_comm, the value of g_comm will be 20 at 9:06am for Smith, but Jones assigned a value of 15 to g_comm earlier, so it will not be 20 for Jones at 9:06am.
Option D) g_comm has a value of 15 at 9:03am for both Jones and Smith. This option is incorrect. Jones executed the code at 9:01am, not 9:03am.
Option E) g_comm has a value of 10 at 9:06am for both Jones and Smith. This option is incorrect. Both Jones and Smith executed code to assign different values to g_comm, so the value will not be 10 for either of them at 9:06am.
Therefore, the correct answer is: B) g_comm has a value of 15 at 9:06am for Jones.
Which two describe a stored procedure? (Choose two)
-
a) A stored procedure is typically written in SQL.
-
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.
-
d) A stored procedure has three parts: the specification, the body, and the exception handler part.
-
e) The executable section of a stored procedure contains statements that assigns values, control execution, and return values to the calling environment.
AI Explanation
To answer this question, you need to understand what a stored procedure is. Let's go through each option to understand why it is correct or incorrect:
Option A) A stored procedure is typically written in SQL - This option is incorrect because a stored procedure can be written in various programming languages, not just SQL.
Option B) A stored procedure is a named PL/SQL block that can accept parameters - This option is correct. A stored procedure is a named block of code that can be executed in a database. It can accept parameters, which allows for flexibility and reusability.
Option C) A stored procedure is a type of PL/SQL subprogram that performs an action - This option is correct. A stored procedure is a type of subprogram in a database that performs a specific action or set of actions.
Option D) A stored procedure has three parts: the specification, the body, and the exception handler part - This option is incorrect. While a stored procedure can have multiple parts, such as a specification, body, and exception handler, it is not limited to just these three parts.
Option E) The executable section of a stored procedure contains statements that assigns values, control execution, and return values to the calling environment - This option is incorrect. While the executable section of a stored procedure can contain statements that assign values, control execution, and return values, it is not the only section of a stored procedure.
The correct answers are B) A stored procedure is a named PL/SQL block that can accept parameters and C) A stored procedure is a type of PL/SQL subprogram that performs an action. These options accurately describe the characteristics of a stored procedure.
Which type of argument passes a value from a procedure to the calling environment?
-
a) VARCHAR2
-
b) BOOLEAN
-
c) OUT
-
d) IN
To solve this question, the user needs to be familiar with the different types of arguments that can be passed between a procedure and the calling environment.
A. VARCHAR2 is a data type used to store character strings in Oracle.
B. BOOLEAN is a data type used to store logical values (TRUE or FALSE) in Oracle.
C. OUT is a parameter mode that is used to pass values from a procedure to the calling environment.
D. IN is a parameter mode that is used to pass values from the calling environment to a procedure.
Therefore, the correct answer is:
The Answer is: C
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?
-
a) SHOW FUNCTION_ERROR
-
b) SHOW USER_ERRORS
-
c) SHOW ERRORS
-
d) SHOW ALL_ERRORS
To solve this question, the user needs to know how to check for the errors in an SQL function.
The correct answer is:
C. SHOW ERRORS
Explanation:
When a function is created with compilation errors, the SHOW ERRORS command can be issued to see the actual error message. This command displays the compilation errors of the last CREATE or REPLACE FUNCTION or PACKAGE statement that was executed in the current session. Using this command can help identify and fix any syntax errors or other issues with the function code.
Option A is incorrect because there is no SHOW FUNCTION_ERROR command in SQL *Plus.
Option B is incorrect because SHOW USER_ERRORS is not a valid command in SQL *Plus.
Option D is incorrect because SHOW ALL_ERRORS is not a valid command in SQL *Plus.
Given a function CALCTAX : CREATE OR REPLACE FUNCTION calc tax (sal NUMBER) RETURN NUMBER IS BEGIN RETURN (sal * 0.05); END; If you want to run the above function from the SQL *Plus prompt, which statement is true?
-
a) You need to execute the command CALCTAX(1000); .
-
b) You need to execute the command EXECUTE FUNCTION calc tax; .
-
c) You need to create a SQL *Plus environment variable X and issue the command :X := CALCTAX(1000); .
-
d) You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX;
-
e) You need to create a SQL *Plus environment variable X and issue the command EXECUTE :X := CALCTAX(1000);
AI Explanation
To run the given function CALCTAX
from the SQL *Plus prompt, you need to create a SQL *Plus environment variable X
and issue the command EXECUTE :X := CALCTAX(1000);
.
Let's go through each option to understand why it is correct or incorrect:
Option A) You need to execute the command CALCTAX(1000);
- This option is incorrect because executing the function directly without assigning the result to a variable will not give you the desired output.
Option B) You need to execute the command EXECUTE FUNCTION calc tax;
- This option is incorrect because the syntax of the EXECUTE
command is incorrect. It should be EXECUTE ();
.
Option C) You need to create a SQL *Plus environment variable X
and issue the command :X := CALCTAX(1000);
- This option is incorrect because the syntax of assigning a value to the variable X
is incorrect. It should be X := ;
instead of :X := ;
.
Option D) You need to create a SQL *Plus environment variable X
and issue the command EXECUTE :X := CALCTAX;
- This option is incorrect because the function CALCTAX
requires an input argument sal
, which is missing in the EXECUTE
command.
Option E) You need to create a SQL *Plus environment variable X
and issue the command EXECUTE :X := CALCTAX(1000);
- This option is correct because it correctly creates a SQL *Plus environment variable X
and assigns the result of the function CALCTAX(1000)
to X
using the EXECUTE
command.
The correct answer is option E.
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)
-
a) add_dept;
-
b) add_dept( .Accounting .);
-
c) add_dept(, .New York .);
-
d) add_dept(p_location=> .New York .);
AI Explanation
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) add_dept;
- This option is a valid call to the add_dept
procedure. It does not provide any arguments, so the procedure will use the default values for p_dept_name
and p_location
.
Option B) add_dept( .Accounting .);
- This option is a valid call to the add_dept
procedure. It provides the argument p_dept_name
with the value "Accounting" and uses the default value for p_location
.
Option C) add_dept(, .New York .);
- This option is an invalid call to the add_dept
procedure. It is missing the p_dept_name
argument and includes an extra comma. The correct syntax should be add_dept('New York')
.
Option D) add_dept(p_location=> .New York .);
- This option is a valid call to the add_dept
procedure. It provides the argument p_location
with the value "New York" and uses the default value for p_dept_name
.
Therefore, the three valid calls to the add_dept
procedure are:
A) add_dept;
B) add_dept('Accounting');
D) add_dept(p_location=>'New York');
The correct answer is options A, B, and D.
-
a) Local variables.
-
b) Arguments.
-
c) Boolean variables.
-
d) Substitution variables.
When creating stored procedures and functions, the option that allows you to transfer values to and from the calling environment is:
B. Arguments.
Arguments, also known as parameters, are variables that are defined within a stored procedure or function and can be used to receive values from the calling environment. These values can be passed to the procedure or function when it is executed, and the procedure or function can also return values back to the calling environment using these arguments.
Option A, local variables, are variables defined within the scope of the procedure or function and are not used for transferring values to and from the calling environment.
Option C, boolean variables, are variables that can hold a true or false value and are not specifically designed for transferring values to and from the calling environment.
Option D, substitution variables, are variables used in SQL*Plus and Oracle SQL Developer tools and are not used for passing values to and from the calling environment in stored procedures or functions.
So, the correct answer is B. Arguments.
Under which situation do you create a server side procedure?
-
a) When the procedure contains no SQL statements.
-
b) When the procedure contains no PL/SQL commands.
-
c) When the procedure needs to be used by many client applications accessing several remote databases.
-
d) When the procedure needs to be used by many users accessing the same schema objects on a local database.
AI Explanation
To answer this question, you need to understand the concept of server-side procedures. Let's go through each option to understand why it is correct or incorrect:
Option A) When the procedure contains no SQL statements. This option is incorrect because server-side procedures often contain SQL statements to interact with the database.
Option B) When the procedure contains no PL/SQL commands. This option is incorrect because PL/SQL is a programming language used for writing server-side procedures. Therefore, a server-side procedure would typically contain PL/SQL commands.
Option C) When the procedure needs to be used by many client applications accessing several remote databases. This option is incorrect because the situation described here relates to a distributed database environment, where multiple remote databases are accessed by client applications. In this case, you would create a distributed database architecture, not necessarily a server-side procedure.
Option D) When the procedure needs to be used by many users accessing the same schema objects on a local database. This option is correct because a server-side procedure is typically created when multiple users need to access the same schema objects on a local database. In this scenario, a server-side procedure provides a centralized and efficient way to manage and execute common tasks or operations.
The correct answer is Option D. This option is correct because it accurately describes the situation where you would create a server-side procedure.
The PROCEDURE_ADD_PRODUCT is defined within a package specifications as follows: PROCEDURE_ADD_PRODUCT (P_PRODNO NUMBER,P_PRODNAME VARCHER2); Which procedure declaration can’t be added to package specifications?
-
a) PROCEDURE add_product (p_order_date DATE);
-
b) PROCEDURE add_product (p_name VARCHER2, P_ORDERED DATE);
-
c) PROCEDURE add_product (p_prodname VARCHER2, P_PRISE NUMBER);
-
d) PROCEDURE add_product (p_prize NUMBER, P_DESCRIPTION VARCHER2);
AI Explanation
To determine which procedure declaration can't be added to the package specifications, let's go through each option:
Option A) PROCEDURE add_product (p_order_date DATE); This option is a valid procedure declaration. It takes a parameter "p_order_date" of type DATE.
Option B) PROCEDURE add_product (p_name VARCHER2, P_ORDERED DATE); This option is a valid procedure declaration. It takes two parameters: "p_name" of type VARCHAR2 and "p_ordered" of type DATE.
Option C) PROCEDURE add_product (p_prodname VARCHER2, P_PRISE NUMBER); This option is a valid procedure declaration. It takes two parameters: "p_prodname" of type VARCHAR2 and "p_prise" of type NUMBER.
Option D) PROCEDURE add_product (p_prize NUMBER, P_DESCRIPTION VARCHER2); This option is not a valid procedure declaration. There is a typo in the parameter declaration. Instead of "VARCHAR2", it is written as "VARCHER2".
Therefore, the correct answer is D) PROCEDURE add_product (p_prize NUMBER, P_DESCRIPTION VARCHER2), as it contains an incorrect parameter declaration.
Examine this procedure: CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHER2(30)) IS BEGIN INSERT INTO PLAYER(ID, LAST_NAME) VALUES(V_ID, V_LAST_NAME); COMMIT; END; Why does this command fail when executed?
-
a) When declaring arguments length is not allowed.
-
b) When declaring arguments each argument must have a mode specified.
-
c) When declaring arguments each argument must have a length specified.
-
d) When declaring a VARCHAR2 argument it must be specified.
AI Explanation
To answer this question, let's examine each option to understand why it is correct or incorrect:
Option A) When declaring arguments length is not allowed - This option is incorrect because the length is allowed when declaring arguments in a procedure.
Option B) When declaring arguments each argument must have a mode specified - This option is incorrect because it is a valid requirement to specify the mode (IN, OUT, or IN OUT) for each argument when declaring a procedure. However, the given procedure does not specify the mode for the arguments, but this is not the reason why the command fails.
Option C) When declaring arguments each argument must have a length specified - This option is incorrect because it is not necessary to specify the length for every argument when declaring a procedure. The length is only required for certain data types, such as VARCHAR2 or RAW.
Option D) When declaring a VARCHAR2 argument it must be specified - This option is incorrect because it is not necessary to specify the VARCHAR2 data type when declaring a procedure. The data type can be specified as VARCHAR2 or VARCHAR, and both are valid.
The correct answer is A) When declaring arguments length is not allowed. This option is correct because in the given procedure, the V_LAST_NAME parameter is missing the length specification for the VARCHAR2 data type. The correct declaration should be V_LAST_NAME VARCHAR2(30) to specify the length.
Therefore, the command fails because the declaration of the V_LAST_NAME parameter is missing the length specification.
The ADD_PLAYER, UPD_PLAYER_STAT and UPD_PITCHER_STAT procedures are grouped together in a package. A variable must be shared among only these procedures. Where should you declare this variable?
-
a) In the package body.
-
b) In the data base triggers.
-
c) In the package specification.
-
d) In the procedures declare section using the exact name in each.
AI Explanation
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) In the package body - This option is correct because declaring the variable in the package body ensures that it is shared among only the procedures contained within the package. The package body is where the implementation details of the package are defined, and any variables declared in the package body are accessible to all the procedures within the package.
Option B) In the database triggers - This option is incorrect because database triggers are not within the scope of the package. Triggers are separate database objects that are used to automatically execute code in response to specific events, such as insert, update, or delete operations on a table. Variables declared in triggers are not accessible within the package procedures.
Option C) In the package specification - This option is incorrect because the package specification defines the interface of the package, including the public procedures, functions, and types that can be accessed from outside the package. Variables declared in the package specification are accessible to other programs or packages that use the package, but not specifically to the procedures within the package.
Option D) In the procedures declare section using the exact name in each - This option is incorrect because declaring the same variable with the exact name in each procedure would create separate and independent variables within each procedure. These variables would not be shared among the procedures and would not serve the purpose of having a variable shared among only these procedures.
The correct answer is A) In the package body. This option is correct because declaring the variable in the package body ensures that it is shared among only the procedures contained within the package.
When using a packaged function in a query, what is true?
-
a) The COMMIT and ROLLBACK commands are allowed in the packaged function.
-
b) You can not use packaged functions in a query statement.
-
c) The packaged function cannot execute an INSERT, UPDATE, or DELETE statement against the table that is being queried.
-
d) The packaged function can execute and INSERT, UPDATE, or DELETE statement against the table that is being queried if it is used in a subquery.
-
e) The packaged function can execute an INSERT, UPDATEM or DELETE statement against the table that is being queried if the pragma RESTRICT REFERENCE is used.
AI Explanation
To answer this question, you need to understand the concept of using packaged functions in a query.
Option A) The COMMIT and ROLLBACK commands are allowed in the packaged function - This option is incorrect. The COMMIT and ROLLBACK commands are not allowed in a packaged function. These commands are used to control transactional behavior, and they should be executed outside the packaged function.
Option B) You cannot use packaged functions in a query statement - This option is incorrect. Packaged functions can be used in a query statement.
Option C) The packaged function cannot execute an INSERT, UPDATE, or DELETE statement against the table that is being queried - This option is correct. Packaged functions are not allowed to execute INSERT, UPDATE, or DELETE statements against the table that is being queried. They are typically used for data retrieval or computation purposes.
Option D) The packaged function can execute an INSERT, UPDATE, or DELETE statement against the table that is being queried if it is used in a subquery - This option is incorrect. The packaged function cannot execute INSERT, UPDATE, or DELETE statements against the table that is being queried, regardless of whether it is used in a subquery or not.
Option E) The packaged function can execute an INSERT, UPDATE, or DELETE statement against the table that is being queried if the pragma RESTRICT REFERENCE is used - This option is incorrect. The pragma RESTRICT REFERENCE is used to restrict the use of certain database objects within a package. It does not allow the packaged function to execute INSERT, UPDATE, or DELETE statements against the table that is being queried.
Therefore, the correct answer is Option C. The packaged function cannot execute an INSERT, UPDATE, or DELETE statement against the table that is being queried.
All users currently have the INSERT privileges on the PLAYER table. You want only your users to insert into this table using the ADD_PLAYER procedure. Which two actions must you take? (Choose two)
-
a) GRANT SELECT ON ADD_PLAYER TO PUBLIC;
-
b) GRANT EXECUTE ON ADD_PLAYER TO PUBLIC;
-
c) GRANT INSERT ON PLAYER TO PUBLIC;
-
d) GRANT EXECUTE, INSERT ON ADD_PLAYER TO PUBLIC;
-
e) REVOKE INSERT ON PLAYER FROM PUBLIC;
- Examine this package body: CREATE OR REPLACE PACKAGE BODY forward_pack IS V_sum NUMBER; - 44 - PROCEDURE calc_ord(. . . ); PROCEDURE generate_summary(. . . ) IS BEGIN Calc_ord(. . . ); . . . END calc_ord; END forward_pack; / Which construct has a forward declaration?
-
a) V_SUM
-
b) CALC_ORD.
-
c) FORWARD_PACK
-
d) GENERATE_SUMMARY.
AI Explanation
To answer this question, let's go through each option to understand which construct has a forward declaration:
Option A) V_SUM - This option does not have a forward declaration. V_SUM is a variable declaration and does not require a forward declaration.
Option B) CALC_ORD - This option has a forward declaration. The PROCEDURE calc_ord is declared in the package body, but its full implementation is not provided in the given code. This indicates that there is a forward declaration for the calc_ord procedure.
Option C) FORWARD_PACK - This option does not have a forward declaration. FORWARD_PACK is the name of the package body itself and does not require a forward declaration.
Option D) GENERATE_SUMMARY - This option does not have a forward declaration. GENERATE_SUMMARY is a procedure declared and implemented within the package body, so it does not need a forward declaration.
The correct answer is Option B) CALC_ORD. This option has a forward declaration because the PROCEDURE calc_ord is declared without its full implementation in the given code.
Examine this procedure: CREATE OR REPLACE PROCEDURE ADD_PLAYER (V_ID IN NUMBER, V_LAST_NAME VARCHER2(30)) IS BEGIN INSERT INTO PLAYER(ID, LAST_NAME) VALUES(V_ID, V_LAST_NAME); COMMIT; END; Why does this command fail when executed?
-
a) When declaring arguments length is not allowed.
-
b) When declaring arguments each argument must have a mode specified.
-
c) When declaring arguments each argument must have a length specified.
-
d) When declaring a VARCHAR2 argument it must be specified.
AI Explanation
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) When declaring arguments length is not allowed - This option is incorrect because in the given procedure, the length is specified for the VARCHAR2 argument V_LAST_NAME.
Option B) When declaring arguments each argument must have a mode specified - This option is incorrect because in the given procedure, the mode for each argument is not specified. However, the absence of a mode specification does not cause the command to fail.
Option C) When declaring arguments each argument must have a length specified - This option is incorrect because in the given procedure, the length is specified for the VARCHAR2 argument V_LAST_NAME.
Option D) When declaring a VARCHAR2 argument it must be specified - This option is incorrect because in the given procedure, the VARCHAR2 argument V_LAST_NAME is specified.
The correct answer is A) When declaring arguments length is not allowed. This option is correct because in the given procedure, the length is specified for the VARCHAR2 argument V_LAST_NAME, which is not allowed. The correct syntax for declaring a VARCHAR2 argument should be VARCHAR2(30).
Therefore, the command fails when executed due to the incorrect length specification for the VARCHAR2 argument.
How do you handle an Exception?
-
a) Trap it with a Handler
-
b) Propagate it to the Calling Environment
-
c) a & then b
-
d) b & then a
This statement fails when executed: CREATE OR REPLACE TRI GGER CALC_TEAM_AVG AFTER I NSERT ON PLAYER BEGIN INSERT INTO PLAYER_BATSTAT ( PLAYER_I D, SEASON_YEAR, AT_BATS, HI TS) VALUES ( : NEW. I D, 1 997, 0, 0) ; END; To which type must you convert the trigger to correct the error?
-
a) Row
-
b) Statement
-
c) ORACLE FORM trigger
-
d) Before
AI Explanation
To answer this question, we need to understand the different types of triggers in Oracle.
Option A) Row - This option is correct because the given trigger is an "AFTER INSERT" trigger, which is a row-level trigger. Row-level triggers fire once for each row that is affected by the triggering event. In this case, the trigger is fired after each row is inserted into the PLAYER table.
Option B) Statement - This option is incorrect because statement-level triggers fire once for each triggering event, regardless of the number of rows affected. Statement-level triggers are used with bulk operations or when you want to perform an action based on the entire set of affected rows.
Option C) ORACLE FORM trigger - This option is incorrect because Oracle Form triggers are specific to Oracle Forms, which is a development tool for creating GUI applications. Form triggers are not applicable in this scenario.
Option D) Before - This option is incorrect because "BEFORE INSERT" triggers are executed before the insert operation is performed. The given trigger is an "AFTER INSERT" trigger.
The correct answer is A) Row. This option is correct because the given trigger should be converted to a row-level trigger to fix the error.