java - Determine if JOIN resulted in any columns -
i have sql statement multiple joins; there records resulting joins , not. not error when joins empty.
is there way test whether particular join empty without having trap exception occurring when resulting column not found in result set?
in other words, if, using jdbc, execute following sql statement:
select * aa left outer join bb on aa.keyfield = bb.keyfield keyfield = "123"
i know whether join found fields without having trap exception. if execute java statement:
string valuestring = rs.getstring("bb.keyfield");
i exception. cannot compare rs.getstring("bb.keyfield") null, because getstring throws exception if did not find values in join.
i hope makes question more clear, , apologize not having expanded on more in first place.
the query won't return columns such names. use simple names of columns (name
, keyfield
, etc.). execute query inside database query tool, , you'll see names assigned retrieved columns.
you should never select *
, , select specific columns. , should assign aliases columns if 2 columns have same name:
select aa.id aid, aa.name aname, bb.id bid, bb.name bname ...
and, then, can safely use
rs.getstring("aid"); rs.getstring("bname"); ...
also, exception thrown contains message, should identify problem. read it. , if don't understand it, post it.
Comments
Post a Comment