BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to get table fields

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers)
View previous topic :: View next topic  
Author Message
Marcelo
Guest





PostPosted: Tue May 25, 2004 4:57 pm    Post subject: How to get table fields Reply with 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
Del Murray
Guest





PostPosted: Tue May 25, 2004 5:04 pm    Post subject: Re: How to get table fields Reply with 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
alex
Guest





PostPosted: Tue May 25, 2004 5:12 pm    Post subject: Re: How to get table fields Reply with 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

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





PostPosted: Tue May 25, 2004 5:39 pm    Post subject: Re: How to get table fields Reply with 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...
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





PostPosted: Tue May 25, 2004 5:47 pm    Post subject: Re: How to get table fields Reply with quote

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





PostPosted: Thu May 27, 2004 3:09 pm    Post subject: Re: How to get table fields Reply with 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

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





PostPosted: Wed Jun 09, 2004 6:34 am    Post subject: Re: How to get table fields Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (SQL Servers) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.