You are not logged in.
Pages: 1
Using Delphi XE8 and the latest nightly build of mORMot, I have created a REST server in which I have the following TSQLRecord class defined:
TCustomers = class(TSQLRecord)
protected
fCustomerID: Integer;
fCustomerStatus: Boolean;
fCustomerName: String;
fCustomerDate: TDateTime;
published
property CustomerID: Integer read fCustomerID write fCustomerID;
property CustomerStatus: Boolean read fCustomerStatus write fCustomerStatus;
property CustomerName: String index 255 read fCustomerName write fCustomerName;
property CustomerDate: TDateTime read fCustomerDate write fCustomerDate;
end;
After generating my 'mORMotClient' unit, I created a REST client that will be using the 'TCustomers' type defined above.
If I run the following from within my client, the 'FillOne' is successful:
var
iClient: TSQLRestClientHTTP;
iCustomerSQLRecord: TCustomers;
begin
iClient := GetClient('localhost');
try
// Let's locate the 'customer' record
iCustomerSQLRecord := TCustomers.CreateAndFillPrepare(iClient, 'ID, CustomerID', 'ID = ?', [aCustomerID]);
try
if (iCustomerSQLRecord.FillOne) then
begin
...
end;
finally
iCustomerSQLRecord.Free;
end;
finally
iClient.Free;
end;
But if I run the following from within my client, the 'FillOne' is UNSUCCESSFUL:
var
iClient: TSQLRestClientHTTP;
iCustomerSQLRecord: TCustomers;
begin
iClient := GetClient('localhost');
try
// Let's locate the 'customer' record
iCustomerSQLRecord := TCustomers.CreateAndFillPrepare(iClient, 'ID, CustomerID, CustomerName, CustomerDate', 'ID = ?', [aCustomerID]);
try
if (iCustomerSQLRecord.FillOne) then
begin
...
end;
finally
iCustomerSQLRecord.Free;
end;
finally
iClient.Free;
end;
I must be doing something wrong. But I am unable to figure out what I am doing wrong. Any inputs would be greatly appreciated. Thanks.
Offline
Offline
Thanks for your input.
After reading your recommendations, I realized that my original post was not complete and accurate. Indeed, I had forgotten to mention that my database is a 'mysql' one. I understand that the type of database used might not be relevant to my problem but I should not have forgotten to mention it in the first place.
I had also forgotten to mention that I had enabled the logs. However, at this point in time, I have not added a '.map' file to my application as I am still reading the documentation concerning these types of files.
Finally, when dealing with the "not successful" statement, the 'CreateAndFillPrepare' should have read:
iCustomerSQLRecord := TCustomers.CreateAndFillPrepare(iClient, 'ID, CustomerID, CustomerStatus, CustomerName, CustomerDate', 'ID = ?', [aCustomerID]);
It is when I noticed the missing 'CustomerStatus' from my supposedly unsuccessful 'CreateAndFillPrepare' statement that I found a solution to my problem. In my 'mysql' database 'CustomerStatus' was defined as a 'bit' field. As soon as I changed its type to 'tinyint,' everything worked as expected.
Offline
Pages: 1