diff --git a/harbour/ChangeLog b/harbour/ChangeLog index e3e95c1ec3..702a43ef5a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,9 @@ +2000-10-23 23:29 GMT+2 Maurilio Longo + * 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 * include/hbver.h * Bumped revision code to "i" and date to 2000-10-23 in diff --git a/harbour/contrib/mysql/dbf2mysql.prg b/harbour/contrib/mysql/dbf2mysql.prg index 69f51788ac..fd6a19532c 100644 --- a/harbour/contrib/mysql/dbf2mysql.prg +++ b/harbour/contrib/mysql/dbf2mysql.prg @@ -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 diff --git a/harbour/contrib/mysql/tmysql.prg b/harbour/contrib/mysql/tmysql.prg index 448b68ecd1..d6f5f15b45 100644 --- a/harbour/contrib/mysql/tmysql.prg +++ b/harbour/contrib/mysql/tmysql.prg @@ -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 + diff --git a/harbour/contrib/mysql/tsqlbrw.prg b/harbour/contrib/mysql/tsqlbrw.prg index f6ed537b58..739b670725 100644 --- a/harbour/contrib/mysql/tsqlbrw.prg +++ b/harbour/contrib/mysql/tsqlbrw.prg @@ -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 := "''" + otherwise + endcase return &("{||" + xValue + "}") diff --git a/harbour/include/hbdbf.h b/harbour/include/hbdbf.h index 8f6d0a428e..79e6dc9e18 100644 --- a/harbour/include/hbdbf.h +++ b/harbour/include/hbdbf.h @@ -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_ */ \ No newline at end of file