dbTalk Databases Forums  

basic SQL query

comp.databases comp.databases


Discuss basic SQL query in the comp.databases forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
Ed Prochak
 
Posts: n/a

Default Re: basic SQL query - 09-07-2006 , 02:42 PM







Hugo wrote:
Quote:
Ed Prochak wrote :

Actually it is not surprising. AFAICT, they assumed you know which DBMS
product you are connecting to, so once connected, you do not need a WHO
AM I feature.

I'm not asking for a "who am i" feature, but just a simple SQL query
that allow me to check that I'm actually connecting to something real.
The reason I suggested a WHO AM I feature was that it allows you to
figure yout which table you can feel safe trying to query.

Quote:
Good luck. Keep us posted on you progress.

Actually I'm using Hibernate to connect on several different DBMS. So I
did post a similar question on hibernate forums, but still waiting for
an answer.

--
Hugo
Well presumably (I never used Hibernate), you have a connect
command/function. It retrurns either success or failure. So what more
assurance do you need? The only uniform sequence for any SQL DBMS that
I can think of is along the lines of this:
CONNECT(someDBMS)
xyz=SQLPREPARE("COMMIT WORK;")
SQLEXECUTE(xyz)
DISCONNECT

I still wonder why you would be connecting to a DB without knowing what
tables you are going to use. A simple communications check isn't going
to prove anything beyond the fact that you could connect and query at
that point in time. There's no guarantee after that moment is gone that
the DBMS doesn't go down or that the network doesn't fail. So I cannot
see the business purpose.

Some interesting solutions proposed so far. I think if you do carry on
with this you'll end up trying multiple queries, sort of like probing
the hardware in the boot up process.

HTH,
ed



Reply With Quote
  #12  
Old   
HansF
 
Posts: n/a

Default Re: basic SQL query - 09-07-2006 , 05:18 PM






On Thu, 07 Sep 2006 12:42:45 -0700, Ed Prochak wrote:
Quote:
Well presumably (I never used Hibernate), you have a connect
command/function. It retrurns either success or failure. So what more
I wonder how Hugo gets around the need to load the rdbms-dependant drivers
needed to get JDBC to work with different databases. Is this perhaps a
recent innovation I've missed?

--
Hans Forbrich (mailto: Fuzzy.GreyBeard_at_gmail.com)
*** Feel free to correct me when I'm wrong!
*** Top posting [replies] guarantees I won't respond.



Reply With Quote
  #13  
Old   
TroyK
 
Posts: n/a

Default Re: basic SQL query - 09-07-2006 , 08:04 PM




Hugo wrote:
Quote:
Hi there,

I'm looking for a simple and quick SQL query with no side effect, that
runs on most databases (at least Oracle, MySQL and PostgreSQL). I need
that to test my database connection.

I tried "select 1" but it does not work under Oracle. Any other idea ?

--
Hugo
Are the INFORMATION_SCHEMA views implemented on all your required DBMS
products?

For instance...

SELECT COUNT(*)
FROM INFORMATION_SCHEMA.TABLES

HTH,
TroyK



Reply With Quote
  #14  
Old   
David Cressey
 
Posts: n/a

Default Re: basic SQL query - 09-08-2006 , 01:54 PM




"Hugo" <hugo (AT) nospam (DOT) fr> wrote

Quote:
Ed Prochak wrote :

Actually it is not surprising. AFAICT, they assumed you know which DBMS
product you are connecting to, so once connected, you do not need a WHO
AM I feature.

I'm not asking for a "who am i" feature, but just a simple SQL query
that allow me to check that I'm actually connecting to something real.

I haven't tried this yet, but maybe you could do a query on the system
tables, using some SQL standard table name.

select table_name from all_tables

would work on Oracle, but I don't know what the standard system table names
are.




Reply With Quote
  #15  
Old   
Lennart
 
Posts: n/a

Default Re: basic SQL query - 09-08-2006 , 02:19 PM




Hugo wrote:
Quote:
Hi there,

I'm looking for a simple and quick SQL query with no side effect, that
runs on most databases (at least Oracle, MySQL and PostgreSQL). I need
that to test my database connection.

I tried "select 1" but it does not work under Oracle. Any other idea ?
I only use DB2, so I dont know what other vendors that implement:

select * from lateral(values(1)) X

I believe the construction was introduced in SQL99.


/Lennart



Reply With Quote
  #16  
Old   
Michael Zedeler
 
Posts: n/a

Default Re: basic SQL query - 09-11-2006 , 04:51 AM



Hugo wrote:
Quote:
I'm looking for a simple and quick SQL query with no side effect, that
runs on most databases (at least Oracle, MySQL and PostgreSQL). I need
that to test my database connection.

I tried "select 1" but it does not work under Oracle. Any other idea ?
Is it nessecary to send a valid SQL command? Why not send an invalid
string and just check that the dbms returns an error code?

Regards,

Michael.
--
Which is more dangerous? TV guided missiles or TV guided families?
I am less likely to answer usenet postings by anonymous authors.
Visit my home page at http://michael.zedeler.dk/


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.