Explore foundational concepts of integrating PL/SQL with APIs and external procedures, enhancing database functionality and connectivity. This quiz assesses your understanding of secure communication, external routine setup, parameter passing, and best practices relevant to PL/SQL-based integrations.
Which PL/SQL package is commonly used to send HTTP requests to external APIs, for instance, retrieving data from a web service?
Explanation: UTL_HTTP is designed for making HTTP requests from PL/SQL code, enabling interaction with external APIs and web services. DBMS_SCHEDULER is used for job scheduling, not web requests. DBMS_PIPE is for inter-session communication within the database. UTL_SMTP supports sending emails through SMTP servers, not general API calls.
When integrating an external C routine with PL/SQL, which mechanism allows PL/SQL to invoke that external code?
Explanation: A Library object serves as the link between PL/SQL and an external routine, such as a C procedure. Indexes are used for database performance optimization and not for integration. Sequences generate numeric values, and Cursors handle database result sets. Only Library directly connects to compiled external code.
Which security measure is necessary for PL/SQL to access an external web API securely over HTTPS?
Explanation: Configuring an Access Control List (ACL) is required to authorize external network access, ensuring secure and permitted HTTP or HTTPS requests from within the database. Creating a synonym is for naming convenience, not security. Rebuilding indexes is unrelated to network operations. Pipelined functions allow dynamic result sets, not secure web connections.
Which parameter type allows data to be sent to and modified by an external procedure, for example, a C function called from PL/SQL?
Explanation: IN OUT parameters allow information to be passed to an external routine and for changes to be returned. CONSTANT is not a parameter mode and defines unmodifiable variables. RETURN is used for function return types. STATIC is not a valid PL/SQL parameter mode verb.
What is the main use of the UTL_FILE PL/SQL package, for example, when exchanging data with other systems via flat files?
Explanation: UTL_FILE is intended for reading from and writing to operating system files, aiding integration with files exchanged between systems. It is not designed for user creation, backup management, or encryption. Those tasks rely on other packages or tools.
Which PL/SQL construct is used to declare the interface to an external procedure, such as a C library routine, within a PL/SQL package?
Explanation: A call specification is a special declaration that tells PL/SQL how to invoke an external procedure, such as one written in C. Exception blocks handle errors, triggers define actions on events, and ref cursors deal with complex result sets, none of which link external routines.
When calling a secure REST API from a PL/SQL procedure using UTL_HTTP, which step is typically required for API authentication?
Explanation: APIs almost always require credentials to be sent in HTTP headers, such as for tokens or keys, to authenticate requests. Table size changes, privilege grants, and TABLE partitioning are unrelated to HTTP authentication or API integration.
What is a best practice for handling errors when consuming an external API in PL/SQL, for example, if the API endpoint is unavailable?
Explanation: Exception handling blocks enable PL/SQL to gracefully manage errors like unreachable endpoints or bad responses, improving reliability. Dropping schemas, disabling triggers, and incrementing sequences do not address error handling for API calls.
What is likely to happen if a user attempts to access an external network resource through UTL_HTTP without the required privileges or ACL setup?
Explanation: Without the necessary privileges or ACL configuration, UTL_HTTP access raises a permission-related error to block unauthorized network access. Insertion of a row, user creation, or log archiving are unrelated and would not occur as a direct result of this action.
Which feature does DBMS_CLOUD offer that assists in integrating with external data sources or APIs, for example, loading data from cloud storage?
Explanation: DBMS_CLOUD enables use of external tables to work with data stored outside the database, such as cloud storage or remote APIs. Index rebuilding, sequence reseeding, and audit policy tasks are not directly related to integrating with external data sources.