* harbour/bin/pack_src.sh
+ harbour/contrib/pgsql/Changelog
+ harbour/contrib/pgsql/Makefile
+ harbour/contrib/pgsql/README
+ harbour/contrib/pgsql/make_b32.bat
+ harbour/contrib/pgsql/makefile.bc
+ harbour/contrib/pgsql/pgrdd.prg
+ harbour/contrib/pgsql/postgres.c
+ harbour/contrib/pgsql/postgres.ch
+ harbour/contrib/pgsql/tpostgre.prg
+ harbour/contrib/pgsql/tstpgrdd.prg
+ harbour/contrib/pgsql/tests/Makefile
+ harbour/contrib/pgsql/tests/async.prg
+ harbour/contrib/pgsql/tests/cache.prg
+ harbour/contrib/pgsql/tests/dbf2pg.prg
+ harbour/contrib/pgsql/tests/simple.prg
+ harbour/contrib/pgsql/tests/stress.prg
+ harbour/contrib/pgsql/tests/test.prg
+ added Postgres SQL library - code borrowed from xHarbour
* harbour/source/rtl/empty.c
+ added support for HASH items
* harbour/source/rtl/itemseri.c
+ added SYMBOL items serialization
72 lines
1.8 KiB
Plaintext
72 lines
1.8 KiB
Plaintext
/*
|
|
* $Id$
|
|
*
|
|
* This sample show howto use asynchronous/nonblocking queries
|
|
*
|
|
*/
|
|
|
|
Function main()
|
|
Local conn
|
|
|
|
CLEAR SCREEN
|
|
|
|
? "Connect", conn := PQConnect('test', 'localhost', 'user', 'pass', 5432)
|
|
|
|
? "Conection status", PQerrorMessage(conn), PQstatus(conn)
|
|
|
|
Query( conn, 'SELECT codigo, descri FROM client limit 100', .f. )
|
|
Query( conn, 'SELECT codigo, descri FROM fornec limit 100', .f. )
|
|
Query( conn, 'SELECT pedido, vlrped FROM pedido', .t. )
|
|
|
|
PQclose(conn)
|
|
|
|
return nil
|
|
|
|
Procedure Query( conn, cQuery, lCancel )
|
|
Local pCancel, cErrMsg := space(30)
|
|
Local res, aTemp, i, x, y, xTime
|
|
|
|
? "PQSendQuery", PQsendQuery(conn, cQuery)
|
|
|
|
xTime := time()
|
|
CLEAR TYPEAHEAD
|
|
|
|
do while inkey() != 27
|
|
DevPos(Row(), 20)
|
|
DevOut("Processing: " + Elaptime(xtime, time()))
|
|
|
|
inkey(1)
|
|
|
|
if lCancel
|
|
if .t.
|
|
pCancel := PQgetCancel(conn)
|
|
? "Canceled: ", PQcancel( pCancel, @cErrMsg ), cErrMsg
|
|
PQfreeCancel(pCancel)
|
|
|
|
else
|
|
? PQrequestCancel(conn) // Deprecated
|
|
endif
|
|
endif
|
|
|
|
if PQconsumeInput(conn)
|
|
if ! PQisBusy(conn)
|
|
exit
|
|
endif
|
|
endif
|
|
enddo
|
|
|
|
if inkey() != 27
|
|
? "PQgetResult", valtoprg(res := PQgetResult(conn))
|
|
|
|
for x := 1 to PQlastrec(res)
|
|
?
|
|
for y := 1 to PQfcount(res)
|
|
?? PQgetvalue(res, x, y), " "
|
|
next
|
|
next
|
|
|
|
PQclear(res)
|
|
else
|
|
? "Canceling Query", PQrequestCancel(conn)
|
|
endif
|
|
Return |