Postgresql to Delphi

Started by Bob Pawleyabout 19 years ago12 messagesgeneral
Jump to latest
#1Bob Pawley
rjpawley@shaw.ca

Hi

I have posed this question to the Delphi list but they don't appear to be able to help.

I am attempting to have the information in a PostgreSQL database table trigger a function in Delphi.

At present the delphi application is triggered by a mouseup on a TImage file, residing in a notebook, through an alias (DeviceNotebookMouseUpAlias). I want to have the Postgres use this alias to trigger the function.

Could someone point me to any literature that would help me with this project?

Bob Pawley

#2Andrej Ricnik-Bay
andrej.groups@gmail.com
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

On 3/21/07, Bob Pawley <rjpawley@shaw.ca> wrote:

Hi

I have posed this question to the Delphi list but they don't appear to be
able to help.

I am attempting to have the information in a PostgreSQL database table
trigger a function in Delphi.

I believe that you'd need to have an untrusted language binding
to be able to call code that's not within postgres, and as far as I
know (I know very little about supported languages, though) there's
no Pascal/Delphi language support.

At present the delphi application is triggered by a mouseup on a TImage
file, residing in a notebook, through an alias
(DeviceNotebookMouseUpAlias). I want to have the Postgres use this alias to
trigger the function.

Could someone point me to any literature that would help me with this
project?

What are you trying to achieve?

Bob Pawley

Cheers,
Andrej

--
Please don't top post, and don't use HTML e-Mail :} Make your quotes concise.

http://www.american.edu/econ/notes/htmlmail.htm

#3Richard Huxton
dev@archonet.com
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

Bob Pawley wrote:

Hi

I have posed this question to the Delphi list but they don't appear
to be able to help.

I am attempting to have the information in a PostgreSQL database
table trigger a function in Delphi.

Not sure what the Delphi stuff was on about - not my field. You've
basically got three options for triggering events though:
1. Poll from the client app
2. LISTEN/NOTIFY
3. Some privileged procedural function that writes to a file or sends a
packet etc.

Polling is inefficient, and doesn't sound responsive enough for you.
LISTEN/NOTIFY might be the best bet if your drivers can support it.

--
Richard Huxton
Archonet Ltd

#4Bob Pawley
rjpawley@shaw.ca
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

Each time the user wants a new device displayed he needs to click on the
TImage. This is time consuming and prone to error.

I have a list of devices in a PostgreSQL table. I want that table list to
trigger the Delphi app instead of the user.

I'm just learning Delphi. It seems that the error indicates an
incompatibility between the table's TStringField class and the TImage class.
Perhaps if I could solve that challenge I may be able to figure out the
rest.

Bob

----- Original Message -----
From: "Andrej Ricnik-Bay" <andrej.groups@gmail.com>
To: "Bob Pawley" <rjpawley@shaw.ca>; "PostgreSQL"
<pgsql-general@postgresql.org>
Sent: Tuesday, March 20, 2007 1:13 PM
Subject: Re: [GENERAL] Postgresql to Delphi

Show quoted text

On 3/21/07, Bob Pawley <rjpawley@shaw.ca> wrote:

Hi

I have posed this question to the Delphi list but they don't appear to be
able to help.

I am attempting to have the information in a PostgreSQL database table
trigger a function in Delphi.

I believe that you'd need to have an untrusted language binding
to be able to call code that's not within postgres, and as far as I
know (I know very little about supported languages, though) there's
no Pascal/Delphi language support.

At present the delphi application is triggered by a mouseup on a TImage
file, residing in a notebook, through an alias
(DeviceNotebookMouseUpAlias). I want to have the Postgres use this alias
to
trigger the function.

Could someone point me to any literature that would help me with this
project?

What are you trying to achieve?

Bob Pawley

Cheers,
Andrej

--
Please don't top post, and don't use HTML e-Mail :} Make your quotes
concise.

http://www.american.edu/econ/notes/htmlmail.htm

---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

#5Tony Caduto
tony_caduto@amsoftwaredesign.com
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

Bob Pawley wrote:

Hi

I have posed this question to the Delphi list but they don't appear to
be able to help.

I am attempting to have the information in a PostgreSQL database table
trigger a function in Delphi.

At present the delphi application is triggered by a mouseup on a
TImage file, residing in a notebook, through an alias
(DeviceNotebookMouseUpAlias). I want to have the Postgres use this
alias to trigger the function.

Could someone point me to any literature that would help me with this
project?

Bob Pawley

I would have replied to the Delphi List if I had seen it :-)

