* 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
169 lines
3.7 KiB
Plaintext
169 lines
3.7 KiB
Plaintext
/*
|
|
* $Id$
|
|
*/
|
|
|
|
#require "hbpgsql"
|
|
|
|
PROCEDURE Main( cHost, cDatabase, cUser, cPass )
|
|
LOCAL oServer, oQuery, oRow, i, x, aTables, aStruct
|
|
|
|
LOCAL cQuery
|
|
|
|
oServer := TPQServer():New( cHost, cDatabase, cUser, cPass )
|
|
|
|
IF oServer:NetErr()
|
|
? oServer:ErrorMsg()
|
|
QUIT
|
|
ENDIF
|
|
|
|
oServer:SetVerbosity( 2 )
|
|
oServer:traceon( "simple.log" )
|
|
|
|
? "Tables..."
|
|
|
|
FOR x := 1 TO 1
|
|
aTables := oServer:ListTables()
|
|
|
|
FOR i := 1 TO Len( aTables )
|
|
? aTables[ i ]
|
|
NEXT
|
|
NEXT
|
|
|
|
IF oServer:TableExists( "TEST" )
|
|
? oQuery := oServer:Execute( "DROP TABLE Test" )
|
|
|
|
oQuery:Destroy()
|
|
ENDIF
|
|
|
|
? "Creating test table..."
|
|
cQuery := "CREATE TABLE test("
|
|
cQuery += " Code integer not null primary key, "
|
|
cQuery += " dept Integer, "
|
|
cQuery += " Name Varchar(40), "
|
|
cQuery += " Sales boolean, "
|
|
cQuery += " Tax Float4, "
|
|
cQuery += " Salary Double Precision, "
|
|
cQuery += " Budget Numeric(12,2), "
|
|
cQuery += " Discount Numeric(5,2), "
|
|
cQuery += " Creation Date, "
|
|
cQuery += " Description text ) "
|
|
|
|
oQuery := oServer:Query( cQuery )
|
|
|
|
IF oQuery:neterr()
|
|
? oQuery:ErrorMsg()
|
|
ENDIF
|
|
|
|
oQuery:Destroy()
|
|
|
|
? "Structure of test table"
|
|
aStruct := oServer:TableStruct( "test" )
|
|
|
|
FOR i := 1 TO Len( aStruct )
|
|
?
|
|
FOR x := 1 TO Len( aStruct[ i ] )
|
|
?? aStruct[ i ][ x ], " "
|
|
NEXT
|
|
NEXT
|
|
|
|
? "Inserting, declared transaction control "
|
|
oServer:StartTransaction()
|
|
|
|
FOR i := 1 TO 10
|
|
cQuery := "INSERT INTO test(code, dept, name, sales, tax, salary, budget, Discount, Creation, Description) " +;
|
|
"VALUES( " + Str( i ) + ', 2, "TEST", "y", 5, 3000, 1500.2, 7.5, "2003-12-17", "Short Description about what ? ")'
|
|
|
|
oQuery := oServer:Query( cQuery )
|
|
|
|
IF oQuery:neterr()
|
|
? oQuery:errorMsg()
|
|
ENDIF
|
|
|
|
oQuery:destroy()
|
|
NEXT
|
|
|
|
oServer:Commit()
|
|
|
|
oQuery := oServer:Query( "SELECT code, name, description, sales FROM test" )
|
|
|
|
aStruct := oQuery:Struct()
|
|
|
|
FOR i := 1 TO Len( aStruct )
|
|
? aStruct[ i ][ 1 ], aStruct[ i ][ 2 ], aStruct[ i ][ 3 ], aStruct[ i ][ 4 ]
|
|
NEXT
|
|
|
|
? "Fields: ", oQuery:Fcount()
|
|
|
|
oRow := oQuery:Blank()
|
|
|
|
? oRow:FCount(), ;
|
|
oRow:Fieldpos( "sales" ), ;
|
|
oRow:Fieldget( 1 ), ;
|
|
oRow:Fieldname( 2 ), ;
|
|
oRow:Fieldtype( 1 ), ;
|
|
oRow:Fielddec( 1 ), ;
|
|
oRow:Fieldlen( 1 )
|
|
|
|
oRow:Fieldput( 1, 150 )
|
|
oRow:Fieldput( 2, "MY TEST" )
|
|
|
|
? oRow:Fieldget( 1 ), oRow:Fieldget( 2 )
|
|
|
|
? oRow:aRow[ 1 ], oRow:aRow[ 2 ], oRow:aOld[ 1 ], oRow:aOld[ 2 ]
|
|
|
|
? oQuery:Append( oRow )
|
|
|
|
? oQuery:ErrorMsg()
|
|
|
|
DO WHILE ! oQuery:Eof()
|
|
? oQuery:Recno(),;
|
|
oQuery:Fieldpos( "code" ),;
|
|
oQuery:Fieldget( oQuery:Fieldpos( "code" ) ), ;
|
|
oQuery:Fieldget( 4 ), ;
|
|
oQuery:Fieldget( 2 ), ;
|
|
oQuery:Fieldname( 1 ),;
|
|
oQuery:Fieldtype( 1 ), ;
|
|
oQuery:Fielddec( 1 ), ;
|
|
oQuery:Fieldlen( 1 ),;
|
|
oQuery:Fieldget( 3 )
|
|
|
|
IF oQuery:Recno() == 50
|
|
oRow := oQuery:getrow()
|
|
|
|
oRow:Fieldput( 2, "My Second test" )
|
|
? "Update: ", oQuery:Update( oRow )
|
|
ENDIF
|
|
|
|
IF oQuery:Recno() == 60
|
|
oRow := oQuery:getrow()
|
|
? "Delete: ", oQuery:Delete( oRow )
|
|
ENDIF
|
|
|
|
oQuery:Skip()
|
|
|
|
ENDDO
|
|
|
|
oQuery:Refresh()
|
|
|
|
FOR i := 1 TO oQuery:Lastrec()
|
|
oRow := oQuery:getrow( i )
|
|
|
|
? i, oRow:Fieldget( oRow:Fieldpos( "code" ) ),;
|
|
oRow:Fieldget( 4 ),;
|
|
oRow:Fieldget( 2 ),;
|
|
oRow:Fieldname( 1 ),;
|
|
oRow:Fieldtype( 1 ),;
|
|
oRow:Fielddec( 1 ),;
|
|
oRow:Fieldlen( 1 ),;
|
|
oRow:Fieldget( i, 3 )
|
|
|
|
NEXT
|
|
|
|
oQuery:Destroy()
|
|
|
|
oServer:Destroy()
|
|
|
|
? "Closing..."
|
|
|
|
RETURN
|