John has created a procedure named SALARY_CALC. Which SQL query allow him to view text of procedure?

  1. SELECT text FROM user_source WHERE name = 'SALARY_CALC';

  2. SELECT * FROM user_source WHERE name='SALARY_CALC';

  3. SELECT * FROM user_objects WHERE object_name='SALARY_CALC';

  4. SELECT * FROM user_procedures WHERE object_name='SALARY_CALC';

  5. SELECT text FROM user_source WHERE name='SALARY_CALC' and owner='JOHN'


Correct Option: A
Explanation:

The correct SQL query to view the text of the procedure named SALARY_CALC, created by John, would be:

A. SELECT text FROM user_source WHERE name = 'SALARY_CALC';

This query selects the text column from the user_source table where the name is equal to 'SALARY_CALC'. This will retrieve the text of the procedure.

The other options are incorrect because:

B. SELECT * FROM user_source WHERE name='SALARY_CALC'; This query selects all columns from the user_source table where the name is equal to 'SALARY_CALC'. It will retrieve all details of the procedure, not just the text.

C. SELECT * FROM user_objects WHERE object_name='SALARY_CALC'; This query selects all columns from the user_objects table where the object_name is equal to 'SALARY_CALC'. This will retrieve details about the object, but not the text of the procedure.

D. SELECT * FROM user_procedures WHERE object_name='SALARY_CALC'; This query selects all columns from the user_procedures table where the object_name is equal to 'SALARY_CALC'. This will retrieve details about the procedure, but not the text of the procedure.

E. SELECT text FROM user_source WHERE name='SALARY_CALC' and owner='JOHN'; This query selects the text column from the user_source table where the name is equal to 'SALARY_CALC' and the owner is equal to 'JOHN'. This query assumes that John is the owner of the procedure. If John is indeed the owner, this query will work. However, if John is not the owner, it will not retrieve the text of the procedure.

So, the correct answer is option A.

Find more quizzes: