DB@AWS · SELECT AI · AMAZON BEDROCK

Bringing AI to Your Data on Oracle Database@AWS: Oracle Select AI with Amazon Bedrock

Share on LinkedIn ↗

You’ve provisioned the database. What’s next? Let’s bring AI to the data.

With Oracle Autonomous Database running on Oracle Database@AWS, the next step is to connect it to Amazon Bedrock and ask questions in plain English.

This walkthrough shows how to connect Oracle Select AI to Amazon Bedrock, explore invoice data, and add business context through table and column comments. Follow the steps to generate SQL, execute queries, explain their logic, and describe results in plain English.

What will you achieve?

Ask a business question in plain English, inspect the generated SQL, and verify the result. First establish the correct overdue-invoice answer with reference SQL, then repeat the question with business comments enabled.

Autonomous Database calls Amazon Bedrock over a private connection. SQL Developer provides the interface for the examples.

Select AI illustrated overview

Before you begin

Use an existing Autonomous Database private endpoint, an application VPC connected through ODB peering, and a Systems Manager managed EC2 client. Keep the existing wallet and TLS settings for SQL Developer. You also need permission to configure the Bedrock endpoint, scoped IAM access, database host ACLs and the associated VCN’s private DNS.

Component Name or setting used
Database connection ADBSLAB01 as ADMIN
Table ADMIN.AR_INVOICES_DEMO
Region us-east-1
Model Amazon Nova Lite, amazon.nova-lite-v1:0
AI profile BEDROCK_BASELINE
Oracle credential AWS_BEDROCK_CRED
Bedrock endpoint odb-select-ai-bedrock-runtime
Conversation false

Use your deployment’s identifiers and private addresses in place of the example names. Bedrock inference and interface endpoints incur charges.

1. Start EC2 and the database and connect from Windows

SQL Developer connects to Autonomous Database through an EC2 client and an AWS Systems Manager port-forwarding tunnel.

For the infrastructure walkthrough, see Building Oracle Database@AWS with Terraform and GitHub Actions. This article continues from that running lab.

Open the database tunnel from Windows

Start the existing EC2 client and wait for both Running and Systems Manager Online. Start Autonomous Database and wait for Available. If either is already running, continue without restarting it.

Create adbs-tunnel.json with your actual database private endpoint IP:

{
  "host": ["YOUR_DATABASE_PRIVATE_ENDPOINT_IP"],
  "portNumber": ["1522"],
  "localPortNumber": ["1522"]
}

Run this in Windows PowerShell using an authenticated AWS profile:

aws ssm start-session --target YOUR_EC2_INSTANCE_ID --profile YOUR_PROFILE --region us-east-1 --document-name AWS-StartPortForwardingSessionToRemoteHost --parameters file://adbs-tunnel.json
01 tunnel
The SSM tunnel opens local port 1522 for SQL Developer. Keep this terminal session open while using the connection.

In SQL Developer, connect using the saved wallet and TLS configuration and verify the session:

SELECT SYS_CONTEXT('USERENV', 'SESSION_USER') AS session_user,
       SYSTIMESTAMP AS database_time
FROM dual;
02 preflight
The preflight confirms database access, the Oracle version and the Select AI package.

2. Configure Amazon Bedrock access

Choose a Bedrock model, create a dedicated AWS identity, and store its key in an Oracle credential.

Select the model and Region

  1. Open Amazon Bedrock in US East (N. Virginia), us-east-1.

  2. Choose Model catalog, search for Amazon Nova Lite, and open its details.

Choose Nova Lite in the Amazon Bedrock model catalog
In the Bedrock Model catalog, filter the provider to Amazon and choose Nova Lite. This walkthrough uses Nova Lite (amazon.nova-lite-v1:0), rather than Nova 2 Lite.
  1. Confirm the API model ID is amazon.nova-lite-v1:0 and that it is supported in the selected Region.

  2. Use this exact model ID in the IAM policy, endpoint policy and AI profile.

The former Model access page has been retired. Model activation requirements vary by provider and account; use the catalog and complete applicable prerequisites. An invocation is needed to establish access. AWS model access documentation

03 model access
The console directs you to the model catalog instead of the retired Model access workflow.

Create the scoped IAM policy

Open IAM → Policies → Create policy → JSON. Paste the following policy, choose Next, name it odb-select-ai-bedrock-nova-lite-invoke, review it, and choose Create policy.

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Action": "bedrock:InvokeModel",
    "Resource": "arn:aws:bedrock:us-east-1::foundation-model/amazon.nova-lite-v1:0"
  }]
}

Use your administrator session to create this policy. The database identity needs only the scoped invocation permission. AWS IAM policy examples

Nova Lite scoped IAM invocation policy
The policy allows bedrock:InvokeModel for Amazon Nova Lite in us-east-1.

Create a dedicated IAM user

  1. Open IAM → Users → Create user.

  2. Enter odb-select-ai-bedrock-lab.

  3. Leave Provide user access to the AWS Management Console unchecked.

userform
Enter the user name and leave console access disabled.
  1. Choose Next, then Attach policies directly.

  2. Search for and select odb-select-ai-bedrock-nova-lite-invoke.

  3. Continue to Review and create, verify the name and selected policy, then choose Create user.

  4. Open the user’s Permissions tab and confirm the scoped Nova Lite policy is attached.

Dedicated Bedrock IAM user created
AWS confirms that the dedicated IAM user was created.

Generate an access key

Open the user’s Security credentials tab. Under Access keys, choose Create access key.

credentials
The user has no access keys yet. Choose Create access key to begin.
AWS access key creation use cases
Select the use case appropriate to the database integration and continue.

Add a description such as Oracle Autonomous Database Select AI — Nova Lite us-east-1 to identify the key’s purpose.

Access key description before creation
Add a description to identify the key. This earlier capture says Llama3; use Nova Lite for this walkthrough.

Choose Create access key, save the access key ID and secret privately, then choose Done. Enter them only in the hidden prompts below; do not include the retrieval screen in the article.

Store the key in an Oracle credential

Store the access key ID as the credential’s username and the secret access key as its password.

Run this script with F5 in SQL Developer as ADMIN. Enter the saved access key ID and secret only in the hidden prompts. Create the credential once; if it already exists, verify its name instead of recreating it.

SET ECHO OFF
SET VERIFY OFF
SET DEFINE ON
ACCEPT bedrock_access_key CHAR PROMPT 'Bedrock AWS access key ID: ' HIDE
ACCEPT bedrock_secret_key CHAR PROMPT 'Bedrock AWS secret access key: ' HIDE
BEGIN
  DBMS_CLOUD.CREATE_CREDENTIAL(
    credential_name => 'AWS_BEDROCK_CRED',
    username => '&bedrock_access_key',
    password => '&bedrock_secret_key');
END;
/
UNDEFINE bedrock_access_key
UNDEFINE bedrock_secret_key
SELECT credential_name
FROM user_credentials
WHERE credential_name = 'AWS_BEDROCK_CRED';
04 credential created
The output confirms that AWS_BEDROCK_CRED was created successfully without displaying its secret.

Create the Bedrock Runtime endpoint

Create an interface endpoint in the application VPC so the database can reach Bedrock privately through the existing ODB peering connection. Follow the endpoint creation form in this order.

AWS documents the com.amazonaws.<region>.bedrock-runtime interface endpoint and regional DNS behavior. The database-side DNS and peering must also be configured for this cross-network deployment. Bedrock private connectivity

How the private connection works

How the database reaches Amazon Bedrock
The database resolves the service hostname, sends HTTPS through ODB peering to the interface endpoint, and uses its AWS credential for a signed request. IAM and endpoint policies authorize the identity and model.

The database sends HTTPS directly through ODB peering to the Bedrock interface endpoint. EC2 carries only the SQL Developer tunnel.

1. Choose the endpoint service

In the AWS Console, select us-east-1, then open VPC → Endpoints → Create endpoint. Enter odb-select-ai-bedrock-runtime as the name. Choose AWS services, search for bedrock-runtime, and select com.amazonaws.us-east-1.bedrock-runtime.

Bedrock endpoint service selection
Select com.amazonaws.us-east-1.bedrock-runtime, the interface endpoint service for model invocation.

2. Choose the VPC and subnet

Under Network settings, choose network-01-vpc, the application VPC connected to the ODB network. Keep Enable private DNS name selected and use IPv4.

Bedrock endpoint vpc selection
Choose the application VPC connected to the ODB network and keep private DNS enabled.

Under Subnets, select the application subnet in us-east-1d. The endpoint will create its network interface in this subnet.

Bedrock endpoint subnet selection
Select a reachable application subnet for the endpoint network interface. This example uses subnet-0b96d55f94bfd274d in us-east-1d.

3. Select the endpoint security group

Keep the endpoint creation form open. If the security group does not exist yet, create it in a separate tab, then return to select it.

Create the security group separately

Open VPC → Security groups → Create security group. Enter odb-select-ai-bedrock-endpoint, add a description such as HTTPS access to the Bedrock Runtime endpoint, and choose the same application VPC, network-01-vpc.

Create the Bedrock endpoint security group
Enter the group name, description and application VPC before adding its inbound rule.
Add the inbound HTTPS rule

Under Inbound rules, choose Add rule, set Type to HTTPS (TCP 443), choose Custom as the source type, and enter the database private IP as 10.43.0.6/32. For this example, retain the default outbound rule, then choose Create security group. If the group already exists, add the rule through Edit inbound rules instead.

The database itself sends Select AI requests to Amazon Bedrock over HTTPS (TCP 443). Allow inbound TCP 443 on the Bedrock endpoint’s security group from the database’s private IP—10.43.0.6/32 in this example. The /32 limits the rule to that single address.

Allowing only the EC2 application subnet is insufficient: EC2 carries the SQL Developer tunnel, while the database sends its AI requests directly through ODB peering.

Bedrock endpoint allows HTTPS from database private IP
The saved group permits HTTPS from 10.43.0.6/32. The second rule, 10.40.0.0/24, supports separate application-subnet connectivity checks and is not required for the database’s Select AI calls.
Why allow HTTPS from the database
The database is the HTTPS caller. The endpoint security group allows that database IP on port 443; EC2 serves the SQL Developer tunnel separately.
Return to the endpoint form and select the group

In the endpoint form’s Security groups section, refresh the list and select odb-select-ai-bedrock-endpoint (sg-017f71175045729fe in this deployment). Continue to the endpoint policy section.

Select the Bedrock endpoint security group
Select the prepared security group on the endpoint creation form. Its rules were configured separately in the Security groups page.

4. Set the endpoint policy

Under Policy, choose Custom. Allow the dedicated IAM user to invoke the same Nova Lite model configured earlier. Replace YOUR_ACCOUNT_ID with your AWS account ID.

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": {
      "AWS": "arn:aws:iam::YOUR_ACCOUNT_ID:user/odb-select-ai-bedrock-lab"
    },
    "Action": "bedrock:InvokeModel",
    "Resource": "arn:aws:bedrock:us-east-1::foundation-model/amazon.nova-lite-v1:0"
  }]
}

The user’s IAM policy and this endpoint policy must both allow the request.

Custom endpoint policy for dedicated user and Nova Lite
The saved endpoint policy allows odb-select-ai-bedrock-lab to invoke only Amazon Nova Lite (amazon.nova-lite-v1:0) in us-east-1.

5. Create the endpoint

Review the service, VPC, subnet, security group and custom policy, then choose Create endpoint. Wait for Available before continuing.

Bedrock Runtime endpoint Available with private DNS enabled
The Bedrock Runtime interface endpoint is Available with private DNS enabled.

6. Check the return route

After creating the endpoint, open VPC → Subnets, select the endpoint subnet, and follow its Route table link. Under Routes, check that the database client subnet, 10.43.0.0/24 in this deployment, has an Active route through the existing ODB peering connection. This lets replies from the Bedrock endpoint return to the database.

ODB route checks with local path blurred
The recorded checks show the ODB client network as 10.43.0.0/24, ODB peering as Available, and the client-network route as active. The 10.44.0.0/24 entry is the backup network. This command output summarizes the checks; inspect the endpoint subnet’s route table in the console to see its route target.

Private DNS must also work from the database network

Enabling private DNS on the AWS interface endpoint makes the regional service name resolve privately within the associated VPC. That setting alone does not establish the DNS mapping used by the database in its associated OCI VCN.

Map bedrock-runtime.us-east-1.amazonaws.com to the endpoint network interface’s private IP in the database VCN’s private DNS view. This deployment uses TTL 60; update the record if the endpoint address changes.