The best way would be to use the listen/notify that PostgreSQL provides,
but only a couple of the Delphi libraries support
notifications from PostgreSQL, zeoslib does not work at all, nor will
the PGSQL driver that shipped with Kylix.
PostgresDAC from Microolap (http://www.microolap.com) will work with
notifications and they have pretty decent support.
If you prefer Dbexpress you could try the driver from www.vitavoom.com
which has support for notifications, but it is a bit pricey compared to
the Microolap product. There is also a library for libpq.dll out there
if you want to code really low level.

And for those out there who don't know what Delphi is, check out
http://www.codegear.com
It's basically Visual Object Pascal and works very similar to VB
version 6, except it has full support for inheritance etc and can
program down to the bare metal using inline Assembler if you really need
to do that :-) It also has full support for pointers etc so you can
pretty much get the performance of C or C++ all in the same package.
Using Delphi for database applications is like being in Paradise all the
time :-)

Later,

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Built with CodeGear Delphi 2007
Your best bet for Postgresql Administration

#6Andrej Ricnik-Bay
andrej.groups@gmail.com
In reply to: Bob Pawley (#4)
Re: Postgresql to Delphi

On 3/21/07, Bob Pawley <rjpawley@shaw.ca> wrote:

Each time the user wants a new device displayed he needs to click on the
TImage. This is time consuming and prone to error.

I guess I must be too obtuse to follow; how will the database
know when the user wants to see a new device if not by
way of your application (which in turn will know from user
interaction)?

Bob

Cheers,
Andrej

#7Geoffrey
esoteric@3times25.net
In reply to: Andrej Ricnik-Bay (#6)
Re: Postgresql to Delphi

Andrej Ricnik-Bay wrote:

On 3/21/07, Bob Pawley <rjpawley@shaw.ca> wrote:

Each time the user wants a new device displayed he needs to click on the
TImage. This is time consuming and prone to error.

I guess I must be too obtuse to follow; how will the database
know when the user wants to see a new device if not by
way of your application (which in turn will know from user
interaction)?

Computer telepathy?

--
Until later, Geoffrey

Those who would give up essential Liberty, to purchase a little
temporary Safety, deserve neither Liberty nor Safety.
- Benjamin Franklin

#8Bob Pawley
rjpawley@shaw.ca
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

Listen/notify implies a dynamic table that is constantly on the change. Am I
correct?

The table I am talking about is completed through one interface then
imported as a relatively static information base for the application in
which I am seeking help.

Bob

----- Original Message -----
From: "Tony Caduto" <tony_caduto@amsoftwaredesign.com>
To: "Bob Pawley" <rjpawley@shaw.ca>; <pgsql-general@postgresql.org>
Sent: Tuesday, March 20, 2007 2:16 PM
Subject: Re: [GENERAL] Postgresql to Delphi

Show quoted text

Bob Pawley wrote:

Hi
I have posed this question to the Delphi list but they don't appear to
be able to help.
I am attempting to have the information in a PostgreSQL database table
trigger a function in Delphi.
At present the delphi application is triggered by a mouseup on a TImage
file, residing in a notebook, through an alias
(DeviceNotebookMouseUpAlias). I want to have the Postgres use this alias
to trigger the function.
Could someone point me to any literature that would help me with this
project?
Bob Pawley

I would have replied to the Delphi List if I had seen it :-)

The best way would be to use the listen/notify that PostgreSQL provides,
but only a couple of the Delphi libraries support
notifications from PostgreSQL, zeoslib does not work at all, nor will the
PGSQL driver that shipped with Kylix.
PostgresDAC from Microolap (http://www.microolap.com) will work with
notifications and they have pretty decent support.
If you prefer Dbexpress you could try the driver from www.vitavoom.com
which has support for notifications, but it is a bit pricey compared to
the Microolap product. There is also a library for libpq.dll out there
if you want to code really low level.

And for those out there who don't know what Delphi is, check out
http://www.codegear.com
It's basically Visual Object Pascal and works very similar to VB version
6, except it has full support for inheritance etc and can program down to
the bare metal using inline Assembler if you really need to do that :-) It
also has full support for pointers etc so you can pretty much get the
performance of C or C++ all in the same package. Using Delphi for
database applications is like being in Paradise all the time :-)

Later,

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Built with CodeGear Delphi 2007
Your best bet for Postgresql Administration

#9Bob Pawley
rjpawley@shaw.ca
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

The user clicks on a button. A Query component, connected to the button, and
the structure of the database determines how many of the devices will be
triggered in the application.

I envision triggering a "loop" which is from one to seven devices with one
button or a specific series of loops with a second button. (Perhaps an
entire project of loops with a third button.)

Bob

----- Original Message -----
From: "Andrej Ricnik-Bay" <andrej.groups@gmail.com>
To: "Bob Pawley" <rjpawley@shaw.ca>
Cc: "PostgreSQL" <pgsql-general@postgresql.org>
Sent: Tuesday, March 20, 2007 2:28 PM
Subject: Re: [GENERAL] Postgresql to Delphi

