| View previous topic :: View next topic |
| Author |
Message |
Marcelo Guest
|
Posted: Tue May 25, 2004 4:57 pm Post subject: How to get table fields |
|
|
Hi!
I wanna get the fields of an unknown table. I use a TQuery and a "select *
from table" to open the table and then iterate trought the field list. I
access the table with a clientdataset and a remote provider. The fact is
that when I open a big table all the registers are sent to the client and
this takes a long time. How can I open a table without returning any result
set? something like "select * from table where false.
Greetings, Marcelo.
|
|
| Back to top |
|
 |
Del Murray Guest
|
Posted: Tue May 25, 2004 5:04 pm Post subject: Re: How to get table fields |
|
|
It depends on the database of course, which you didn't tell us anything
about :-(
you can do 'select * from sometable where 1=2' and you will get a tquery
that knows all about the columns of the table but has no rows
|
|
| Back to top |
|
 |
alex Guest
|
Posted: Tue May 25, 2004 5:12 pm Post subject: Re: How to get table fields |
|
|
Set ClientDataSet.PacketRecords property to 0 before Open and after Open you
will receive
only field descriptions. Don't forget to set PacketRecords to non zero when
you will need data.
However there are hidden problem in using this way. PacketRecords := 0 means
that
TQuery will be opened on appserver and no records will be sent from
appserver to client.
But TQuery's realization is such that it will fetch one record from
database. This is not a problem
if your statement is 'select * from <some table>'. But it is a big problem
when your statement is
complex (has group by, order and etc.) because in some cases (when table is
huge or other)
database server has to do very much work to retrieve this (unnecessary for
you) first record.
P.S. But in exactly your case this method is a solution :)
"Marcelo" <mmartinez (AT) csg-consulting (DOT) com.ar> wrote
| Quote: | Hi!
I wanna get the fields of an unknown table. I use a TQuery and a "select *
from table" to open the table and then iterate trought the field list. I
access the table with a clientdataset and a remote provider. The fact is
that when I open a big table all the registers are sent to the client and
this takes a long time. How can I open a table without returning any
result
set? something like "select * from table where false.
Greetings, Marcelo.
|
|
|
| Back to top |
|
 |
Marcelo Guest
|
Posted: Tue May 25, 2004 5:39 pm Post subject: Re: How to get table fields |
|
|
Hi!
Im using SQL Server trought midas 6, but Im trying to implement a DBinf
component for a Korzh Simple Query component and should work with any remote
ODBC database, so do you think that "where 1=2" should work with any
database?
Thanks in advance, Marcelo.
"Del Murray" <Del.Murray (AT) N_S_CreditHawk (DOT) Net> escribió en el mensaje
news:40b37bd8$1 (AT) newsgroups (DOT) borland.com...
| Quote: | It depends on the database of course, which you didn't tell us anything
about :-(
you can do 'select * from sometable where 1=2' and you will get a tquery
that knows all about the columns of the table but has no rows
|
|
|
| Back to top |
|
 |
Marcelo Guest
|
Posted: Tue May 25, 2004 5:47 pm Post subject: Re: How to get table fields |
|
|
Thank you for your quick answer! Im trying it right now I seems to work
fine.
Thanks, Marcelo.
"alex" <no (AT) no (DOT) com> escribió en el mensaje
news:40b37e6a (AT) newsgroups (DOT) borland.com...
| Quote: | Set ClientDataSet.PacketRecords property to 0 before Open and after Open
you
will receive
only field descriptions. Don't forget to set PacketRecords to non zero
when
you will need data.
However there are hidden problem in using this way. PacketRecords := 0
means
that
TQuery will be opened on appserver and no records will be sent from
appserver to client.
But TQuery's realization is such that it will fetch one record from
database. This is not a problem
if your statement is 'select * from <some table>'. But it is a big problem
when your statement is
complex (has group by, order and etc.) because in some cases (when table
is
huge or other)
database server has to do very much work to retrieve this (unnecessary for
you) first record.
P.S. But in exactly your case this method is a solution :)
"Marcelo" <mmartinez (AT) csg-consulting (DOT) com.ar> wrote in message
news:40b37a98 (AT) newsgroups (DOT) borland.com...
Hi!
I wanna get the fields of an unknown table. I use a TQuery and a "select
*
from table" to open the table and then iterate trought the field list. I
access the table with a clientdataset and a remote provider. The fact is
that when I open a big table all the registers are sent to the client
and
this takes a long time. How can I open a table without returning any
result
set? something like "select * from table where false.
Greetings, Marcelo.
|
|
|
| Back to top |
|
 |
Edwin Walker Guest
|
Posted: Thu May 27, 2004 3:09 pm Post subject: Re: How to get table fields |
|
|
I never tried where 1=2, but I do where ID=-1 and I know that works.
Edwin
"Marcelo" <mmartinez (AT) csg-consulting (DOT) com.ar> wrote
| Quote: | Hi!
Im using SQL Server trought midas 6, but Im trying to implement a DBinf
component for a Korzh Simple Query component and should work with any
remote
ODBC database, so do you think that "where 1=2" should work with any
database?
Thanks in advance, Marcelo.
"Del Murray" <Del.Murray (AT) N_S_CreditHawk (DOT) Net> escribió en el mensaje
news:40b37bd8$1 (AT) newsgroups (DOT) borland.com...
It depends on the database of course, which you didn't tell us anything
about :-(
you can do 'select * from sometable where 1=2' and you will get a tquery
that knows all about the columns of the table but has no rows
|
|
|
| Back to top |
|
 |
Geert Gruwez Guest
|
Posted: Wed Jun 09, 2004 6:34 am Post subject: Re: How to get table fields |
|
|
The ID=-1 will only work if the table has a column with a field ID
1=2 will always work on the other hand !
Geert
"Edwin Walker" <enwalker (AT) ameritech (DOT) net> schreef in bericht
news:40b60406$1 (AT) newsgroups (DOT) borland.com...
| Quote: | I never tried where 1=2, but I do where ID=-1 and I know that works.
Edwin
"Marcelo" <mmartinez (AT) csg-consulting (DOT) com.ar> wrote in message
news:40b38497 (AT) newsgroups (DOT) borland.com...
Hi!
Im using SQL Server trought midas 6, but Im trying to implement a DBinf
component for a Korzh Simple Query component and should work with any
remote
ODBC database, so do you think that "where 1=2" should work with any
database?
Thanks in advance, Marcelo.
"Del Murray" <Del.Murray (AT) N_S_CreditHawk (DOT) Net> escribió en el mensaje
news:40b37bd8$1 (AT) newsgroups (DOT) borland.com...
It depends on the database of course, which you didn't tell us
anything
about :-(
you can do 'select * from sometable where 1=2' and you will get a
tquery
that knows all about the columns of the table but has no rows
|
|
|
| Back to top |
|
 |
|