Files
harbour-core/harbour/contrib/hbmysql/tests/test.prg
Viktor Szakats 44caa6f70e 2012-07-21 13:55 UTC+0200 Viktor Szakats (vszakats syenar.net)
* contrib/hbide/idemain.prg
  * contrib/hbmysql/tests/test.prg
  * contrib/hbmysql/utils/dbf2mysq.prg
  * contrib/hbpgsql/tests/dbf2pg.prg
  * examples/hbapollo/tests/test02.prg
  * examples/hbapollo/tests/test05.prg
  * examples/hbapollo/tests/test07.prg
  * examples/hbapollo/tests/test08.prg
  * examples/hbapollo/tests/test11.prg
  * examples/hbapollo/tests/test12.prg
  * examples/hbapollo/tests/test13.prg
  * examples/hbapollo/tests/test14.prg
  * examples/hbapollo/tests/test15.prg
  * examples/hbapollo/tests/test20.prg
  * examples/hbapollo/tests/test21.prg
  * examples/hbapollo/tests/test22.prg
  * examples/hbapollo/tests/test23.prg
  * examples/hbapollo/tests/test24.prg
  * examples/hbapollo/tests/test25.prg
  * examples/hbapollo/tests/test26.prg
  * examples/hbapollo/tests/test27.prg
  * examples/hbapollo/tests/test28.prg
  * examples/hbapollo/tests/test29.prg
  * examples/hbapollo/tests/test30.prg
  * examples/hbapollo/tests/test34.prg
  * examples/hbapollo/tests/test35.prg
  * examples/hbapollo/tests/test36.prg
  * examples/hbapollo/tests/test37.prg
  * examples/hbapollo/tests/test38.prg
  * examples/hbapollo/tests/test39.prg
  * examples/hbapollo/tests/test41.prg
  * examples/hbapollo/tests/test42.prg
  * examples/hbapollo/tests/test43.prg
  * examples/hbapollo/tests/test45.prg
  * examples/hbapollo/tests/test46.prg
  * examples/hbapollo/tests/test47.prg
  * examples/hbapollo/tests/test50.prg
  * examples/hbapollo/tests/test51.prg
  * examples/hbapollo/tests/test52.prg
  * examples/hbapollo/tests/test53.prg
  * examples/hbapollo/tests/test54.prg
  * examples/hbapollo/tests/test55.prg
  * examples/hbapollo/tests/test56.prg
  * examples/hbapollo/tests/test57.prg
  * examples/hbapollo/tests/test58.prg
  * examples/hbapollo/tests/test60.prg
  * examples/hbapollo/tests/test61.prg
  * examples/httpsrv/uhttpd.prg
  * tests/fsplit.prg
    * deleted archaic SET EPOCH commands, using SET CENTURY ON 
      instead
    * use SET DATE ANSI
    * some formatting
2012-07-21 11:58:22 +00:00

130 lines
4.2 KiB
Plaintext

/*
* $Id$
*/
/*
* Harbour Project source code:
* MySQL DBMS test program
*
* Copyright 2000 Maurilio Longo <maurilio.longo@libero.it>
* www - http://harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#include "dbstruct.ch"
PROCEDURE Main( cArg )
LOCAL oServer, oQuery2, oRow, aStru
LOCAL oQuery
SET CENTURY ON
oServer := TMySQLServer():New( "localhost", "root", "" )
IF oServer:NetErr()
Alert( oServer:Error() )
ENDIF
oServer:SelectDB( "ims" )
// oQuery := oServer:Query( "SELECT * from maga limit 10" )
// oRow := oQuery:GetRow()
dbUseArea( .T.,, cArg, "wn", .F. )
IF !oServer:DeleteTable( "test" )
Alert( oServer:Error() )
ENDIF
aStru := dbStruct()
IF oServer:CreateTable( "test", aStru )
Alert( "test created successfully" )
ELSE
Alert( oServer:Error() )
ENDIF
oQuery:=oServer:Query( "SELECT C111, C116, C134 from maga limit 10" )
// oRow := oQuery:GetRow()
oServer:Destroy()
DO WHILE !wn->(Eof())
oQuery2 := oServer:Query( "SELECT * from test where CODF='" + wn->CODF + "' and CODP='" + wn->CODP + "'" )
IF oQuery2:LastRec() > 0
? "found "
oRow := oQuery2:GetRow()
oRow:FieldPut( oRow:FieldPos( "GIACENZA" ), oRow:FieldGet( oRow:FieldPos( "GIACENZA" ) ) + wn->GIACENZA )
oRow:FieldPut( oRow:FieldPos( "ACQGR" ), oRow:FieldGet( oRow:FieldPos( "ACQGR" ) ) + wn->ACQGR )
oRow:FieldPut( oRow:FieldPos( "ACQDI" ), oRow:FieldGet( oRow:FieldPos( "ACQDI" ) ) + wn->ACQDI )
IF ! oQuery2:Update( oRow )
Alert( oQuery2:Error() )
ENDIF
ELSE
? wn->CODF + " " + wn->CODP
oRow := oQuery:GetBlankRow()
oRow:FieldPut( oRow:FieldPos( "CODF" ), wn->CODF )
oRow:FieldPut( oRow:FieldPos( "CODP" ), wn->CODP )
oRow:FieldPut( oRow:FieldPos( "GIACENZA" ), wn->GIACENZA )
oRow:FieldPut( oRow:FieldPos( "DATA" ), wn->DATA + 365 * 100 )
oRow:FieldPut( oRow:FieldPos( "ACQGR" ), wn->ACQGR )
oRow:FieldPut( oRow:FieldPos( "ACQDI" ), wn->ACQDI )
IF ! oQuery:Append( oRow )
Alert( oQuery:Error() )
ENDIF
ENDIF
wn->(dbSkip())
ENDDO
wn->(dbCloseArea())
RETURN