Skip to Main Content

Oracle Developer Tools for VS Code

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can I see the sql statement of a view (db resides on AWS)

User_C54NYOct 10 2021

I've just installed the vscode extension and successfully connected the db.
The db resides on AWS.
I can connect the db and just wanted to test it by opening an existing view.
But, it just lets me "describe" the view. So I can see the columns but I need to edit the query statement.
What's missing? Or is the problem the AWS part?
Thanks

This post has been answered by Christian.Shay -Oracle on Oct 16 2021
Jump to Answer

Comments

Christian.Shay -Oracle

Hi,
Please execute this making appropriate substitutions for VIEW_NAME and VIEW_OWNER:

select
dbms_metadata.get_ddl('VIEW', 'VIEW_NAME', 'VIEW_OWNER') 
from
dual;

Or you can try:

SELECT VIEW_NAME, TEXT
FROM USER_VIEWS;
User_C54NY

Hi,
I tried the first one but have problems to replace accordingly.
2021-10-14_14-22.pngSo, I put:

select
dbms_metadata.get_ddl('ALL_VIEW_SOURCE', 'ALB') 
from
dual;

But who is meant by owner?
Is it the username which is used to establish the connection? The host name? Connection Name?
"Dual" should be used as given?
Thanks!

undefined (0 Bytes)undefined (0 Bytes)In your case, please try this:

select
dbms_metadata.get_ddl('VIEW', 'ALL_VIEW_SOURCE', 'AWS_DEV_ALB') 
from
dual;
User_C54NY

Thanks, it took me one step further.
I right clicked on AWS_DEV_ALB -> "open new sql file"
2021-10-15_10-48.png
and pasted what you provided:

select
dbms_metadata.get_ddl('VIEW', 'ALL_VIEW_SOURCE', 'AWS_DEV_ALB') 
from
dual;

I right click on the query and "execute sql" but all I get is:
2021-10-15_10-58.pngIf that's relevant, the structure is:
2021-10-15_10-59.pngThe view I want is in "Relational Views" file order.

Answer

You greyed out the view name, so I cannot check to see if you have a typo which is the first thing I would suspect.
Did you give the view name in all caps, surrounded by single quotes?
Maybe you can create a view called TESTVIEW and run this again using 'TESTVIEW' as the second parameter and share the full error message without greying it out.
Finally, please issue:
select owner from ALL_VIEWS where VIEW_NAME ='NAMEOFYOURVIEW';

If that is NOT AWS_DEV_ALB then you will need to change the pl/sql block accordingly.

Marked as Answer by User_C54NY · Oct 18 2021
User_C54NY

The owner it was. With your second view I got the owner, changed it and it worked. Thank you very much for your patience! Just for clearance and everybody else who might have problems with it. Owner is the name you fill in to connect to your database. What I used before - and what didn't work - was the name I gave for the connection.
Screenshot 2021-10-18 103155.jpg

1 - 6

Post Details

Added on Oct 10 2021
6 comments
155 views