Files
harbour-core/harbour/contrib/hbpgsql/tests/async.prg
Viktor Szakats 6d60145620 2012-11-07 03:28 UTC+0100 Viktor Szakats (harbour syenar.net)
* contrib/hbnf/hbnf.hbx
  * contrib/hbodbc/hbodbc.hbx
  * contrib/hbtip/hbtip.hbx
  * contrib/hbtpathy/hbtpathy.hbx
  * contrib/xhb/xhb.hbx
    ! minor fixes

  * contrib/hblzf/tests/*.prg
  * contrib/hbmxml/format.prg
  * contrib/hbmysql/tests/test.prg
  * contrib/hbmysql/tmysql.prg
  * contrib/hbmysql/tsqlbrw.prg
  * contrib/hbnetio/netiomt.prg
  * contrib/hbnetio/utils/hbnetio/*.prg
  * contrib/hbnf/*.prg
  * contrib/hbnf/tests/*.prg
  * contrib/hbodbc/tests/testodbc.prg
  * contrib/hbodbc/todbc.prg
  * contrib/hbpgsql/tests/*.prg
  * contrib/hbpgsql/tpostgre.prg
  * contrib/hbssl/tests/*.prg
  * contrib/hbtip/*.prg
  * contrib/hbtip/tests/*.prg
  * contrib/hbtpathy/telepath.prg
  * contrib/hbzebra/tests/*.prg
  * contrib/rddads/tests/*.prg
  * contrib/xhb/*.prg
  * contrib/xhb/tests/*.prg
    * formatted
    ! commented code converted to #if 0/#endif block
2012-11-07 02:57:26 +00:00

76 lines
1.6 KiB
Plaintext

/*
* $Id$
*/
/*
* This sample show howto use asynchronous/nonblocking queries
*/
#require "hbpgsql"
#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