nageswaragunupudi wrote:Also New in 16.12 (Upcoming):
Automatic Recovery from Lost Connections:
During execution of a program, connection to the server can be lost either due to connection timeout or due to physical loss of connection like failure or internet or physical connection.
Even after disconnection, the program can continue to browse / view the tables already opened including sorting and filtering, but any attempts to write data, requery, etc will fail.
TimeOut:
It is customary to set time out to 28,800 seconds (8 hours) in many cases. In some cases it is possible that the timeout is set to a very short period.
When any sql is executed for access or writing data, if disconnection is encountered, automatically reconnection is attempted. In case of connections lost due to time out, the recovery is 100% successful. In case of physical loss of connections, the program can continue without accessing data from the server and when the physical connectivity is restored any attempt to read/write data will automatically reconnect to the server and proceed with the execution of the program.
06/06/2017 15:32:02: FWMARIACONNECTION:EXECUTE_SQL( 3829 ) CallStack() = " <- FWMARIACONNECTION:ROWSET(4266) <- FWMARIAROWSET:EDITBASERECORD(2839) <- (b)EVAL(61) <- TBUTTONBMP:CLICK(179) <- TBUTTON:HANDLEEVENT(1685)" cSql = "SELECT * FROM `cpr` LIMIT 0" uRet = ::nError = 2003 ::cError = "Can't connect to MySQL server on '192.168.2.2' (10061)" ::cSqlInfo = ""
06/06/2017 16:12:39: FWMARIACONNECTION:EXECUTE_SQL( 3829 ) CallStack() = " <- FWMARIACONNECTION:ROWSET(4266) <- FWMARIAROWSET:EDITBASERECORD(2839) <- (b)EVAL(61) <- TBUTTONBMP:CLICK(179) <- TBUTTON:HANDLEEVENT(1685)" cSql = "SELECT * FROM `cpr` LIMIT 0" uRet = ::nError = 2003 ::cError = "Can't connect to MySQL server on '192.168.2.2' (10061)" ::cSqlInfo = ""
06/06/2017 16:23:15: FWMARIACONNECTION:EXECUTE_SQL( 3829 ) CallStack() = " <- FWMARIACONNECTION:ROWSET(4266) <- FWMARIAROWSET:EDITBASERECORD(2839) <- (b)EVAL(61) <- TBUTTONBMP:CLICK(179) <- TBUTTON:HANDLEEVENT(1685)" cSql = "SELECT * FROM `cpr` LIMIT 0" uRet = ::nError = 2003 ::cError = "Can't connect to MySQL server on '192.168.2.2' (10061)" ::cSqlInfo = ""
06/06/2017 16:42:39: FWMARIACONNECTION:EXECUTE_SQL( 3829 ) CallStack() = " <- FWMARIACONNECTION:ROWSET(4266) <- FWMARIAROWSET:EDITBASERECORD(2839) <- (b)EVAL(61) <- TBUTTONBMP:CLICK(179) <- TBUTTON:HANDLEEVENT(1685)" cSql = "SELECT * FROM `cpr` LIMIT 0" uRet = ::nError = 2003 ::cError = "Can't connect to MySQL server on '192.168.2.2' (10061)" ::cSqlInfo = ""
aDatos := { ;
{ "id", "n", 6, 0, .T., 0 }, ;
{ "idfactura", "n", 6, 0, .T., NIL }, ;
{ "idcontacto", "n", 4, 0, .T., NIL }, ;
{ "fecha", "d", 10, 0, .T., NIL }, ;
{ "subtotal", "n", 6, 2, .T., NIL }, ;
{ "descuento", "n", 6, 2, .T., NIL }, ;
{ "total", "n", 6, 2, .T., NIL } ;
}
nageswaragunupudi wrote:Much simpler way to specify auto-inc primary key is to specify "+" as field type.
Before or without actually creating table, you can check the table creation sql by
? oCn:CreateTableSQL( cTableName, aStruct )
Example:
- Code: Select all Expand view RUN
aStru := { ;
{ "codgru", "+", 3, 0 }, ; // '+' : AutoInc Primary Key
{ "nomgru", "C", 30, 0 }, ;
{ "altera", "D", 8, 0 }, ;
{ "check", "L", 1, 0 }, ;
{ "Amount", "N", 10, 2 }, ;
{ "details", "M", 10, 0 }, ; // Unlimited Text Memo Field
{ "photo", "m", 10, 0 }, ; // 'm' for Binary Memo field like Images, etc
{ "dtime", "T", 8, 0 }, ; // DateTime field
{ "createdt", "@", 8, 0 }, ; // TimeStamp when record is appended
{ "changedt", "=", 8, 0 } ; // TimeStamp when record is last modified
}
? oCn:CreateTableSQL( "testtable", aStru )
Result:
- Code: Select all Expand view RUN
CREATE TABLE `testtable` (
`codgru` INT AUTO_INCREMENT PRIMARY KEY,
`nomgru` VARCHAR( 30 ),
`altera` DATE,
`check` BIT DEFAULT 0,
`Amount` DECIMAL( 11, 2 ),
`details` TEXT,
`photo` LONGBLOB,
`dtime` DATETIME,
`createdt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
`changedt` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
Example showing how to specify foreign key constraints, collations, calculated columns ( mysql 5.7 and above):
- Code: Select all Expand view RUN
aStru := { ;
{ "code", "REFERENCES states( code )" }, ;
{ "details", "C", 80, 0, "utf8" }, ;
{ "quantity", "N", 8, 3 }, ;
{ "rate", "N", 3, 0 }, ;
{ "value = quantity * rate", "N", 12, 2 } }
? oCn:CreateTableSQL( "test", aStru, nil, "latin1" )
Result:
- Code: Select all Expand view RUN
CREATE TABLE `test` (
`ID` INT AUTO_INCREMENT PRIMARY KEY,
`code` varchar(2) CHARACTER SET latin1 COLLATE latin1_general_ci,
`details` VARCHAR( 80 ) CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`quantity` DECIMAL( 9, 3 ),
`rate` SMALLINT,
`value` DECIMAL( 13, 2 ) AS ( quantity * rate ),
FOREIGN KEY ( `code` ) REFERENCES `states` ( `code` ) ON UPDATE CASCADE ON DELETE RESTRICT
) CHARACTER SET latin1 COLLATE latin1_general_ci
IF ::nId != 0
TEXT into cSql
Select
p.id AS c1,
p.idsucursal AS c2,
p.iddistribuidor AS c3,
p.nombre AS c4,
pr.id AS c5,
pr.idsucursal AS c6,
pr.idproducto AS c7,
pr.fecha AS c8,
pr.importe AS c9,
pr.stock AS c10,
pr.stockminimo AS c11,
pr.ganancia AS c12
FROM tbprod p
Left join tbprecio pr
ON pr.idproducto = p.id
WHERE p.id = 'nId'
ENDTEXT
cSql := StrTran( cSql, 'nId', Str( ::nId ) )
::oCnx:lShowErrors := .T.
oQry := ::oCnx:QUERYRESULT( cSql )
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 57 guests