From: "Esteban Manchado Velázquez" Date: 2006-04-20T17:12:12+09:00 Subject: Re: ResultSetMetaData --cQXOx3fnlpmgJsTP Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Barinek, On Wed, Apr 19, 2006 at 11:56:23PM +0900, barinek barinek wrote: > dose Ruby or ActiveRecord have the Java/JDBC equivalent for retrieving=20 > ResultSet meta data... >=20 > PreparedStatement statement =3D null; > try > { > statement =3D connection.prepareStatement("select * from some_table"); >=20 > ResultSet rs =3D null; > try > { > rs =3D statement.executeQuery(); > ResultSetMetaData rsMetaData =3D rs.getMetaData(); > int columnCount =3D rsMetaData.getColumnCount(); >=20 > more stuff... Hmmm... you can use ActiveRecord::Base.columns to get a list of ActiveRecord::ConnectionAdapters::Column objects, like this: MyModel.columns # =3D> [#, ..= =2E] If you want metadata for random SQL queries (from ActiveRecord), I don't think you can get it... If you really want to query the database and retrieve meta data, you can always use Ruby's DBI (see http://ruby-dbi.rubyforge.org/). You have an explanation on meta data retrieving on "Using the Ruby DBI Module", at http://www.kitebird.com/articles/ruby-dbi.html#TOC_9 HTH, --=20 Esteban Manchado Vel=E1zquez - http://www.foton.es EuropeSwPatentFree - http://EuropeSwPatentFree.hispalinux.es --cQXOx3fnlpmgJsTP Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFERoWWhYgK5b1UDsERAtA/AJ0UAdCbMjxsmyJ9dAkP3i/ujHHTIwCePhPe HqL3gpViGkECh3aoeeIancw= =1YvS -----END PGP SIGNATURE----- --cQXOx3fnlpmgJsTP--