Files
harbour-core/harbour/contrib/hbpgsql/tests/async.prg
Viktor Szakats 70140e5aed 2012-07-22 23:52 UTC+0200 Viktor Szakats (vszakats syenar.net)
* contrib/hbct/tests/ctwtest.prg
  * contrib/hbcups/tests/test.prg
  * contrib/hbfbird/tests/stress.prg
  * contrib/hbnf/aredit.prg
  * contrib/hbnf/doc/en/aredit.txt
  * contrib/hbnf/menu1.prg
  * contrib/hbnf/popadder.prg
  * contrib/hbnf/tbwhile.prg
  * contrib/hbpgsql/tests/async.prg
  * contrib/hbpgsql/tests/cache.prg
  * contrib/hbpgsql/tests/stress.prg
  * contrib/hbpgsql/tests/test.prg
  * contrib/hbtip/tests/tiptest.prg
  * contrib/xhb/tests/compress.prg
  * doc/en/sayget.txt
  * src/rtl/profiler.prg
  * tests/ac_test.prg
  * tests/boxtst2.prg
  * tests/fortest.prg
  * tests/menutest.prg
  * tests/mt/mttest11.prg
  * tests/parseini.prg
  * tests/speedold.prg
  * tests/tstchbx.prg
  * tests/usrrdd/exarr.prg
  * tests/videotst.prg
  * tests/vidtest.prg
    * formatting
    ! deleted SetMode()s
    * CLEAR SCREEN -> CLS
    * other minor cleanups
2012-07-22 21:54:14 +00:00

72 lines
1.6 KiB
Plaintext

/*
* $Id$
*/
/*
* This sample show howto use asynchronous/nonblocking queries
*/
#include "inkey.ch"
PROCEDURE Main( cServer, cDatabase, cUser, cPass )
LOCAL conn
CLS
? "Connect", conn := PQconnectDB( "dbname = " + cDatabase + " host = " + cServer + " user = " + cUser + " password = " + cPass + " port = 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. )
RETURN
PROCEDURE Query( conn, cQuery, lCancel )
LOCAL pCancel, cErrMsg := Space( 30 )
LOCAL res, x, y, cTime
? "PQSendQuery", PQsendQuery( conn, cQuery )
cTime := Time()
CLEAR TYPEAHEAD
DO WHILE Inkey() != K_ESC
DevPos( Row(), 20 )
DevOut( "Processing: " + Elaptime( cTime, Time() ) )
Inkey( 1 )
IF lCancel
IF .T.
pCancel := PQgetCancel( conn )
? "Canceled: ", PQcancel( pCancel, @cErrMsg ), cErrMsg
pCancel := NIL
ELSE
? PQrequestCancel( conn ) /* Deprecated */
ENDIF
ENDIF
IF PQconsumeInput( conn )
IF ! PQisBusy( conn )
EXIT
ENDIF
ENDIF
ENDDO
IF Inkey() != K_ESC
? "PQgetResult", hb_valtoexp( res := PQgetResult( conn ) )
FOR x := 1 TO PQlastrec( res )
?
FOR y := 1 TO PQfcount( res )
?? PQgetvalue( res, x, y ), " "
NEXT
NEXT
ELSE
? "Canceling Query", PQrequestCancel( conn )
ENDIF
RETURN