2000-10-23 23:29 GMT+2 Maurilio Longo <maurilio.longo@libero.it>

This commit is contained in:
Maurilio Longo
2000-10-23 21:31:36 +00:00
parent 581d49ab5e
commit 839949be1a
5 changed files with 67 additions and 32 deletions

View File

@@ -1,3 +1,9 @@
2000-10-23 23:29 GMT+2 Maurilio Longo <maurilio.longo@libero.it>
* contrib/mysql/*.prg
* changes / fixes as needed :-)
* include/hbdbf.h
+ added #pragma pack() for GCC under OS/2
2000-10-23 14:00 UTC-0400 David G. Holm <dholm@jsd-llc.com>
* include/hbver.h
* Bumped revision code to "i" and date to 2000-10-23 in

View File

@@ -49,6 +49,10 @@ procedure main(c1, c2, c3, c4, c5, c6, c7, c8, c9, c10, c11, c12, c13, c14)
SET CENTURY ON
SET EPOCH TO 1960
// At present time (23/10/00) DBFCDX is default RDD and DBFNTX is
// now DBF (I mean the one able to handle .DBTs :-))
rddSetDefault( "DBF" )
if PCount() < 6
help()
quit

View File

@@ -40,36 +40,6 @@
#include "mysql.ch"
// Returns an SQL string with clipper value converted ie. Date() -> "'YYYY-MM-DD'"
static function ClipValue2SQL(Value)
local cValue := ""
do case
case Valtype(Value) == "N"
cValue := AllTrim(Str(Value))
case Valtype(Value) == "D"
if !Empty(Value)
// MySQL dates are like YYYY-MM-DD
cValue := "'" + Str(Year(Value), 4) + "-" + PadL(Month(Value), 2, "0") + "-" + PadL(Day(Value), 2, "0") + "'"
else
cValue := "''"
endif
case Valtype(Value) == "C"
cValue := "'" + StrTran(Value, "'", "\'") + "'"
case Valtype(Value) == "L"
cValue := AllTrim(Str(iif(Value == .F., 0, 1)))
otherwise
cValue := "''" // NOTE: Here we lose values we cannot convert
endcase
return cValue
// Every single row of an answer
CLASS TMySQLRow
@@ -421,7 +391,12 @@ METHOD GetRow(nRow) CLASS TMySQLQuery
// Date format YYYY-MM-DD
aRow[i] := CToD(__StrToken(aRow[i], 2, ",") + "-" + __StrToken(aRow[i], 3, ",") + "-" + __StrToken(aRow[i], 1, ","))
endif
case ::aFieldStruct[i][MYSQL_FS_TYPE] == MYSQL_BLOB_TYPE
// Memo field
otherwise
endcase
next
@@ -714,6 +689,9 @@ METHOD CreateTable(cTable, aStruct) CLASS TMySQLServer
case aStruct[i][DBS_TYPE] == "C"
cCreateQuery += aStruct[i][DBS_NAME] + " char(" + AllTrim(Str(aStruct[i][DBS_LEN])) + ")" + Eval(cNN, aStruct[i]) + ","
case aStruct[i][DBS_TYPE] == "M"
cCreateQuery += aStruct[i][DBS_NAME] + " text" + Eval(cNN, aStruct[i]) + ","
case aStruct[i][DBS_TYPE] == "N"
if aStruct[i][DBS_DEC] == 0
cCreateQuery += aStruct[i][DBS_NAME] + " int(" + AllTrim(Str(aStruct[i][DBS_LEN])) + ")" + Eval(cNN, aStruct[i]) + ","
@@ -827,7 +805,7 @@ METHOD Query(cQuery) CLASS TMySQLServer
oQuery := TMySQLQuery():New(::nSocket, cQuery)
endif
if oQuery:nNumRows < 0
if oQuery:NetErr()
::lError := .T.
endif
@@ -917,3 +895,35 @@ METHOD TableStruct(cTable) CLASS TMySQLServer
endif*/
return aStruct
// Returns an SQL string with clipper value converted ie. Date() -> "'YYYY-MM-DD'"
static function ClipValue2SQL(Value)
local cValue := ""
do case
case Valtype(Value) == "N"
cValue := AllTrim(Str(Value))
case Valtype(Value) == "D"
if !Empty(Value)
// MySQL dates are like YYYY-MM-DD
cValue := "'" + Str(Year(Value), 4) + "-" + PadL(Month(Value), 2, "0") + "-" + PadL(Day(Value), 2, "0") + "'"
else
cValue := "''"
endif
case Valtype(Value) $ "CM"
cValue := "'" + StrTran(Value, "'", "\'") + "'"
case Valtype(Value) == "L"
cValue := AllTrim(Str(iif(Value == .F., 0, 1)))
otherwise
cValue := "''" // NOTE: Here we lose values we cannot convert
endcase
return cValue

View File

@@ -95,14 +95,18 @@ METHOD Block(xNewValue) CLASS TBColumnSQL
case ValType(xValue) == "L"
xValue := iif(xValue, ".T.", ".F.")
case ValType(xValue) $ "CM"
case ValType(xValue) == "C"
// Chr(34) is a double quote
// That is: if there is a double quote inside text substitute it with a string
// which gets converted back to a double quote by macro operator. If not it would
// give an error because of unbalanced double quotes.
xValue := Chr(34) + StrTran(xValue, Chr(34), Chr(34) + "+Chr(34)+" + Chr(34)) + Chr(34)
case ValType(xValue) == "M"
xValue := "'<MEMO>'"
otherwise
endcase
return &("{||" + xValue + "}")

View File

@@ -38,6 +38,12 @@
#include "hbapirdd.h"
/* 23/10/00 - maurilio.longo@libero.it
When using GCC under OS/2 pack(1) byte aligns every structure */
#if defined(__EMX__) && ! defined(__RSXNT__)
#pragma pack(1)
#endif
#if defined(HB_EXTERN_C)
extern "C" {
#endif
@@ -81,4 +87,9 @@ typedef DBFFIELD * LPDBFFIELD;
}
#endif
#if defined(__EMX__) && ! defined(__RSXNT__)
#pragma pack()
#endif
#endif /* HB_DBF_H_ */