In OCI, open the database VCN’s associated private view and create a private zone named bedrock-runtime.us-east-1.amazonaws.com. Select the existing VCN-network-01 private view for this deployment.

OCI Bedrock private DNS zone creation
The zone uses the regional Bedrock Runtime hostname and the database VCN’s existing private view.

Choose Create and open the zone details.

OCI Bedrock private DNS zone Active
The private zone is Active and associated with VCN-network-01.

Under Records → Manage records, add an apex A record for the zone hostname using the Bedrock endpoint network interface’s private IP and TTL 60, then review and publish it. The final configuration uses 10.40.0.220. Use your deployment’s endpoint address.

OCI Bedrock A record 10.40.0.220 TTL 60
The OCI private DNS A record maps bedrock-runtime.us-east-1.amazonaws.com to the Bedrock endpoint’s private IP, 10.40.0.220, with a TTL of 60 seconds.

Keep the regional hostname in API requests for TLS and AWS request signing.

The working configuration used ODB peering and the interface endpoint. VPC Lattice resources explored during troubleshooting are not required for this path. The two existing OCI network security groups remained unchanged, and no database restart was required.

Create the Select AI profile

Create the profile once using the credential and model configured above. Comments are enabled later for the comparison. If BEDROCK_BASELINE already exists, inspect it before rerunning CREATE_PROFILE.

BEGIN
  DBMS_CLOUD_AI.CREATE_PROFILE(
    profile_name => 'BEDROCK_BASELINE',
    attributes => '{
      "provider": "aws",
      "credential_name": "AWS_BEDROCK_CRED",
      "model": "amazon.nova-lite-v1:0",
      "object_list": [
        {"owner": "ADMIN", "name": "AR_INVOICES_DEMO"}
      ],
      "conversation": false
    }');
END;
/
SELECT profile_name, attribute_name, attribute_value
FROM user_cloud_ai_profile_attributes
WHERE profile_name = 'BEDROCK_BASELINE'
  AND LOWER(attribute_name) IN
    ('provider', 'model', 'object_list', 'conversation', 'comments')
ORDER BY attribute_name;
Verified Nova Lite Select AI profile settings
The saved profile uses AWS, Amazon Nova Lite and AWS_BEDROCK_CRED, with conversation history disabled and ADMIN.AR_INVOICES_DEMO as its object context.

The object list supplies schema context for SQL generation; database privileges still control access. Each example specifies the profile explicitly.

Test connectivity from the database

Run these checks from the database connection in SQL Developer. Playground and EC2 checks use different callers and network paths.

Test connectivity from the database layer by layer
Check settings, resolve the name, test HTTPS, and finally request a model response. Each check isolates a different layer.
Check private endpoint routing and host privileges

Read the outbound routing property:

SELECT property_value AS outbound_routing
FROM database_properties
WHERE property_name = 'ROUTE_OUTBOUND_CONNECTIONS';

For this deployment, private endpoint routing was already enabled and remained unchanged. Also inspect the host ACL entries for the schema making the request. The working ADMIN configuration had http and connect on port 443 for the regional Bedrock hostname, and a separate resolve privilege without a port range. The host entries were configured as private targets.

Inspect the matching host ACEs as an administrator:

SELECT host, lower_port, upper_port, principal,
       privilege, grant_type
FROM dba_host_aces
WHERE host = 'bedrock-runtime.us-east-1.amazonaws.com'
  AND principal = 'ADMIN'
ORDER BY lower_port, privilege;

Review matching entries and any broader rules before changing them. A missing privilege must be corrected for the actual calling schema and private hostname target; the checks here do not alter ACLs.

Host ACLs permit the database schema to make requests; the endpoint security group permits the network connection.

Resolve the hostname inside Autonomous Database
SELECT UTL_INADDR.GET_HOST_ADDRESS(
  'bedrock-runtime.us-east-1.amazonaws.com'
) AS database_dns_result
FROM dual;

This checks name resolution from the database session. Compare it with the private DNS configuration described above. In this environment, the database lookup displayed a 254.x.x.x address even with the private DNS mapping configured. That observation alone did not establish whether HTTPS worked, so the next check tested the connection directly.

Request an HTTPS response

Run a simple GET against the regional service root. This is a transport probe, not a signed inference request:

SET SERVEROUTPUT ON

DECLARE
  req UTL_HTTP.req;
  res UTL_HTTP.resp;
BEGIN
  UTL_HTTP.SET_TRANSFER_TIMEOUT(15);
  UTL_HTTP.SET_RESPONSE_ERROR_CHECK(FALSE);

  req := UTL_HTTP.BEGIN_REQUEST(
    'https://bedrock-runtime.us-east-1.amazonaws.com/', 'GET');
  res := UTL_HTTP.GET_RESPONSE(req);

  DBMS_OUTPUT.PUT_LINE(
    'HTTPS status: ' || res.status_code || ' ' || res.reason_phrase);
  UTL_HTTP.END_RESPONSE(res);
END;
/

SET_RESPONSE_ERROR_CHECK(FALSE) allows the probe to inspect a 4xx or 5xx response; it does not disable TLS certificate verification. The timeout setting applies to this session’s UTL_HTTP requests.

Database routing DNS and HTTPS test
The captured run shows ENFORCE_PRIVATE_ENDPOINT, a database DNS result of 254.250.131.235, and HTTPS status 404 Not Found. The combined script completed in 1.361 seconds.

The HTTP reply confirms a working HTTPS transport path. 404 does not confirm model invocation: the service root is not an inference request.

Invoke the model from the database

After the transport check, use the configured AI profile and stored credential to make an actual model request:

SET LONG 100000
SET LONGCHUNKSIZE 100000

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'Reply with exactly: Database to Bedrock test successful.',
  profile_name => 'BEDROCK_BASELINE',
  action => 'chat') AS model_response
FROM dual;
Database to Bedrock model response
The model returned “Database to Bedrock test successful.” in 1.242 seconds.

The response verifies model invocation using the database profile, stored credential and current permissions. Next, inspect the invoice data.

Interpret failures at the correct layer
Observation What to check next
ORA-24247 network access denied Effective host ACL privileges for the calling database schema and hostname.
ORA-30699 connection timeout DNS destination, peering routes, return traffic, security groups and network ACLs.
HTTP response from the root URL Transport is responding; continue with a signed model request.
Authorization or model-access error Credential, IAM policy, endpoint policy, model ID, region and provider prerequisites.
Model response Connectivity and invocation worked for this request; continue to validate business queries separately.

3. Inspect the invoice table

Inspect AR_INVOICES_DEMO to understand its columns and check for existing table and column comments:

SELECT column_name, data_type, nullable
FROM user_tab_columns
WHERE table_name = 'AR_INVOICES_DEMO'
ORDER BY column_id;

SELECT comments
FROM user_tab_comments
WHERE table_name = 'AR_INVOICES_DEMO';

SELECT column_name, comments
FROM user_col_comments
WHERE table_name = 'AR_INVOICES_DEMO'
  AND comments IS NOT NULL
ORDER BY column_name;

Inspect the initial schema and comments before adding business context.

07 table columns
The initial inspection shows the 11 columns and no existing business comments.

Inspect sample invoices, then group the table by payment status and currency:

SELECT invoice_number, customer_name,
       TO_CHAR(due_date, 'YYYY-MM-DD') AS due_on,
       currency_code, invoice_amount, paid_amount,
       outstanding_amount, payment_status
FROM admin.ar_invoices_demo
ORDER BY invoice_id
FETCH FIRST 5 ROWS ONLY;

SELECT payment_status, currency_code, COUNT(*) AS invoice_count
FROM admin.ar_invoices_demo
GROUP BY payment_status, currency_code
ORDER BY currency_code, payment_status;
08 invoice samples
One sample invoice has an original amount of 23,758.42, with 11,879.21 paid and 11,879.21 outstanding. The full grouping below shows the payment statuses and currencies.
Payment status Currency Invoice count
PAID USD 24,927
PARTIALLY PAID USD 25,022
UNPAID USD 50,051

All rows in the observed grouping were USD. Keep currencies separate when aggregating monetary values so that the rule remains valid if the dataset changes.

4. Verify the overdue invoice answer with SQL

An overdue outstanding invoice in this example has a due date before the requested reporting date and an outstanding amount greater than zero. Invoices due on November 16 are excluded from that date’s overdue total. Partially paid invoices are included when a balance remains.

The table contains stored balances, not a payment history. The reporting date controls the due-date cutoff; this query does not reconstruct what the balance was at some earlier point in time.

SELECT '2026-11-16' AS as_of_date,
       currency_code,
       COUNT(*) AS overdue_invoice_count,
       SUM(outstanding_amount) AS overdue_outstanding
FROM admin.ar_invoices_demo
WHERE due_date < DATE '2026-11-16'
  AND outstanding_amount > 0
GROUP BY currency_code
ORDER BY currency_code;
09 verified answer
The reference SQL returns 72,240 overdue outstanding invoices and USD 1,512,705,087.97.

5. Generate SQL before adding business context

Use SHOWSQL to inspect the generated query before execution. Keep this prompt unchanged for the before-and-after comparison:

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'What are the overdue invoice count and total outstanding amount as of November 16, 2026 in AR_INVOICES_DEMO?',
  profile_name => 'BEDROCK_BASELINE',
  action => 'showsql') AS generated_sql
FROM dual;
10 baseline generated sql
Before business context, Select AI generated a due-date filter but no positive outstanding balance filter.

The generated statement was:

SELECT
  COUNT("INVOICE_ID") AS "OVERDUE_INVOICE_COUNT",
  SUM("OUTSTANDING_AMOUNT") AS "TOTAL_OUTSTANDING_AMOUNT"
FROM "ADMIN"."AR_INVOICES_DEMO"
WHERE "DUE_DATE" < TO_DATE('2026-11-16', 'YYYY-MM-DD');

Execute the exact returned statement to validate it. A fresh AI request could generate a different query; the comparison below uses the saved SQL.

Result Invoice count Outstanding USD
Generated SQL without business context 96,220 1,512,705,087.97
Verified business answer 72,240 1,512,705,087.97
Difference +23,980 0.00

The amount matched, which could easily have made the result feel trustworthy. But the query counted invoices based only on their due dates. An old due date does not make a fully paid invoice an outstanding receivable.

Successful execution and a matching monetary total do not prove correctness. The invoice count must also satisfy the business definition.

6. Add table and column comments

Add one table comment and descriptions for all 11 columns. Explain which date defines overdue, which amount represents the remaining balance, how partial payments are handled, and why currencies must be grouped.

Comments supply additional schema metadata when enabled in the profile; they do not train or fine-tune Nova Lite. Oracle comment-based SQL generation example

COMMENT ON COLUMN admin.ar_invoices_demo.due_date IS
'Payment due date. Overdue means DUE_DATE < the requested as-of date,
excluding invoices due on that date. Also require OUTSTANDING_AMOUNT > 0.';

COMMENT ON COLUMN admin.ar_invoices_demo.outstanding_amount IS
'Remaining unpaid balance in CURRENCY_CODE. Outstanding invoices require
this value > 0. Sum this column for total outstanding balances,
including partially paid invoices.';

COMMENT ON COLUMN admin.ar_invoices_demo.payment_status IS
'Observed values: PAID, PARTIALLY PAID, UNPAID. Use OUTSTANDING_AMOUNT > 0
to select outstanding invoices; filtering only UNPAID would omit
partially paid invoices.';

Run the attached complete script to add the table comment and all 11 column comments. The excerpt above shows three key columns.

11 business comments applied
The full script adds the table description and 11 column descriptions. The output confirms comments were created.

Complete AR invoice business comments SQL

Read back the descriptions from USER_TAB_COMMENTS and USER_COL_COMMENTS:

SELECT 'TABLE' AS object_or_column, comments AS saved_comment
FROM user_tab_comments
WHERE table_name = 'AR_INVOICES_DEMO'
UNION ALL
SELECT column_name, comments
FROM user_col_comments
WHERE table_name = 'AR_INVOICES_DEMO';
12 saved comments
All 12 descriptions—one table comment and 11 column comments—are saved.

Enable comments in the AI profile

Enable comments in the AI profile, then read back the saved setting:

BEGIN
  DBMS_CLOUD_AI.SET_ATTRIBUTE(
    profile_name => 'BEDROCK_BASELINE',
    attribute_name => 'comments',
    attribute_value => 'true');
END;
/

SELECT profile_name, attribute_name, attribute_value
FROM user_cloud_ai_profile_attributes
WHERE profile_name = 'BEDROCK_BASELINE'
  AND LOWER(attribute_name) = 'comments';

The verified row was BEDROCK_BASELINE | comments | true. Oracle documents this setting as the switch for including table and column comments in SQL-generation metadata. Oracle documentation

7. Repeat the question and compare the results

Repeat the question with the same model and profile. Only the business descriptions and the comments setting have changed.

Repeat the same SHOWSQL call from step 5, with the prompt unchanged:

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'What are the overdue invoice count and total outstanding amount as of November 16, 2026 in AR_INVOICES_DEMO?',
  profile_name => 'BEDROCK_BASELINE',
  action => 'showsql') AS generated_sql
FROM dual;

This time, Select AI generated:

SELECT
  COUNT("INVOICE_ID") AS OVERDUE_INVOICE_COUNT,
  SUM("OUTSTANDING_AMOUNT") AS TOTAL_OUTSTANDING_AMOUNT
FROM "ADMIN"."AR_INVOICES_DEMO"
WHERE "DUE_DATE" < TO_DATE('2026-11-16', 'YYYY-MM-DD')
  AND "OUTSTANDING_AMOUNT" > 0
  AND "PAYMENT_STATUS" IN ('UNPAID', 'PARTIALLY PAID')
GROUP BY "CURRENCY_CODE";
13 context generated sql
With comments enabled, the SQL now includes positive outstanding balances, partially paid invoices and currency grouping.

The SQL groups by currency but omits the currency code from its output. Include that code when presenting results across multiple currencies.

Execute the exact returned SQL shown above and compare both measures with the reference:

Result Invoice count Outstanding USD
Before business comments 96,220 1,512,705,087.97
After business comments were enabled 72,240 1,512,705,087.97
Verified business answer 72,240 1,512,705,087.97
After minus verified 0 0.00
Select AI comparison observed result
Execution completed in 1.813 seconds. Both reference measures match: 72,240 invoices and USD 1,512,705,087.97. The count overstatement fell from 23,980 to zero for this example.

For this question and dataset, the added business context produced SQL with the required positive-balance condition and the correct count. Continue to validate each generated query against the reporting rules.

8. Test the five Select AI actions

Explore five actions in SQL Developer, each with a different purpose. SHOWSQL, RUNSQL, EXPLAINSQL and NARRATE use the identical overdue-invoice question; CHAT uses a separate conceptual question.

Action Purpose
CHAT Explain a general concept using the model
SHOWSQL Generate SQL for review
RUNSQL Generate and execute SQL against the database
EXPLAINSQL Explain generated SQL logic
NARRATE Query records and describe the results in natural language

These roles follow Oracle’s Select AI action documentation. Each example below includes its invocation and the observed response.

CHAT explains a concept

Ask CHAT to explain a familiar accounts receivable concept:

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'Explain accounts receivable aging and how partial payments affect outstanding balances. Use a simple numerical example. Keep the answer under 180 words.',
  profile_name => 'BEDROCK_BASELINE',
  action => 'chat') AS chat_response
FROM dual;
Select AI chat observed result
CHAT returned a general explanation in 3.577 seconds; it did not query AR_INVOICES_DEMO.

The response correctly described a partial payment reducing a balance. But it also claimed that the payment moves the invoice into a newer aging category. Under the due-date aging convention used here, the remaining balance normally retains its age from the original due date. A payment reduces what is owed; it does not reset that date. The screenshot illustrates how a readable explanation can still contain a business error.

SHOWSQL lets us review the logic

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'What are the overdue invoice count and total outstanding amount as of November 16, 2026 in AR_INVOICES_DEMO?',
  profile_name => 'BEDROCK_BASELINE',
  action => 'showsql') AS generated_sql
FROM dual;
13 context generated sql
SHOWSQL returns the generated statement for review. This captured context-enabled generation completed in 3.881 seconds; SHOWSQL itself does not execute the returned query.

SHOWSQL returns SQL text for review without executing it.

RUNSQL brings back the answer

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'What are the overdue invoice count and total outstanding amount as of November 16, 2026 in AR_INVOICES_DEMO?',
  profile_name => 'BEDROCK_BASELINE',
  action => 'runsql') AS runsql_response
FROM dual;
Select AI runsql observed result
RUNSQL completed in 2.22 seconds and returned JSON with count 72,240, outstanding amount 1,512,705,087.97 and currency USD.

Both returned measures match the reference. RUNSQL makes a fresh generation request; do not assume it executes the same SQL previously returned by SHOWSQL.

EXPLAINSQL explains the generated query

Use EXPLAINSQL to describe the generated SQL in natural language. This explains query logic rather than producing an optimizer execution plan.

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'What are the overdue invoice count and total outstanding amount as of November 16, 2026 in AR_INVOICES_DEMO?',
  profile_name => 'BEDROCK_BASELINE',
  action => 'explainsql') AS explanation
FROM dual;
Select AI explainsql observed result
EXPLAINSQL completed in 3.363 seconds and described the generated query clause by clause.

Review the generated SQL alongside its explanation. This call introduced the following filter:

AND "OUTSTANDING_AMOUNT" > 0
AND "PAYMENT_STATUS" IN ('PAID', 'PARTIALLY PAID')

The status list omitted UNPAID. It differed from the earlier correct statement, which included UNPAID and PARTIALLY PAID. The explanation then incorrectly described its own filter as excluding fully paid invoices without recognizing the missing unpaid category. This statement was not executed, so no numerical result is claimed for it.

The comments remained enabled during this call. EXPLAINSQL supplies an explanation to review; it does not independently verify the query’s correctness.

NARRATE tells the result in plain English

Use NARRATE to query the records and describe the result in plain English. This action sends query results to the model; the table here contains synthetic invoices.

SELECT DBMS_CLOUD_AI.GENERATE(
  prompt => 'What are the overdue invoice count and total outstanding amount as of November 16, 2026 in AR_INVOICES_DEMO?',
  profile_name => 'BEDROCK_BASELINE',
  action => 'narrate') AS narrative
FROM dual;
Select AI narrate observed result
NARRATE completed in 2.66 seconds and reported 72,240 overdue invoices with 1,512,705,087.97 still owed.

The figures and treatment of partial payments match the reference. The narrative does not explicitly name USD, and its underlying generated SQL was not separately inspected.

Conclusion

Oracle Select AI and Amazon Bedrock provide a practical way to ask questions of data on Oracle Database@AWS. In the verified comparison, business comments corrected an invoice count that was 23,980 too high. The saved context-enabled SQL matched both reference measures, and the observed RUNSQL and NARRATE calls also returned matching figures.

Two errors remain useful checks for readers: CHAT incorrectly described partial payments changing an invoice’s age, and EXPLAINSQL generated a status filter that omitted unpaid invoices. Context improved one verified answer, but fresh calls still varied. This is a worked example, not a general accuracy benchmark.

Define business meaning alongside the schema, review the generated SQL, and compare its results with a trusted reference. Comments provide useful context; database knowledge and validation establish whether the answer is correct.

The same approach can extend to customer balances, aging buckets and charts built from validated results. The examples here demonstrate five Select AI actions in SQL Developer; chart rendering requires a suitable visualization tool. Start with a clear business definition and a verified query before building further analysis.

Troubleshooting and observed limitations

The initial database-to-Bedrock call timed out. Later HTTPS checks and AWS flow logs confirmed connectivity to the interface endpoint. Regional hostname behavior changed after the DNS update; stale resolution was consistent with the delay, but the internal cache was not directly observed.

06 initial timeout
The original ORA-30699 timeout was a connectivity failure, not an incorrect answer from the model.

After connectivity was established, a direct API call rejected the initial Llama 3 70B model because it was a legacy model and the account did not meet its recent-use requirement. Switching to active Nova Lite and updating the scoped IAM policy, endpoint policy and AI profile allowed invocation.

A later SHOWSQL call timed out, while subsequent CHAT and SHOWSQL calls succeeded. The cause of the intermittent timeout remains unresolved.

References

Share on LinkedIn ↗

Join the discussion

Ask a question, share a result, or add a useful tip.

Loading comments…

Leave a comment

Your name and comment will be public. Keep passwords, email addresses, IP addresses, and other private details out of your comment. Cloudflare Turnstile checks submissions to help prevent spam.