Files
harbour-core/harbour/contrib/hbpgsql/tests/simple.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

170 lines
3.7 KiB
Plaintext

/*
* $Id$
*/
#include "common.ch"
Function 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:Error()
quit
endif
oServer:SetVerbosity(2)
oServer:traceon('lixo.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:Error()
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) "
cQuery += "VALUES( " + str(i) + ", 2, 'TEST', 'y', 5, 3000, 1500.2, 7.5, '12-22-2003', 'Short Description about what ? ')"
oQuery := oServer:Query(cQuery)
if oQuery:neterr()
? oQuery:error()
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 nil