SQLInsert, SQLUpdate, etc

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
ebrenne
Posts: 1
Joined: Sun 28 Nov 2021 19:34

SQLInsert, SQLUpdate, etc

Post by ebrenne » Sun 28 Nov 2021 19:40

Hi

I'm trying to understand how the SQL, SQLInsert, SQLUpdate and SQLDelete works in the TUniQuery. In the main SQL I have the Select SQL statement but can I have an insert, update or delete SQL as well without using separate TUniQuery objects? I need this for a web app in Elevate Web Builder and I have to specify SQL statements for Select, Insert, Update and Delete. After I have generated the SQL statements for Insert, Update and Delte, only the parameters for the main SQL statements is visible. How do I set the params for these other SQL statements and how to I specifically execute each of them? For Example, how to I assigne params and execute the SQLUpdate?

Thanks and best regards
Eivind

MaximG
Devart Team
Posts: 1822
Joined: Mon 06 Jul 2015 11:34

Re: SQLInsert, SQLUpdate, etc

Post by MaximG » Thu 09 Dec 2021 13:35

You can use the usual methods of Append, Edit, Post when working with UniQuery. After all, using properties such as SQLDelete, SQLInsert, SQLUpdate is not mandatory. You can check it by yourself,
specifying in the UniQuery.SQL property the simplest query as follows: Select * From TABLENAME. For example, when executing the Append method, in this query there will be data insertion into the TABLENAME table, even without specifying the SQLInsert property value. In this case, UniDAC will generate a query for inserting by itself.
To update data using parameters, you can use the following approach:

Code: Select all

    UniQuery.SQL.Text := 'Update DEPT Set Loc = :Param1 Where DEPTNO=:Param2';
    UniQuery.ParamByName('Param1').AsString := 'Barcelona';
    UniQuery.ParamByName('Param1').AsInteger := 10;
    UniQuery.Execute;

Post Reply