You are not logged in.
Pages: 1
Ok,thanks
The rest server run on port 8080, Html5 app run on port 8081 (MS IIS7), Whether it is cross-domain?
\html5\app\store\contancts.js
...
actionMethods : {
create : 'POST',
read : 'GET',
update : 'PUT',
destroy : 'DELETE'
},
api : {
create : 'http://localhost:8080/root/SampleRecord',
read : 'http://localhost:8080/root/SampleRecord/?SELECT=*',
update : 'http://localhost:8080/root/SampleRecord/',
destroy : 'http://localhost:8080/root/SampleRecord/'
},
...
About this,can tell us about it?
thanks,
I do not know the number of parameters,Only know the number of parameters when running... Need to dynamically create parameters
I use the Tquery with Pooling, and the connection is different,I want get query object form pool and set conncetion
My code:
var
vparam: array of Tvarrec;
...
// How can I build vparam ? the value form anther array (string array )
ConnectionProperties.Execute(aSQL, vparam)
...
have a suggestion:
Can Change the Connection property of TQuery to read and write?
property Connection: TSQLDBConnection read fConnection write fConnection;
Thank you very much!
o~~,thanks!
But I need a query of Parameter based on the name,and return json. How I'm doing is the right ?
Test code :
...
VQuery:TQuery;
begin
VQuery:=TQuery.create(con);
with VQuery do
begin
SQL.Clear;
SQL.Add('select * from table');
Open;
Result:=PreparedSQLDBStatement.FetchAllAsJSON(aExpanded);
end;
...
There are 5 row of data in table , but only returns 4.
In SynDB 5440 line
function TSQLDBStatement.FetchAllToJSON(JSON: TStream; Expanded: boolean;
DoNotFletchBlobs: Boolean=false): PtrInt;
...
<----------------- CurrentRow=1 ?
// write rows data
while Step do begin
ColumnsToJSON(W,DoNotFletchBlobs);
W.Add(',');
inc(result);
end;
...
If I change the following:
// write rows data
////////////////////////// 畅雨 add begin 2014.05.26
if CurrentRow=1 then
begin
ColumnsToJSON(W,DoNotFletchBlobs);
W.Add(',');
inc(result);
end;
/////////////////////////// 畅雨 and end 2014.05.26
while Step do begin
ColumnsToJSON(W,DoNotFletchBlobs);
W.Add(',');
inc(result);
end;
THen Return 5 ,why?
thanks !
I test like this:
Q := TQuery.Create(aSQLDBConnection);
try
Q.SQL.Clear; // optional
Q.SQL.Add('select * from TABLE');
Q.SQL.Add(' WHERE ID_DETAIL=:detail;');
Q.ParamByName('detail').AsString := '123420020100000430015';
Q.Open;
Q.First; // optional
while not Q.Eof do begin
assert(Q.FieldByName('id_detail').AsString='123420020100000430015');
Q.Next;
end;
Q.Close;
finally
Q.Free;
end;
----------------
raise error:Parameter 'detail' not bound for 'detail';
In SynDB.pas line 3397
i := fParam.FindHashed(tmp);
if i<0 then
raise ESQLQueryException.CreateFmt('Parameter "%s" not bound for "%s"',[tmp,req]);
This statement has bug?
Ok,thanks
hi,
Current, GetTableNames and GetFieldNames return result is RawUTF8Array,
Can return json?
My test code (delphi7):
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,synoledb, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
MSSQL2012OLEDB:TOleDBMSSQL2012ConnectionProperties;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
MSSQL2012OLEDB:=TOleDBMSSQL2012ConnectionProperties.Create('.','dh1pmip','sa','');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
MSSQL2012OLEDB.Execute('select 1 as aa',[]);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
MSSQL2012OLEDB.Free;
end;
Click button1, run MSSQL2012OLEDB.Execute,
When exit application, the process can not be terminated.
Oh,but ,not do it :(
When exit application, sometime the process can not be terminated, sometime trancing to here:
---->
assert(OleDBCoinitialized>0,'You should call TOleDBConnection.Free from the same '+
'thread which called its Create: i.e. call MyProps.EndCurrentThread from an '+
'THttpServerGeneric.OnHttpThreadTerminate event - see ticket 213544b2f5');
dec(OleDBCoinitialized);
if OleDBCoinitialized=0 then
CoUninitialize;
ad,
I do not use THttpServerGeneric ,only use olednconnection ,how can i free it?
help
code:
...
fDefaultConnectionProperties:=TOleDBMSSQL2012ConnectionProperties.Create('.','database','sa','');
fDefaultConnectionProperties.Execute(sql,param);
freeandnil(fDefaultConnectionProperties) ;
....
When exit application, the process can not be terminated.
ok,thanks!
My idea is that rest API is not the ORM, but the definition of sql. Each rest API is defined as the execution of a SQL, and the SQL parameter is passed, performed by the DB layer, returned the JSON result to client.
ad,Thank you for your answer!
1. I have been using instantobject,want to switch to mORMot, instandobject using guid as objectid...
2. I do not use the ORM but want to use SQL ans result as JSON,how to do it?
Some time after the test :
1. Why is objectid not guid? If guid should be more Suitable for distributed applications.
2. SQL Parameters used '?' The SQL parameters are as follows: where (name like @p1) or (title like @P1) or (desc like @p1),The parameters of processing need to write the same three, Why not use the parameter name?
SynDBZEOS.pas line 548
...
PSQLDBColumnProperty(fColumn.AddAndMakeUniqueName(StringToUTF8(name)))^.
...
replace as:
PSQLDBColumnProperty(fColumn.AddAndMakeUniqueName(name))^.
remove StringToUTF8 , result is correct !
I guess Coding has been processed by zeos, the returned 'name' is UTF-8 encoded?
OK, I try
delphi7, zeos: 7.1.2
Test : mssql server2012 + syndbZEOS : If fieldname has some Asian languages(Double-byte characters) then error,
but oledb,firedac,sqlite3 is correct .
eg: SQL= select 'changyu畅雨' as 姓名 , the result : [{"濮撳悕":"changyu畅雨"}] , remark: '姓名' = 'name'
The fieldname is wrong, but fieldvalue is correct !
SynDBZEOS.pas line 544
...
for i := 1 to fResultInfo.GetColumnCount do begin
name := (fResultInfo.GetColumnLabel(i)); -----maybe has error?
if name='' then
name := (fResultInfo.GetColumnName(i)); -----maybe has error?
...
But I do not know how to fix it ...
Test : mssql server2012 + syndbfireDAC : If fieldtype is boolean then error : Cannot access field 'Booleanfield' as type Integer
synDBDataset.pas line 584
Replace
...
if ColumnValueDBType=IsTLargeIntField then
WR.Add(TLargeintField(ColumnAttr).AsLargeInt) else
WR.Add(TField(ColumnAttr).AsInteger); ----this error
...
as
...
if ColumnValueDBType=IsTLargeIntField then
WR.Add(TLargeintField(ColumnAttr).AsLargeInt) else
begin
if TField(ColumnAttr).DataType =ftBoolean then
WR.Add(ord(TField(ColumnAttr).AsBoolean)) -------ok!
else
WR.Add(TField(ColumnAttr).AsInteger);
end;
...
thanks mORMot Framework is great!
Problem solved, before Execute(SQL,[]) just AnsiToUtf8() :Execute(AnsiToUtf8(SQL),[])
hi,ad
I use synoledb, when SQL include some Asian languages(Double-byte characters),then SQLW is Wrong. zeos,sqlite3,firedac has same problem.
-----> in synoledb.pas line 1480
procedure TOleDBStatement.Prepare(const aSQL: RawUTF8;
ExpectResults: Boolean);
begin
...
SetLength(SQLW,L*2+1);
UTF8ToWideChar(pointer(SQLW),pointer(fSQL),L); ----------------- this!
fCommand.SetCommandText(DBGUID_DEFAULT,pointer(SQLW));
end
when fSQL include some Asian languages(Double-byte characters),then SQLW is Wrong.
eg:
fSQL ='select 'changyu畅雨' as name '
but Converted to SQLW ='select 'chan '
-------> symCommons line 9432
function UTF8ToWideChar(dest: pWideChar; source: PUTF8Char; sourceBytes: PtrInt=0): PtrInt;
begin
...
c := pCardinal(source)^;
if (c and $80808080<>0)then -------------not support some Asian languages(Double-byte characters)
break; // break on first non ASCII quad
...
end
Pages: 1