Show quoted text

On 3/21/07, Bob Pawley <rjpawley@shaw.ca> wrote:

Each time the user wants a new device displayed he needs to click on the
TImage. This is time consuming and prone to error.

I guess I must be too obtuse to follow; how will the database
know when the user wants to see a new device if not by
way of your application (which in turn will know from user
interaction)?

Bob

Cheers,
Andrej

#10Tony Caduto
tony_caduto@amsoftwaredesign.com
In reply to: Bob Pawley (#8)
Re: Postgresql to Delphi

Bob Pawley wrote:

Listen/notify implies a dynamic table that is constantly on the
change. Am I correct?

The table I am talking about is completed through one interface then
imported as a relatively static information base for the application
in which I am seeking help.

Yes,
you would have to define a rule on the table and when the table changed
it would send a notification back to who ever is listening.

Why don't you just run a query against the table, then loop through the
result set and then trigger your devices from inside the loop?

myquery.sql.add('select * from mytable where bla = bla;');
myquery.open;
While not myquery.eof do
begin

if myquery.fieldbyname('somefield').asstring = 'something' then
//signal your device.
myquery.next;
end;

I guess that is the best I can come up without knowing more.

Later,

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration

#11Bob Pawley
rjpawley@shaw.ca
In reply to: Bob Pawley (#1)
Re: Postgresql to Delphi

I think that may be what I have been trying to do.

Can you point me to some literature on how to do that? I'm just learning the
basics of Delphi and the documenation I've seen so far hasn't been very
specific.

Bob

----- Original Message -----
From: "Tony Caduto" <tony_caduto@amsoftwaredesign.com>
To: "Bob Pawley" <rjpawley@shaw.ca>
Cc: <pgsql-general@postgresql.org>
Sent: Tuesday, March 20, 2007 3:07 PM
Subject: Re: [GENERAL] Postgresql to Delphi

Show quoted text

Bob Pawley wrote:

Listen/notify implies a dynamic table that is constantly on the change.
Am I correct?

The table I am talking about is completed through one interface then
imported as a relatively static information base for the application in
which I am seeking help.

Yes,
you would have to define a rule on the table and when the table changed it
would send a notification back to who ever is listening.

Why don't you just run a query against the table, then loop through the
result set and then trigger your devices from inside the loop?

myquery.sql.add('select * from mytable where bla = bla;');
myquery.open;
While not myquery.eof do
begin
if myquery.fieldbyname('somefield').asstring = 'something' then
//signal your device.
myquery.next;
end;

I guess that is the best I can come up without knowing more.

Later,

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration

#12Arthur Hoogervorst
arthur.hoogervorst@gmail.com
In reply to: Bob Pawley (#11)
Re: Postgresql to Delphi

Hi:

There are a couple of solutions to solve this problem and some of them
will depend on how frequent you expect these changes to happen.

I generally stay clear from server-specific notifications: In the
larger projects I have seen and maintained, we used background
processes to do this kind of stuff: shell scripts calling external
applications on regular intervals. For smaller projects, I would just
do this (in a timely fashion) internally in my 'user'/client
application.

As for Delphi: Tony is too much of a fan of this particular language
:-) [no offense meant, since I've been working for years in Delphi
too]

Regards,

Arthur

Show quoted text

On 3/20/07, Bob Pawley <rjpawley@shaw.ca> wrote:

I think that may be what I have been trying to do.

Can you point me to some literature on how to do that? I'm just learning the
basics of Delphi and the documenation I've seen so far hasn't been very
specific.

Bob

----- Original Message -----
From: "Tony Caduto" <tony_caduto@amsoftwaredesign.com>
To: "Bob Pawley" <rjpawley@shaw.ca>
Cc: <pgsql-general@postgresql.org>
Sent: Tuesday, March 20, 2007 3:07 PM
Subject: Re: [GENERAL] Postgresql to Delphi

Bob Pawley wrote:

Listen/notify implies a dynamic table that is constantly on the change.
Am I correct?

The table I am talking about is completed through one interface then
imported as a relatively static information base for the application in
which I am seeking help.

Yes,
you would have to define a rule on the table and when the table changed it
would send a notification back to who ever is listening.

Why don't you just run a query against the table, then loop through the
result set and then trigger your devices from inside the loop?

myquery.sql.add('select * from mytable where bla = bla;');
myquery.open;
While not myquery.eof do
begin
if myquery.fieldbyname('somefield').asstring = 'something' then
//signal your device.
myquery.next;
end;

I guess that is the best I can come up without knowing more.

Later,

--
Tony Caduto
AM Software Design
http://www.amsoftwaredesign.com
Home of PG Lightning Admin for Postgresql
Your best bet for Postgresql Administration

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster