Listing the content of an object storage bucket in OCI from an autonomous database with PL/SQL code

This post explains a specific use case, but it can be used for calling whatever existing OCI REST API fron the database.


DBMS_CLOUD provides all you need to handle requests to OCI REST API’s.

What you need

Create and grab a private and public keys and also grab your tenancy ocid, get help from here

Create a user in OCI, grab the user ocid

Add the public key previously created to the user and grab the fingerprint

Give permissions to user

Create a group and add the user to it

Create a policy with the following statements:

allow group <yourgroup> to manage buckets in compartment <loquesea>
allow group <yourgroup> to manage objects in compartment <loquesea>

Create a credential

credential_name => 'YOURCRED',
user_ocid => <userocid>,
tenancy_ocid => <tenancyocid>,
private_key => <privatekey>,
fingerprint => <fingerprint>);

Execute the REST call

resp := DBMS_CLOUD.send_request(
credential_name => 'YOURCRED',
uri => '<namespace>/b/<bucketnamwe>/o',
method => 'GET');
dbms_output.put_line('result: ' || DBMS_CLOUD.get_response_text(resp) );

So far, so good:

That’s all, hope it helps! 🙂


Leave a Reply to Marcelo Cancel reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.