* contrib/hbblat/tests/blatcmd.prg
* contrib/hbblat/tests/blattest.prg
* contrib/hbbz2/tests/test.prg
* contrib/hbcomm/tests/test.prg
* contrib/hbcups/tests/test.prg
* contrib/hbexpat/tests/test.prg
* contrib/hbexpat/tests/tohash.prg
* contrib/hbfbird/tests/simple.prg
* contrib/hbfbird/tests/stress.prg
* contrib/hbfbird/tests/test.prg
* contrib/hbfimage/tests/fitest.prg
* contrib/hbgs/tests/testgs.prg
* contrib/hbhpdf/tests/harupdf.prg
* contrib/hblzf/tests/test.prg
* contrib/hbmagic/tests/hbmagit.prg
* contrib/hbmemio/tests/test.prg
* contrib/hbmxml/tests/custom.prg
* contrib/hbmxml/tests/reminder.prg
* contrib/hbmxml/tests/testmxml.prg
* contrib/hbmysql/tests/test.prg
* contrib/hbmzip/tests/myunzip.prg
* contrib/hbmzip/tests/myzip.prg
* contrib/hbodbc/tests/odbccall.prg
* contrib/hbodbc/tests/odbcdemo.prg
* contrib/hbodbc/tests/testodbc.prg
* contrib/hbpgsql/tests/async.prg
* contrib/hbpgsql/tests/cache.prg
* contrib/hbpgsql/tests/dbf2pg.prg
* contrib/hbpgsql/tests/simple.prg
* contrib/hbpgsql/tests/stress.prg
* contrib/hbpgsql/tests/test.prg
* contrib/hbsms/tests/send.prg
* contrib/hbsqlit3/tests/authoriz.prg
* contrib/hbsqlit3/tests/backup.prg
* contrib/hbsqlit3/tests/blob.prg
* contrib/hbsqlit3/tests/hdbctest.prg
* contrib/hbsqlit3/tests/hooks.prg
* contrib/hbsqlit3/tests/metadata.prg
* contrib/hbsqlit3/tests/pack.prg
* contrib/hbsqlit3/tests/sl3_test.prg
* contrib/hbssl/tests/bio.prg
* contrib/hbssl/tests/crypt.prg
* contrib/hbssl/tests/digest.prg
* contrib/hbssl/tests/encode.prg
* contrib/hbssl/tests/pem.prg
* contrib/hbssl/tests/test.prg
* contrib/hbtip/tests/base64.prg
* contrib/hbtip/tests/dbtohtml.prg
* contrib/hbtip/tests/dnldftp.prg
* contrib/hbtip/tests/ftpadv.prg
* contrib/hbtip/tests/gmail.prg
* contrib/hbtip/tests/httpadv.prg
* contrib/hbtip/tests/loadhtml.prg
* contrib/hbtip/tests/test01.prg
* contrib/hbtip/tests/tipmail.prg
* contrib/hbtip/tests/tipmime.prg
* contrib/hbtip/tests/tipmmail.prg
* contrib/hbtip/tests/tiptest.prg
* contrib/hbtip/tests/tiptime.prg
* contrib/hbtip/tests/upld_ftp.prg
* contrib/hbtpathy/tests/testtp.prg
* contrib/hbunix/tests/testdmn.prg
* contrib/hbunix/tests/testpid.prg
* contrib/hbxdiff/tests/test.prg
* contrib/hbxdiff/tests/test2.prg
* contrib/hbxdiff/tests/test3.prg
* contrib/rddsql/tests/arrayrdd.prg
* contrib/sddsqlt3/tests/test1.prg
* contrib/xhb/tests/compress.prg
* contrib/xhb/tests/dll.prg
* contrib/xhb/tests/testcp.prg
* contrib/xhb/tests/xml1.prg
+ added #require directives, so the tests can now
be run as scripts. It will require a dynamically
built hbrun and contrib dlls. To make them, use:
HB_BUILD_CONTRIB_DYN=yes and rebuild Harbour.
* minor cleanups along the way
; RDDSQL fails in RDDSETDEFAULT().
* contrib/gtwvg/toolbar.prg
! fixed yet another != (disguised as <>) operator on string
94 lines
2.6 KiB
Plaintext
94 lines
2.6 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
#require "hbpgsql"
|
|
|
|
#include "postgres.ch"
|
|
|
|
PROCEDURE main()
|
|
LOCAL conn, res, aTemp, x, y, pFile
|
|
LOCAL cDb := "test"
|
|
LOCAL cUser := "user"
|
|
LOCAL cPass := "pass"
|
|
|
|
CLS
|
|
|
|
conn := PQsetdbLogin( "localhost", "5432", NIL, NIL, cDb, cUser, cPass )
|
|
? PQdb( conn ), PQuser( conn ), PQpass( conn ), PQhost( conn ), PQport( conn ), PQtty( conn ), PQoptions( conn )
|
|
|
|
conn := PQconnectDB( "dbname = " + cDb + " host = localhost user = " + cUser + " password = " + cPass + " port = 5432" )
|
|
|
|
? PQstatus( conn ), PQerrormessage( conn )
|
|
|
|
IF PQstatus( conn ) != CONNECTION_OK
|
|
QUIT
|
|
ENDIF
|
|
|
|
? "Blocking: ", PQisnonblocking( conn ), PQsetnonblocking( conn, .T. ), PQisnonblocking( conn )
|
|
|
|
pFile := PQcreatetrace( "trace.log" )
|
|
PQtrace( conn, pFile )
|
|
|
|
? "Verbose: ", PQsetErrorVerbosity( conn, 2 )
|
|
|
|
? "Protocol: ", PQprotocolVersion( conn ),;
|
|
" Server Version: ", PQserverVersion( conn ),;
|
|
" Client Encoding: ", PQsetClientEncoding( conn, "ASCII" ),;
|
|
"New encode: ", PQclientEncoding( conn )
|
|
|
|
? PQdb( conn ), PQuser( conn ), PQpass( conn ), PQhost( conn ), PQport( conn ), PQtty( conn ), PQoptions( conn )
|
|
|
|
res := PQexec( conn, "drop table products" )
|
|
? PQresultStatus( res ), PQresultErrorMessage( res )
|
|
res := NIL
|
|
|
|
res := PQexec( conn, "create table products ( product_no numeric(10), name varchar(20), price numeric(10,2) )" )
|
|
? PQresultStatus( res ), PQresultErrorMessage( res )
|
|
|
|
res := PQexecParams( conn, "insert into products(product_no, name, price) values ($1, $2, $3)", { "2", "bread", "10.95" } )
|
|
? "Oid Row: ", PQoidValue( res ), PQoidStatus( res )
|
|
|
|
IF PQresultStatus( res ) != PGRES_COMMAND_OK
|
|
? PQresultStatus( res ), PQresultErrorMessage( res )
|
|
ENDIF
|
|
|
|
res := PQexec( conn, 'select price, name, product_no as "produto" from products' )
|
|
|
|
IF PQresultStatus( res ) != PGRES_TUPLES_OK
|
|
? PQresultStatus( res ), PQresultErrorMessage( res )
|
|
ENDIF
|
|
|
|
? "Binary: ", PQbinaryTuples( res )
|
|
? "Rows: ", PQntuples( res ), "Cols: ", PQnfields( res )
|
|
? PQfname( res, 1 ), PQftable( res, 1 ), PQftype( res, 1 ), PQfnumber( res, "name" ), PQfmod( res, 1 ), PQfsize( res, 1 ), PQgetisnull( res, 1, 1 )
|
|
|
|
aTemp := PQmetadata( res )
|
|
|
|
FOR x := 1 TO Len( aTemp )
|
|
? "Linha 1: "
|
|
FOR y := 1 TO 6
|
|
?? aTemp[ x ][ y ], ", "
|
|
NEXT
|
|
NEXT
|
|
|
|
? PQFcount( res )
|
|
|
|
? PQlastrec( res )
|
|
|
|
? PQGetvalue( res, 1, 2 )
|
|
|
|
? "Large Objects, always should be in a transaction..."
|
|
|
|
PQexec( conn, "begin" )
|
|
|
|
? ( x := lo_Import( conn, "test.prg" ) )
|
|
? lo_Export( conn, x, "test.new" )
|
|
? lo_Unlink( conn, x )
|
|
|
|
PQexec( conn, "commit" )
|
|
|
|
PQuntrace( conn )
|
|
|
|
RETURN
|