Hi all. My goal is to get a list of all field names and data types for
those fields in any given table in a mysql database. From reading the
DBI documentation, the only way I've been able to do this is by
preparing and executing a query against a table first. Then I would use
$sth-{NAME} and
[EMAIL PROTECTED] wrote:
Hi all. My goal is to get a list of all field names and data types for
those fields in any given table in a mysql database. From reading the
DBI documentation, the only way I've been able to do this is by
preparing and executing a query against a table first. Then I
I would try to use SELECT * FROM TABLE WHERE 0=1. That has no result
rows, but it should deliver the column information. By the way, most SQL
databases have a way to query some special tables or view to find
information about a table. Consult the database manual for that.
Alexander
On
[EMAIL PROTECTED] wrote:
Hi all. My goal is to get a list of all field names and
data types for
those fields in any given table in a mysql database. From
reading the
DBI documentation, the only way I've been able to do this is by
preparing and executing a query against a table
[EMAIL PROTECTED] wrote:
So what does WHERE 0=1 actually mean? Just curious. :)
It means select all rows where zero is equal to one. So it always returns
zero rows. :)
Ronald
On 27.06.2006 17:03, [EMAIL PROTECTED] wrote:
Tried it and it works just fine. I guess I specified no where clause
because I thought a value of a known field would have to be greater,
lesser, or equal to something and I wouldn't be able to depend on the
value of the fields, let alone even
[EMAIL PROTECTED] wrote:
Hi all. My goal is to get a list of all field names and data types for
those fields in any given table in a mysql database. From reading the
DBI documentation, the only way I've been able to do this is by
preparing and executing a query against a table first. Then I
Here's one for oracle
sub GetOracleFieldLengths
{
my ($TABLE)[EMAIL PROTECTED];
my (%FIELDLENGTHS, %FIELDTYPES);
if ($TABLE=~/\.(\S+)$/)
{
$TABLE=$1;
}
my $fieldlengths=$dbh-prepare(SELECT COLUMN_NAME, DATA_TYPE, DATA_LENGTH
from ALL_TAB_COLUMNS where
On 6/27/06, Matthew Persico [EMAIL PROTECTED] wrote:
So now I need one for every database?
Yes - and there a DBMS that make you do that the hard way, with raw access
to the system catalog.
Despite the prior thread entry refering to
select * from table where 0 = 1
as a hack in the 'bad'
On 6/27/06, Jordan Sissel [EMAIL PROTECTED] wrote:
iirc, you can use $dbh-table_info() or tables() or type_info() functions to
pull that information without having to do a hack where you select 0 rows
just to poll for column names.
Right?
Yes. Unless you want the information for a
It is much more easily portable.
Suppose you have a real query:
select a.foo, b.bar.c.baz
from
a, b, c
where .
The 0= 1 method works for that too. Contrast that with parsing the
from clause and the where clause to create a tabel catalog query. Yuk.
How can you gaurantee all DB engines
Matthew Persico wrote:
So now I need one for every database?
For every database you need to support yes, not all engines will return
the exact same data with a query if no results and that also not in the
same format.
But each database is 00% gauranteed to support what it documents it
JupiterHost.Net [mailto:[EMAIL PROTECTED] wrote:
It is much more easily portable.
Suppose you have a real query:
select a.foo, b.bar.c.baz
from
a, b, c
where .
The 0= 1 method works for that too. Contrast that with parsing the
from clause and the where clause to
13 matches
Mail list logo