[Pas2js] Post in TSQLDBRestDataset

Michael Van Canneyt michael at freepascal.org
Mon Apr 12 21:29:03 CEST 2021



On Mon, 12 Apr 2021, Gabriele Cappelletto via Pas2js wrote:

> The test table is this:
>
> CREATE TABLE COUNTRY
> (
>   ISO char(2) NOT NULL,
>   NAME varchar(80) NOT NULL,
>   NICENAME varchar(80) NOT NULL,
>   ISO3 char(3) DEFAULT NULL,
>   NUMCODE smallint,
>   PHONECODE smallint NOT NULL,
>   CONSTRAINT COUNTRY_PKEY PRIMARY KEY (ISO)
> );
>
> The database is firebird 2.5
>
> In the server I wrote:
>
> FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, 
>
>            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);
>
>
> but it gives me the problem listed below. So then I wrote
>
>
> FDisp.ExposeDatabase(TIBConnectionDef.TypeName,'localhost','/var/tmpGabry/testrest.fdb','SYSDBA','masterkey',Nil, 
>
>            [foFilter,foInInsert,foInUpdate,foOrderByDesc]);
>
>     With FDisp.Schemas[0].Schema.Resources do
>       begin
> FindResourceByName('country').Fields.FindByFieldName('ISO').Options:=[foInKey,foInInsert, 
> foInUpdate,foRequired,foFilter,foOrderBy,foOrderByDesc];
>         end;

That should be enough. The foInKey tells the server to use the field ISO as
the primary key.

Together with the client-side
FieldByname('ISO').ProviderFlags:=[pfInkey,pfInUpdate];

It should work. (you obviously need both)

A mechanism to set the client-side field properties based on server-side
metadadata (all data is available, after all) is still on my todo list...

Michael.


More information about the Pas2js mailing list