Files
harbour-core/harbour/contrib/hbpgsql/tests/test.prg
Viktor Szakats b937df971b 2009-03-25 14:09 UTC+0100 Viktor Szakats (harbour.01 syenar hu)
* INSTALL
    + Added HB_INC_SQLITE3

  * include/hbapi.h
    + Added HB_IS*() flavour of classic Clipper compatibility IS*()
      macros. I'd recommend everyone to start using these new ones,
      as the old ones might be deprecated in future versions.

  * Makefile
    + Added new 'external' dir to host foreign, non-Harbour code.

  + external
  + external/sqlite3
  + external/sqlite3/_sqlite3.c
  + external/sqlite3/sqlite3.c
  + external/sqlite3/sqlite3.h
  + external/sqlite3/Makefile
  - contrib/hbsqlit3/sqlite3
    + Moved sqlite3 code into its dedicated place.

  * contrib/hbsqlit3/tests/hbsqlit3.hbp
    + Added sqlite3 to liblist.

  * contrib/hbsqlit3/hbsqlit3.c
  * contrib/hbsqlit3/Makefile
    + Changed to use external headers just like other external
      dependent libs. The only difference here is that it will
      pickup the locally hosted sqlite3 source from
      external/sqlite3 if not specified by user.
    * Changed to no embed sqlite3 code anymore.
      ATTENTION: This also means that hbsqlit3 users will now
                 have to add sqlite3 lib to their liblist, since
                 this code isn't anymore embedded into hbsqlit3.

  * contrib/hbqt/hbqt_qfontcombobox.cpp
  * contrib/hbqt/hbqt_qgroupbox.cpp
  * contrib/hbqt/hbqt_qcombobox.cpp
  * contrib/hbqt/hbqt_qtoolbutton.cpp
  * contrib/hbqt/slots.h
  * contrib/hbqt/hbqt_qpushbutton.cpp
  * contrib/hbqt/hbqt_qpagesetupdialog.cpp
  * contrib/hbqt/hbqt_qprintpreviewdialog.cpp
  * contrib/hbqt/hbqt_qlabel.cpp
  * contrib/hbqt/hbqt_qinputdialog.cpp
  * contrib/hbqt/hbqt_qprogressdialog.cpp
  * contrib/hbqt/hbqt_qtoolbox.cpp
  * contrib/hbqt/hbqt_qcommandlinkbutton.cpp
  * contrib/hbqt/hbqt_qmenubar.cpp
  * contrib/hbqt/hbqt_qhboxlayout.cpp
  * contrib/hbqt/hbqt_qabstractbutton.cpp
  * contrib/hbqt/hbqt_qabstractprintdialog.cpp
  * contrib/hbqt/hbqt_qwizard.cpp
  * contrib/hbqt/hbqt_qabstractspinbox.cpp
  * contrib/hbqt/hbqt_qfont.cpp
  * contrib/hbqt/hbqt_qdial.cpp
  * contrib/hbqt/hbqt_qtablewidgetitem.cpp
  * contrib/hbqt/hbqt_qlcdnumber.cpp
  * contrib/hbqt/hbqt_qmainwindow.cpp
  * contrib/hbqt/hbqt_qprintdialog.cpp
  * contrib/hbqt/hbqt_qcalendarwidget.cpp
  * contrib/hbqt/hbqt_qabstractitemview.cpp
  * contrib/hbqt/hbqt_qaction.cpp
  * contrib/hbqt/hbqt_qspinbox.cpp
  * contrib/hbqt/hbqt_qwidget.cpp
  * contrib/hbqt/hbqt_slots.cpp
  * contrib/hbqt/hbqt_qdateedit.cpp
  * contrib/hbqt/hbqt_qcheckbox.cpp
  * contrib/hbqt/hbqt_qprogressbar.cpp
  * contrib/hbqt/hbqt_qframe.cpp
  * contrib/hbqt/hbqt_qfocusframe.cpp
  * contrib/hbqt/hbqt_qtabbar.cpp
  * contrib/hbqt/hbqt_qcqlendarwidget.cpp
  * contrib/hbqt/hbqt_qerrormessage.cpp
  * contrib/hbqt/hbqt_qfiledialog.cpp
  * contrib/hbqt/hbqt_qformlayout.cpp
  * contrib/hbqt/hbqt_qtoolbar.cpp
  * contrib/hbqt/hbqt_qdatetimeedit.cpp
  * contrib/hbqt/hbqt_qmenu.cpp
  * contrib/hbqt/hbqt_qabstractslider.cpp
  * contrib/hbqt/hbqt_qwebview.cpp
  * contrib/hbqt/hbqt_qlayout.cpp
  * contrib/hbqt/hbqt_qslider.cpp
  * contrib/hbqt/hbqt_qtableview.cpp
  * contrib/hbqt/hbqt_qfontdialog.cpp
  * contrib/hbqt/hbqt_qboxlayout.cpp
  * contrib/hbqt/hbqt_qtreeview.cpp
  * contrib/hbqt/hbqt_qtextedit.cpp
  * contrib/hbqt/hbqt_qradiobutton.cpp
  * contrib/hbqt/hbqt_qcolordialog.cpp
  * contrib/hbqt/hbqt_qapplication.cpp
  * contrib/hbqt/hbqt_qtimeedit.cpp
  * contrib/hbqt/hbqt_qsplitter.cpp
  * contrib/hbqt/hbqt_qlistview.cpp
  * contrib/hbqt/hbqt_qtabwidget.cpp
  * contrib/hbqt/hbqt_qabstractscrollarea.cpp
  * contrib/hbqt/hbqt_qvboxlayout.cpp
  * contrib/hbqt/hbqt_qdoublespinbox.cpp
  * contrib/hbqt/hbqt_qscrollbar.cpp
  * contrib/hbqt/hbqt_qscrollarea.cpp
  * contrib/hbqt/hbqt_qtablewidget.cpp
  * contrib/hbqt/hbqt_qsizegrip.cpp
  * contrib/hbqt/hbqt_qlayoutitem.cpp
  * contrib/hbqt/hbqt_qmessagebox.cpp
  * contrib/hbqt/hbqt_qlineedit.cpp
    * Formatting, indenting.
    ! ISNIL() usage removed.

  * contrib/hbwin/wapi_commctrl.c
  * contrib/hbwin/wapi_winuser.c
    ! ISNIL() usage removed.

  * contrib/hbfbird/tfirebrd.prg
  * contrib/hbpgsql/tests/simple.prg
  * contrib/hbpgsql/tests/test.prg
  * contrib/hbpgsql/tests/cache.prg
  * contrib/hbpgsql/tests/stress.prg
  * contrib/hbpgsql/tests/dbf2pg.prg
  * contrib/hbpgsql/tpostgre.prg
  * contrib/examples/uhttpd/uhttpd.prg
  * contrib/examples/uhttpd/uhttpdc.c
  * contrib/examples/terminal/trm_server.prg
    * ISNIL() usage and other code cleanup, formatting.
