Writing Postgres tables

Started by Michael Greer, July 09, 2021, 01:12:55 PM

Previous topic - Next topic

Michael Greer

Has anyone every written to a postgres database out of a PVX program. Any pointers would be appreciated.

Stéphane Devouard

#1
Michael


Since PxPlus does not provide a direct interface to PostgreSQL, you need to download and install the ODBC driver


The attached code connects to a database on the local machine using a DSN-less connection string


When run, it yields :


-:run
1
Family


2
Work


You can also insert to a table (very simple schema : an auto-increment id and a varchar description :

1:
1:write record (pgdb)"insert into categories (category_name) values ('Friends')"
1:write record (pgdb)"select * from categories where category_id=3"
1:?rcd(pgdb)
3
Friends


And update as well :

1:write record (pgdb)"update categories set category_name='Professional' where c
ategory_id=2"
1:write record (pgdb)"select * from categories where category_id=2"
1:?rcd(pgdb)
2
Professional
1:
Stéphane Devouard
Portfolio | Work