You are not logged in.
tested on XE2 and 2010 and same problem
sorry, i download latest version, working perfect!
Again the same problem.
Test:
1) change constant MAX_SQLFIELDS to 128
2) sample project 02 - Embedded SQLite3 ORM in SampleData.pas add more fields to TSQLSampleRecord (>64) and run.
type
/// here we declare the class containing the data
// - it just has to inherits from TSQLRecord, and the published
// properties will be used for the ORM (and all SQL creation)
// - the beginning of the class name must be 'TSQL' for proper table naming
// in client/server environnment
TSQLSampleRecord = class(TSQLRecord)
private
fQuestion: RawUTF8;
fName: RawUTF8;
fTime: TModTime;
fQuestion1: RawUTF8;
fName1: RawUTF8;
fTime1: TModTime;
fQuestion2: RawUTF8;
fName2: RawUTF8;
fTime2: TModTime;
fQuestion3: RawUTF8;
fName3: RawUTF8;
fTime3: TModTime;
fQuestion4: RawUTF8;
fName4: RawUTF8;
fTime4: TModTime;
fQuestion5: RawUTF8;
fName5: RawUTF8;
fTime5: TModTime;
fQuestion6: RawUTF8;
fName6: RawUTF8;
fTime6: TModTime;
fQuestion7: RawUTF8;
fName7: RawUTF8;
fTime7: TModTime;
fQuestion8: RawUTF8;
fName8: RawUTF8;
fTime8: TModTime;
fQuestion9: RawUTF8;
fName9: RawUTF8;
fTime9: TModTime;
fQuestion10: RawUTF8;
fName10: RawUTF8;
fTime10: TModTime;
fQuestion11: RawUTF8;
fName11: RawUTF8;
fTime11: TModTime;
fQuestion12: RawUTF8;
fName12: RawUTF8;
fTime12: TModTime;
fQuestion13: RawUTF8;
fName13: RawUTF8;
fTime13: TModTime;
fQuestion14: RawUTF8;
fName14: RawUTF8;
fTime14: TModTime;
fQuestion15: RawUTF8;
fName15: RawUTF8;
fTime15: TModTime;
fQuestion16: RawUTF8;
fName16: RawUTF8;
fTime16: TModTime;
fQuestion17: RawUTF8;
fName17: RawUTF8;
fTime17: TModTime;
fQuestion18: RawUTF8;
fName18: RawUTF8;
fTime18: TModTime;
fQuestion19: RawUTF8;
fName19: RawUTF8;
fTime19: TModTime;
fQuestion20: RawUTF8;
fName20: RawUTF8;
fTime20: TModTime;
fQuestion21: RawUTF8;
fName21: RawUTF8;
fTime21: TModTime;
fQuestion22: RawUTF8;
fName22: RawUTF8;
fTime22: TModTime;
published
property Time: TModTime read fTime write fTime;
property Name: RawUTF8 read fName write fName;
property Question: RawUTF8 read fQuestion write fQuestion;
property Time1: TModTime read fTime write fTime;
property Name1: RawUTF8 read fName write fName;
property Question1: RawUTF8 read fQuestion write fQuestion;
property Time2: TModTime read fTime write fTime;
property Name2: RawUTF8 read fName write fName;
property Question2: RawUTF8 read fQuestion write fQuestion;
property Time3: TModTime read fTime write fTime;
property Name3: RawUTF8 read fName write fName;
property Question3: RawUTF8 read fQuestion write fQuestion;
property Time4: TModTime read fTime write fTime;
property Name4: RawUTF8 read fName write fName;
property Question4: RawUTF8 read fQuestion write fQuestion;
property Time5: TModTime read fTime write fTime;
property Name5: RawUTF8 read fName write fName;
property Question5: RawUTF8 read fQuestion write fQuestion;
property Time6: TModTime read fTime write fTime;
property Name6: RawUTF8 read fName write fName;
property Question6: RawUTF8 read fQuestion write fQuestion;
property Time7: TModTime read fTime write fTime;
property Name7: RawUTF8 read fName write fName;
property Question7: RawUTF8 read fQuestion write fQuestion;
property Time8: TModTime read fTime write fTime;
property Name8: RawUTF8 read fName write fName;
property Question8: RawUTF8 read fQuestion write fQuestion;
property Time9: TModTime read fTime write fTime;
property Name9: RawUTF8 read fName write fName;
property Question9: RawUTF8 read fQuestion write fQuestion;
property Time10: TModTime read fTime write fTime;
property Name10: RawUTF8 read fName write fName;
property Question10: RawUTF8 read fQuestion write fQuestion;
property Time11: TModTime read fTime write fTime;
property Name11: RawUTF8 read fName write fName;
property Question11: RawUTF8 read fQuestion write fQuestion;
property Time12: TModTime read fTime write fTime;
property Name12: RawUTF8 read fName write fName;
property Question12: RawUTF8 read fQuestion write fQuestion;
property Time13: TModTime read fTime write fTime;
property Name13: RawUTF8 read fName write fName;
property Question13: RawUTF8 read fQuestion write fQuestion;
property Time14: TModTime read fTime write fTime;
property Name14: RawUTF8 read fName write fName;
property Question14: RawUTF8 read fQuestion write fQuestion;
property Time15: TModTime read fTime write fTime;
property Name15: RawUTF8 read fName write fName;
property Question15: RawUTF8 read fQuestion write fQuestion;
property Time16: TModTime read fTime write fTime;
property Name16: RawUTF8 read fName write fName;
property Question16: RawUTF8 read fQuestion write fQuestion;
property Time17: TModTime read fTime write fTime;
property Name17: RawUTF8 read fName write fName;
property Question17: RawUTF8 read fQuestion write fQuestion;
property Time18: TModTime read fTime write fTime;
property Name18: RawUTF8 read fName write fName;
property Question18: RawUTF8 read fQuestion write fQuestion;
property Time19: TModTime read fTime write fTime;
property Name19: RawUTF8 read fName write fName;
property Question19: RawUTF8 read fQuestion write fQuestion;
property Time20: TModTime read fTime write fTime;
property Name20: RawUTF8 read fName write fName;
property Question20: RawUTF8 read fQuestion write fQuestion;
property Time21: TModTime read fTime write fTime;
property Name21: RawUTF8 read fName write fName;
property Question21: RawUTF8 read fQuestion write fQuestion;
property Time22: TModTime read fTime write fTime;
property Name22: RawUTF8 read fName write fName;
property Question22: RawUTF8 read fQuestion write fQuestion;
end;3) compiling and run fine, close program and run again and see
"Project Project02.exe raised exception class ESQLite3Exception with message 'duplicate column name: Time21'."
what i do wrong?
FireMonkey 2 have TGrid component and TMS create TTMSFMXGrid.
What's the easiest way to display the data through mORMot Framework?
I think understand what the problem is - 64 fields, when I reduce the number of fields up to 63 everything works fine.
Is it possible to determine the possibility of more than 63 fields?
Thank you, everything works fine!
made changes to the structure of the database and startup error.
Project BlankPrn.exe raised exception class ESQLException with message 'duplicate column name: MKB10'.
TSQLDataRecord = class(TSQLRecord)
private
fDateVid: TDateTime;
fListNetrud,
fBlankPrv,
fFam, fIm, fOt: string;
fDateBorn: TDateTime;
fSex,
fPMestoRab, fMestoRab: string;
fNetrudKod, fNetrudDopKod, fNetrudKodIzm: Integer;
fNumOrg: string;
fDate1, fDate2: TDateTime;
fNumPut, fOGRNSan,
fVozrL1, fVozrM1, fRodSv1: Integer;
fFIOChS1: string;
fVozrL2, fVozrM2, fRodSv2: Integer;
fFIOChS2: string;
fBerem: string;
fNarRej: Integer;
fDateNarRej,
fDateVStacS, fDateVStacPo,
fDateNapMSE, fDateRegMSE, fDateOsvMSE: TDateTime;
fInvalid: Integer;
fDateOsvOtRabS1, fDateOsvOtRabPo1: TDateTime;
fDolgnVr1, fIDVrach1: string;
fDateOsvOtRabS2, fDateOsvOtRabPo2: TDateTime;
fDolgnVr2, fIDVrach2: string;
fDateOsvOtRabS3, fDateOsvOtRabPo3: TDateTime;
fDolgnVr3, fIDVrach3: string;
fDateWorkAt: TDateTime;
fWorkOther: string;
fDateWorkOtherAt: TDateTime;
fVidanListNetr: string;
fFIOVrachKor: string;
fNumIstBolKor: string;
fDateVidKor: TDateTime;
fSS,
fTipogNum: string;
fDolgnVr1R, fIDVrach1R,
fDolgnVr2R, fIDVrach2R,
fDolgnVr3R, fIDVrach3R: string;
fUchGosSl: string;
fMKB10: string;
published
property DateVid: TDateTime read fDateVid write fDateVid;
property ListNetrud: string read fListNetrud write fListNetrud;
property BlankPrv: string read fBlankPrv write fBlankPrv;
property Fam: string read fFam write fFam;
property Im: string read fIm write fIm;
property Ot: string read fOt write fOt;
property DateBorn: TDateTime read fDateBorn write fDateBorn;
property Sex: string read fSex write fSex;
property PMestoRab: string read fPMestoRab write fPMestoRab;
property MestoRab: string read fMestoRab write fMestoRab;
property NetrudKod: Integer read fNetrudKod write fNetrudKod;
property NetrudDopKod: Integer read fNetrudDopKod write fNetrudDopKod;
property NetrudKodIzm: Integer read fNetrudKodIzm write fNetrudKodIzm;
property NumOrg: string read fNumOrg write fNumOrg;
property Date1: TDateTime read fDate1 write fDate1;
property Date2: TDateTime read fDate2 write fDate2;
property NumPut: Integer read fNumPut write fNumPut;
property OGRNSan: Integer read fOGRNSan write fOGRNSan;
property VozrL1: Integer read fVozrL1 write fVozrL1;
property RodSv1: Integer read fRodSv1 write fRodSv1;
property VozrM1: Integer read fVozrM1 write fVozrM1;
property FIOChS1: string read fFIOChS1 write fFIOChS1;
property VozrL2: Integer read fVozrL2 write fVozrL2;
property RodSv2: Integer read fRodSv2 write fRodSv2;
property VozrM2: Integer read fVozrM2 write fVozrM2;
property FIOChS2: string read fFIOChS2 write fFIOChS2;
property Berem: string read fBerem write fBerem;
property NarRej: Integer read fNarRej write fNarRej;
property DateNarRej: TDateTime read fDateNarRej write fDateNarRej;
property DateVStacS: TDateTime read fDateVStacS write fDateVStacS;
property DateVStacPo: TDateTime read fDateVStacPo write fDateVStacPo;
property DateNapMSE: TDateTime read fDateNapMSE write fDateNapMSE;
property DateRegMSE: TDateTime read fDateRegMSE write fDateRegMSE;
property DateOsvMSE: TDateTime read fDateOsvMSE write fDateOsvMSE;
property Invalid: Integer read fInvalid write fInvalid;
property DateOsvOtRabS1: TDateTime read fDateOsvOtRabS1 write fDateOsvOtRabS1;
property DateOsvOtRabPo1: TDateTime read fDateOsvOtRabPo1 write fDateOsvOtRabPo1;
property DolgnVr1: string read fDolgnVr1 write fDolgnVr1;
property IDVrach1: string read fIDVrach1 write fIDVrach1;
property DateOsvOtRabS2: TDateTime read fDateOsvOtRabS2 write fDateOsvOtRabS2;
property DateOsvOtRabPo2: TDateTime read fDateOsvOtRabPo2 write fDateOsvOtRabPo2;
property DolgnVr2: string read fDolgnVr2 write fDolgnVr2;
property IDVrach2: string read fIDVrach2 write fIDVrach2;
property DateOsvOtRabS3: TDateTime read fDateOsvOtRabS3 write fDateOsvOtRabS3;
property DateOsvOtRabPo3: TDateTime read fDateOsvOtRabPo3 write fDateOsvOtRabPo3;
property DolgnVr3: string read fDolgnVr3 write fDolgnVr3;
property IDVrach3: string read fIDVrach3 write fIDVrach3;
property DateWorkAt: TDateTime read fDateWorkAt write fDateWorkAt;
property WorkOther: string read fWorkOther write fWorkOther;
property DateWorkOtherAt: TDateTime read fDateWorkOtherAt write fDateWorkOtherAt;
property VidanListNetr: string read fVidanListNetr write fVidanListNetr;
property FIOVrachKor: string read fFIOVrachKor write fFIOVrachKor;
property NumIstBolKor: string read fNumIstBolKor write fNumIstBolKor;
property DateVidKor: TDateTime read fDateVidKor write fDateVidKor;
property SS: string read fSS write fSS;
property TipogNum: string read fTipogNum write fTipogNum;
property DolgnVr1R: string read fDolgnVr1R write fDolgnVr1R;
property IDVrach1R: string read fIDVrach1R write fIDVrach1R;
property DolgnVr2R: string read fDolgnVr2R write fDolgnVr2R;
property IDVrach2R: string read fIDVrach2R write fIDVrach2R;
property DolgnVr3R: string read fDolgnVr3R write fDolgnVr3R;
property IDVrach3R: string read fIDVrach3R write fIDVrach3R;
property UchGosSl: string read fUchGosSl write fUchGosSl;
property MKB10: string read fMKB10 write fMKB10;
end;function CreateDataModel: TSQLModel;
begin
result := TSQLModel.Create([TSQLDataRecord, TSQLOptions]);
end;
procedure InitClient();
begin
Model := CreateDataModel;
Database := TSQLRestClientDB.Create(Model, CreateDataModel, ChangeFileExt(paramstr(0), '.db3'), TSQLRestServerDB);
TSQLRestClientDB(Database).Server.CreateMissingTables(0); <<<< error here
end;deleted the database run, create a new database, but again an error message.
changed some fields in some places, the error is gone, the program starts and runs normally.
TSQLDataRecord = class(TSQLRecord)
private
fTipogNum: string;
fListNetrud,
fBlankPrv,
fFam, fIm, fOt: string;
fDateBorn: TDateTime;
fSex,
fPMestoRab, fMestoRab: string;
fNetrudKod, fNetrudDopKod, fNetrudKodIzm: Integer;
fNumOrg: string;
fDate1, fDate2: TDateTime;
fNumPut, fOGRNSan,
fVozrL1, fVozrM1, fRodSv1: Integer;
fFIOChS1: string;
fVozrL2, fVozrM2, fRodSv2: Integer;
fFIOChS2: string;
fBerem: string;
fNarRej: Integer;
fDateNarRej,
fDateVStacS, fDateVStacPo,
fDateNapMSE, fDateRegMSE, fDateOsvMSE: TDateTime;
fInvalid: Integer;
fDateOsvOtRabS1, fDateOsvOtRabPo1: TDateTime;
fDolgnVr1, fDolgnVr1R, fIDVrach1, fIDVrach1R: string;
fDateOsvOtRabS2, fDateOsvOtRabPo2: TDateTime;
fDolgnVr2, fDolgnVr2R, fIDVrach2, fIDVrach2R: string;
fDateOsvOtRabS3, fDateOsvOtRabPo3: TDateTime;
fDolgnVr3, fDolgnVr3R, fIDVrach3, fIDVrach3R: string;
fDateWorkAt: TDateTime;
fWorkOther: string;
fDateWorkOtherAt: TDateTime;
fVidanListNetr: string;
fFIOVrachKor: string;
fNumIstBolKor: string;
fDateVidKor: TDateTime;
fSS,
fUchGosSl: string;
fMKB10: string;
published
property TipogNum: string read fTipogNum write fTipogNum;
property ListNetrud: string read fListNetrud write fListNetrud;
property BlankPrv: string read fBlankPrv write fBlankPrv;
property Fam: string read fFam write fFam;
property Im: string read fIm write fIm;
property Ot: string read fOt write fOt;
property DateBorn: TDateTime read fDateBorn write fDateBorn;
property Sex: string read fSex write fSex;
property PMestoRab: string read fPMestoRab write fPMestoRab;
property MestoRab: string read fMestoRab write fMestoRab;
property NetrudKod: Integer read fNetrudKod write fNetrudKod;
property NetrudDopKod: Integer read fNetrudDopKod write fNetrudDopKod;
property NetrudKodIzm: Integer read fNetrudKodIzm write fNetrudKodIzm;
property NumOrg: string read fNumOrg write fNumOrg;
property Date1: TDateTime read fDate1 write fDate1;
property Date2: TDateTime read fDate2 write fDate2;
property NumPut: Integer read fNumPut write fNumPut;
property OGRNSan: Integer read fOGRNSan write fOGRNSan;
property VozrL1: Integer read fVozrL1 write fVozrL1;
property RodSv1: Integer read fRodSv1 write fRodSv1;
property VozrM1: Integer read fVozrM1 write fVozrM1;
property FIOChS1: string read fFIOChS1 write fFIOChS1;
property VozrL2: Integer read fVozrL2 write fVozrL2;
property RodSv2: Integer read fRodSv2 write fRodSv2;
property VozrM2: Integer read fVozrM2 write fVozrM2;
property FIOChS2: string read fFIOChS2 write fFIOChS2;
property Berem: string read fBerem write fBerem;
property NarRej: Integer read fNarRej write fNarRej;
property DateNarRej: TDateTime read fDateNarRej write fDateNarRej;
property DateVStacS: TDateTime read fDateVStacS write fDateVStacS;
property DateVStacPo: TDateTime read fDateVStacPo write fDateVStacPo;
property DateNapMSE: TDateTime read fDateNapMSE write fDateNapMSE;
property DateRegMSE: TDateTime read fDateRegMSE write fDateRegMSE;
property DateOsvMSE: TDateTime read fDateOsvMSE write fDateOsvMSE;
property Invalid: Integer read fInvalid write fInvalid;
property DateOsvOtRabS1: TDateTime read fDateOsvOtRabS1 write fDateOsvOtRabS1;
property DateOsvOtRabPo1: TDateTime read fDateOsvOtRabPo1 write fDateOsvOtRabPo1;
property DolgnVr1: string read fDolgnVr1 write fDolgnVr1;
property DolgnVr1R: string read fDolgnVr1R write fDolgnVr1R;
property IDVrach1: string read fIDVrach1 write fIDVrach1;
property IDVrach1R: string read fIDVrach1R write fIDVrach1R;
property DateOsvOtRabS2: TDateTime read fDateOsvOtRabS2 write fDateOsvOtRabS2;
property DateOsvOtRabPo2: TDateTime read fDateOsvOtRabPo2 write fDateOsvOtRabPo2;
property DolgnVr2: string read fDolgnVr2 write fDolgnVr2;
property DolgnVr2R: string read fDolgnVr2R write fDolgnVr2R;
property IDVrach2: string read fIDVrach2 write fIDVrach2;
property IDVrach2R: string read fIDVrach2R write fIDVrach2R;
property DateOsvOtRabS3: TDateTime read fDateOsvOtRabS3 write fDateOsvOtRabS3;
property DateOsvOtRabPo3: TDateTime read fDateOsvOtRabPo3 write fDateOsvOtRabPo3;
property DolgnVr3: string read fDolgnVr3 write fDolgnVr3;
property DolgnVr3R: string read fDolgnVr3R write fDolgnVr3R;
property IDVrach3: string read fIDVrach3 write fIDVrach3;
property IDVrach3R: string read fIDVrach3R write fIDVrach3R;
property DateWorkAt: TDateTime read fDateWorkAt write fDateWorkAt;
property WorkOther: string read fWorkOther write fWorkOther;
property DateWorkOtherAt: TDateTime read fDateWorkOtherAt write fDateWorkOtherAt;
property VidanListNetr: string read fVidanListNetr write fVidanListNetr;
property FIOVrachKor: string read fFIOVrachKor write fFIOVrachKor;
property NumIstBolKor: string read fNumIstBolKor write fNumIstBolKor;
property DateVidKor: TDateTime read fDateVidKor write fDateVidKor;
property SS: string read fSS write fSS;
property UchGosSl: string read fUchGosSl write fUchGosSl;
property MKB10: string read fMKB10 write fMKB10;
end;structure we want to save for import into an empty database
At the moment I am temporarily using the code:
function GetZeroPaddedString (s: string; l: integer): string;
begin
Result: = Format ('%.' + IntToStr (l) + 'd', [StrToInt64 (s)]);
end;
edtBlankNumber.Text: = GetZeroPaddedString (BlankNumber, 12);it works fine and does not require modifications when updating the database of all clients using the program (each program is running locally)
What a way to change the field type, or the entire database for clients to be the easiest?
or may have to create a new database with the correct structure and import the data?
first field type number of the blank was a integer type, then I changed it to a string, but the record in this field the number 0000000001 for example written in the database 1
how to correct this situation?
some modification code
TSQLTable
public
property TableSortParams: TSQLTableSortParams read fSortParams;
TSQLTableToGrid = class (TComponent)
public
property Table: TSQLTable read fTable write fTable;Need to update Drawgrid without flicker and shift the cursor position, and are used in the following procedure:
procedure TfrmMain.RefreshRowPatients;
var
tsp: TSQLTableSortParams;
begin
tsp: = TablePatients.TableSortParams;
TablePatients: = Database.ExecuteList ([], sqlFillGrid);
if tsp.FieldType <> sftUnknown
TablePatients.SortFields (tsp.FieldIndex, tsp.Asc);
ttgPatients.Table: = TablePatients;
dgPatients.Invalidate;
end;it works, but if you want to change the value of a field have to re-recreate the table TablePatients
Is it possible to how some way to make changes directly to the table without having to call a sql
how display results from query to drawgrid like TSQLTableToGrid?
Simply say as quickly display the JSON array in Drawgrid?
i try connect to sample.dbf,
procedure TForm2.btnADOClick(Sender: TObject);
const
ADOProvider = 'Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=dBASE IV;Persist Security Info=False;Mode=ReadWrite;Data Source=';
var
base: string;
begin
base := 'D:\work\delphi\convbase';
ADOQuery1.ConnectionString := ADOProvider + base;
ADOQuery1.SQL.Text := 'select * from sample';
ADOQuery1.Open;
end;
procedure TForm2.btnSynopseClick(Sender: TObject);
var Props: TOleDBConnectionProperties;
Conn: TSQLDBConnection;
Query: TSQLDBStatement;
F: TFileStream;
begin
Props := TOleDBMSSQLConnectionProperties.Create('Microsoft.Jet.OLEDB.4.0','D:\work\delphi\convbase','','');
try
//Props.ConnectionStringDialogExecute;
Conn := Props.NewConnection;
try
Conn.Connect;
Query := Conn.NewStatement;
try
Query.Execute('select * from sample',true,[]);
F := TFileStream.Create(ChangeFileExt(paramstr(0),'.json'),fmCreate);
try
Query.FetchAllToJSON(F,false);
finally
F.Free;
end;
finally
Query.Free;
end;
finally
Conn.Free;
end;
finally
Props.Free;
end;
end;but get error
[DBNETLIB][ConnectionOpen (Connect()).]SQL-server not found
i write sample with use ADO, and Synopse http://dl.dropbox.com/u/12662204/convbase.7z
i think is very good idea create new method.
and one small question:
assume that more than two categories and I need to choose two categories, I do not know how to do it
sql direct: i simple add new select parameters
and c.name = "for boy"to
and (c.name = "for boy" or c.name = "for girl")but i don't understand how change ORM code to work with many parameters. Method SourceGet give only one ID parameter;
var
table: TSQLTable;
product: TSQLProduct;
category: TSQLCategory;
fIds: TIntegerDynArray;
s: string;
begin
product := TSQLProduct.Create;
category := TSQLCategory.Create(Database, 'name = "for boy"');
product.Categories.SourceGet(Database, category.ID, fIds);
try
s := IntegerDynArrayToCSV(fIds, length(fIds), 'id in (', ')');
product.CreateAndFillPrepare(Database, s + 'and owner = "mark"');
table := product.FillTable;
table.OwnerMustFree := False;
finally
FreeAndNil(product);
FreeAndNil(category);
end;
TSQLTableToGrid.Create(DrawGrid1, table, Database);i read documentation but i don't understand.
i create sample, left 3 button work great, but it sql direct command. In right button i try create not sql direct, first button work, but other button not work, please show me how build this selection (on button title) in orm and rest style
I read the documentation, but I did not get to realize the following example
TSQLProduct = class;
TSQLSize = class(TSQLRecord)
private
fName: UTF8String;
published
property Name: UTF8String read fName write fName;
end;
TSQLSizes = class(TSQLRecordMany)
private
fSource: TSQLProduct;
fDest: TSQLSize;
published
property Source: TSQLProduct read fSource write fSource;
property Dest: TSQLSize read fDest write fDest;
end;
TSQLForm = class(TSQLRecord)
private
fName: UTF8String;
published
property Name: UTF8String read fName write fName;
end;
TSQLForms = class(TSQLRecordMany)
private
fSource: TSQLProduct;
fDest: TSQLForm;
published
property Source: TSQLProduct read fSource write fSource;
property Dest: TSQLForm read fDest write fDest;
end;
TSQLCategory = class(TSQLRecord)
private
fName: UTF8String;
published
property Name: UTF8String read fName write fName;
end;
TSQLCategories = class(TSQLRecordMany)
private
fSource: TSQLProduct;
fDest: TSQLCategory;
published
property Source: TSQLProduct read fSource write fSource;
property Dest: TSQLCategory read fDest write fDest;
end;
TSQLProduct = class(TSQLRecord)
private
fName: UTF8String;
fOwner: UTF8String;
fCategories: TSQLCategories;
published
property Name: UTF8String read fName write fName;
property Owner: UTF8String read fName write fName;
property Categories: TSQLCategories read fCategories write fCategories;
end;sample database:
Category
id | name
1 | boy
2 | girl
Size
id | name
1 | small
2 | medium
3 | big
Form
id | name
1 | circle
2 | rectangle
3 | triangle
4 | square
Product
id | name | owner
1 | name 1 | mark
2 | name 2 | ann
3 | name 3 | mark
4 | name 4 | john
5 | name 5 | john
6 | name 6 | mark
Categories
id | source | dest
1 | 1 | 1
2 | 1 | 2
3 | 2 | 2
4 | 3 | 1
5 | 4 | 1
6 | 5 | 2
7 | 6 | 2
Sizes
id | source | dest
1 | 1 | 1
2 | 2 | 1
3 | 2 | 2
4 | 3 | 1
5 | 3 | 2
6 | 3 | 3
7 | 4 | 2
8 | 5 | 2
9 | 5 | 3
10 | 6 | 1
11 | 6 | 3
Forms
id | source | dest
1 | 1 | 1
2 | 1 | 3
3 | 1 | 4
4 | 2 | 3
5 | 3 | 2
6 | 3 | 3
7 | 4 | 3
8 | 4 | 4
9 | 5 | 1
10 | 6 | 1
11 | 6 | 4
need select all products with owner mark, category for boy, size - small or medium, form - circle or square.
I know how to do it directly using Sql, but I do not understand how to make it through the ORM
can you implement this example, it will be very helpful for beginners
my application is required to bind the table often
works, but due to lack of communication between the tables is obtained by nonsense
table := Database.List([TSQLInsertion, TSQLProduct], 'articul, insertion.name');works, but it looks awkward
table := Database.ExecuteList([TSQLInserts, TSQLProduct], 'select p.articul, t.name from product p inner join (inserts ii inner join insertion i on ii.dest = i.id) t on p.id = t.source');is it possible to create a table without using SQL directly?
something like this: http://www.sql.ru/forum/actualthread.aspx?tid=817359
so directly through the sql works fine
Database.ExecuteList([TSQLPatients, TSQLPersonDiagnoses], 'select distinct pds.Dest from Patients p inner join PersonDiagnoses pds on p.ID = pds.Source where pds.Dest between 1 and 459 and p.Sex="М" and DisNew = 1').RowCount;but I think there is more RESTful method, and that the relationship between the tables automatically be placed in the database structure and uslovich request data. If two class and both are involved in the request, the framework should automatically link the related fields and to construct a query correctly. Or can complement the function of the arguments linking?
Database.ExecuteList([TSQLPatients, TSQLPersonDiagnoses], 'Patients p inner join PersonDiagnoses pds on p.ID = pds.Source', 'distinct pds.Dest', 'pds.Dest between 1 and 459 and p.Sex="М" and DisNew = 1').RowCount;I tried to write a join condition, but always get the error
Database.List([TSQLPatients, TSQLPersonDiagnoses], 'distinct PersonDiagnoses.Dest', 'Patients inner join PersonDiagnoses on Patients.ID = PersonDiagnoses.Source where PersonDiagnoses.Dest between 1 and 459 and Patients.Sex="М" and DisNew = 1').RowCount;Database.List([TSQLPatients, TSQLPersonDiagnoses], 'distinct PersonDiagnoses.Dest', 'Patients.ID = PersonDiagnoses.Source where PersonDiagnoses.Dest between 1 and 459 and Patients.Sex="М" and DisNew = 1').RowCount;Database.List([TSQLPatients, TSQLPersonDiagnoses], 'distinct PersonDiagnoses.Dest from Patients inner join PersonDiagnoses on Patients.ID = PersonDiagnoses.Source', 'PersonDiagnoses.Dest between 1 and 459 and Patients.Sex="М" and DisNew = 1').RowCount;select all disease from table - code work very well
if CompareText(VarName, 'AllDSA00B99') = 0 then Value :=
Database.List([TSQLPersonDiagnoses], 'distinct Dest', 'dest between 1 and 459').RowCount;but if I try to merge the choice of two tables in one query:
if CompareText(VarName, 'AllMDSA00B99') = 0 then Value :=
Database.List([TSQLPersonDiagnoses, TSQLPatients], 'distinct PersonDiagnoses.Dest', 'PersonDiagnoses.Dest between 1 and 459 and Patients.Sex="М"').RowCount;I get the same result as in the first query, although the number of patients must be less than the previous query
structure class:
TSQLPerson = class(TSQLRecord)
private
fFam, fIm, fOt,
fSex: string;
...
end;
TSQLPatients = class(TSQLPerson)
private
...
fDiagnoses: TSQLPersonDiagnoses;
...
end;
TSQLPersonDiagnoses = class(TSQLRecordMany)
private
...
fDisNew: Boolean;
fSource: TSQLPatients;
fDest: TSQLPersonDiagnose;
...
end;I have a few sqlite3 database that I need to integrate automatically in the program.
Using ADO I have done so
insert into secondbase select * from firstbaseHow to make good use of this wonderful framework?
WOW is pretty simple, thanks!
It is often necessary to leave the date blank
use ADO i write
if query.FieldByName('DATE_BL').IsNull then dedtDATE_B.Clear
else dedtDATE_B.Date := FieldByName('DATE_BL').AsDateTime;i write procedure, but i think is a bad way to check null datetime
procedure ReadDate(dedt: TRzDateTimeEdit; d: TDateTime);
begin
if DatetoStr(d) = '30.12.1899' then dedt.Clear
else dedt.Date := d;
end;use ADO i write for count all man:
query.SQL.Text := 'select count(id) as cnt from table where Sex = "M"';
query.Open;
ManCount := query.FieldByName('cnt').AsInteger;or
query.SQL.Text := 'select id from table where Sex = "M"';
query.Open;
ManCount := query.RecordCount;how use framework qiuck count Man?
Mans := Database.List([TSQLPatients], '*','Sex = "М"').RowCount; this code work, but is a good way??
what other way can count the number of people with the condition?
I want to assign key Delete on event onKeyDown in a particular table. If i use IDE double click on event onKeyDown and write my code - nothing happens.
how correct set events to DrawGrid?
How can I assign a visually set event onKeyDown in Drawgrid or this is only possible programming method?
i try execute you sample, but i get error: [DCC Error] uMain.pas(347): E2010 Incompatible types: 'TSQLDatabase' and 'TSQLRestClientURI'
var
Database: TSQLRestClientURI;I solved problem using for TSQLTable, but i dont understand how use TSQLTableDB
var
TableRole: TSQLTable;
sql: string;
begin
sql := 'select UserRoles.ID, UserRole.RoleName from UserRoles inner join UserRole on UserRoles.Dest=UserRole.ID';
TableRole := Database.ExecuteList([], sql);
TSQLTableToGrid.Create(dgRoles, TableRole, Database);
end;maybe any create very simple sample using this method?
i too try search russian letter
Rec := TSQLUser.Create(globalClient, 'FirstName like "%%%"', [UpperCase(Search.Text)]);or
Rec := TSQLUser.Create(globalClient, 'FirstName like "%%%"', [UpperCaseU(Search.Text)]);0 results
but if i use standart function uppercase:
function AnsiUpperCase(const S: string): string;
{$IFDEF MSWINDOWS}
var
Len: Integer;
begin
Len := Length(S);
SetString(Result, PChar(S), Len);
if Len > 0 then
CharUpperBuff(PChar(Result), Len);
end;
{$ENDIF MSWINDOWS}
{$IFDEF POSIX}
begin
Result := WideUpperCase(S);
end;
{$ENDIF POSIX}work with unicode string fine
Rec := TSQLUser.Create(globalClient, 'FirstName like "%%%"', [AnsiUpperCase(Search.Text)]);thank for reply i found solution:
Rec := TSQLDataRec.Create(Database, 'Fam like "%%%"', [Search.Text]);its work fine!
i try search record with like
not work
Rec := TSQLDataRec.Create(Database, 'Fam like "%"', [Search.Text]);work
Rec := TSQLDataRec.Create(Database, 'Fam like "%"', [Search.Text + '%']); Rec := TSQLDataRec.Create(Database, 'Fam like "%' + Search.Text + '%"');Table1
id data
----------
1 | One
2 | Two
3 | Three
4 | Four
Table2
id id_t1 otherdata
-------------------------
1 | 1 | otherdata
2 | 1 | otherdata
3 | 2 | otherdata
4 | 2 | otherdata
need run query: select Table1.data, Table2.otherdata from Table2 inner join Table1 on Table2.id_t1 = Table1.id to get
ResultTable
id data otherdata
-------------------------
1 | One | otherdata
2 | One | otherdata
3 | Two | otherdata
4 | Two | otherdata
how get resulttable in SQLite3 Framework?