2009-03-25 13:22:38 +00:00

100 lines
2.7 KiB
Plaintext

/*
* $Id$
*/
#include "../postgres.ch"
Function main()
Local conn, res, aTemp, i, x,y, pFile
Local cDb := 'test'
Local cUser := 'user'
Local cPass := 'pass'
CLEAR SCREEN
conn := PQsetdbLogin( 'localhost', "5432", NIL, NIL, cDb, cUser, cPass)
? PQdb(conn), PQuser(conn), PQpass(conn), PQhost(conn), PQport(conn), PQtty(conn), PQoptions(conn)
? PQClose(conn)
conn := PQConnect(cDb, 'localhost', cuser, cpass, 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('drop table products')
? PQresultStatus(res), PQresultErrorMessage(res)
PQclear(res)
res := PQexec('create table products ( product_no numeric(10), name varchar(20), price numeric(10,2) )')
? PQresultStatus(res), PQresultErrorMessage(res)
PQclear(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
PQclear(res)
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)
? PQclear(res)
? "Large Objects, always should be in a transaction..."
res := PQexec(conn, 'begin')
PQclear(res)
? (x := lo_Import( conn, 'test.prg' ))
? lo_Export( conn, x, 'test.new' )
? lo_Unlink( conn, x )
res := PQexec(conn, 'commit')
PQclear(res)
PQuntrace( conn )
PQclosetrace( pFile )
PQClose(conn)
return nil