@MySQLFetchRow
Syntax
@MySQLFetchRow(MySQLResultHandle;FNAnzahl[;ErgebnisFelder;...]);
Description
Fetches one row from the current position (see @MySQLSeekResult) of a stored result of a @MySQLQuery query.
The VSPECMYSQLRES MySQLResultHandle is provided by @MySQLQuery.
NOTE:
Currently, only one row at a time is supported!!!
The number of specified ResultFields variables must match the number of queried columns in the query.
The queried values are returned in the ResultFields variables.
Return:
On success TRUE is returned, otherwise @Error or FALSE;
Example: @MySQLFetchRow(MySQLResultHandle;FNCount[;ResultFields;…]);
MySQLh:=@MySQLInit;
MySQLError:=1;
IF(@IsError(MySQLh)){
@LogReport(MySQLh;3);
}ELSE{
@MySQLOptions(MySQLh);
MySQLUser:="MySQLConnectorUser";
MySQLPassword:="ConnectorPassword";
MySQLDefaultDatabase:="testdb";
MySQLHost:="mysql.intranet";
Ret:=@MySQLConnect(MySQLh;MySQLHost;MySQLUser;MySQLPassword;MySQLDefaultDatabase);
IF(@IsError(Ret)){
@LogReport(Ret);
}ELSE{
MySQLError:=0;}
IF(!MySQLError){
QueryStr:="SELECT ID,Name,Amount,UID FROM testdb.amounts WHERE Name=\"Test User\";";
Ret:=@MySQLQuery(MySQLh;QueryStr;MySQLResH);
NumRows:=@MySQLGetNumRows(MySQLResH);
IF(NumRows=1){
Ret:=@MySQLFetchRow(MySQLResH;1;ThisQueryID;ThisQueryName;ThisQueryAmount;ThisQueryUID);
}ELSE{
ThisQueryID:=-1;
ThisQueryAmount:=0;
ThisQueryName:=ThisQueryUID:="";
}
MySQLResH:=@MySQLFreeResult(MySQLResH);
@LogReport("ThisQueryID :"+@Text(ThisQueryID);3);
@LogReport("ThisQueryName :"+ThisQueryName;3);
@LogReport("ThisQueryAmount:"+@Text(ThisQueryAmount);3);
@LogReport("ThisQueryUID :"+ThisQueryUID;3);
}
MySQLh:=@MySQLClose(MySQLh);
}
@MySQLThreadEnd;
MySQL DB for this example:
INSERT INTO testdb.amount (Name,Amount,UID,ModTime) VALUES ("Test User",123.45,"1234567890ABCDEFABCD1234567890AB",NOW());
Output in APILOG for this example:
NumRows:1
ThisQueryID :1
ThisQueryName :Test User
ThisQueryAmount:123.45
ThisQueryUID :1234567890ABCDEFABCD1234567890AB
A MySQL connection is established and a query is submitted; the result is then output to APILOG.
Note : This text was machine-translated and may contain inaccuracies.
