This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi! I'm trying to figure out a way to see if my result set is empty (as in, the query returned no records, as in, the table is empty). I thought maybe there was a way similar to rsmd.getColumnCount() Does anyone know how I could test for this? Annette
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
The next() method will return false on the first call.
rs = executeQuery(" "); while(rs.next()) { do something; }
Annette L'Heureux
Ranch Hand
Joined: Dec 07, 2000
Posts: 135
posted
0
No no no. I have a database with about 12 tables in it, and I need to execute a query that selects from multiple tables. The problem is, some of the tables have no records in them, because it's still in development and we haven't had time to go and fill them in. If I make a query that mentions one of these empty tables, I get no records returned. For example. Let's say I have these tables: Systems Envs (environments) Locations owners If my query says: select s.system_names, e.env_name, l.location, o.owner_name from systems s, envs e, locations l, owners o where env_name="bla bla bla" and s.owner_identifier=o.identifier and s.env_identifier=e.identifier, etc,etc So in the systems table, there are foreign keys to all the other tables. But when I build my query like this, I get no records because the owner table is empty. You might be saying "well then why include the owner table?" Because in the future, it will need to be referenced, when it starts filing up. So, the whole point of this was that I was trying to determine whether or not a table contained records, and if it did, append that portion to the query. Does this make sense?
Thomas Paul
mister krabs
Ranch Hand
Joined: May 05, 2000
Posts: 13974
posted
0
Do a select count(*) from the table first. Or use an outer join.
Annette L'Heureux
Ranch Hand
Joined: Dec 07, 2000
Posts: 135
posted
0
I'll try that! I think that's probably the simplest way. Thanks!