Stored program objects: which statement accurately describes a database procedure?

Difficulty: Easy

Correct Answer: They include procedural and SQL statements.

Explanation:


Introduction / Context:
Procedures (stored procedures) and functions are core programmable objects in DBMSs. They encapsulate business logic close to the data and are invoked by applications, jobs, or triggers. This question targets the essential characteristics of a procedure.



Given Data / Assumptions:

  • Most RDBMSs support procedural languages (PL/pgSQL, T-SQL, PL/SQL) for stored code.
  • Procedures can contain both control-flow and SQL statements.
  • Naming rules require unique identifiers within a given namespace/schema.


Concept / Approach:
A procedure is a stored program consisting of procedural logic (IF, CASE, loops) and embedded SQL (SELECT, INSERT, UPDATE, DELETE). It is compiled/stored in the database catalog and invoked by name, often with parameters.



Step-by-Step Solution:

Assess whether creation uses SQL: CREATE PROCEDURE is standard SQL syntax in many systems.Check uniqueness: object names must be unique within their schema/namespace.Distinguish procedure vs. function: functions return a value; procedures may not.Thus, the accurate statement is that procedures include procedural and SQL statements.


Verification / Alternative check:
Vendor docs show CREATE PROCEDURE with procedural control structures and embedded SQL. Functions often have RETURN types; procedures typically do not (though dialects vary).



Why Other Options Are Wrong:
Not created with SQL is false; CREATE PROCEDURE is SQL.
No unique name is false; uniqueness is required within scope.
Same as a function is false; functions and procedures differ in invocation and return semantics.



Common Pitfalls:
Assuming procedures must return values (that is functions), and overlooking schema-qualified naming.



Final Answer:
They include procedural and SQL statements.

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion