Eugen Popescu Eugen Popescu - 1 year ago 95
Javascript Question

How can I check if a table or view exists in Oracle DB using javascript?

I need to check if a table name from html input exists in an oracle database, how can I do that?

Answer Source

You cannot access a db from client side (javascript browser). You need to expose, server side, a service which accepts in the GET call a parameter string, the table name, and call this server with an ajax call client side, using javascript and sending the required table name string into the GET body of the ajax call.

The server will receive the table name, check it against its db wit a proper query, then return the result to the client that will parse the server result as GET return value and perform the desired action

EDIT: answering to the comment, you need to query your db searching for your table, let's say named your-table-name, in your db user_tables executing the following query via php:

SELECT table_name FROM user_tables where table_name = 'your-table-name'

and then check if the query returns one record (the table exists) or none (the table doesn't exist).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download