Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 6 of 6 total
Thread Examples of how to use TEDBUpdateSQL component
Fri, May 3 2013 5:11 AMPermanent Link

Adam Brett

Orixa Systems

I almost exclusively use the TEDBQuery in my work.

Lots of perfectly OK code setting the SQL.Text and ParamByName() properties.

Sometime when I wasn't looking, Tim has introduced the TEDBUpdateSQL component onto the EDB pallet in Delphi. (Smile... It looks interesting, as it seems to allow the setting of multiple SQL statements, and calling them in different contexts, particularly through the ClientDataset (which I also use).

... There is some Help, but its a bit thin.

Does anyone have any examples of how to use this component, particularly whether it is possible to set Param's detailed in the various SQL properties dynamically & how it is used with the ClientDataset ... ???
Fri, May 3 2013 10:53 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Adam,

<< Does anyone have any examples of how to use this component, particularly
whether it is possible to set Param's detailed in the various SQL properties
dynamically & how it is used with the ClientDataset ... ??? >>

The parameters are matched up by column name, so just use :MyColumn,
:MyOtherColumn, etc. in order to use parameters with the SELECT, INSERT,
UPDATE, and DELETE statements.  The TClientDataSet/TDataSetProvider
components then uses these parameters to move data in and out of the
referenced table(s).

Tim Young
Elevate Software
www.elevatesoft.com


Fri, Jan 24 2014 5:23 AMPermanent Link

George

Trying to use TEDBUpdateSQL to learn how it works, I've created a small application with a simple database of one table only.

CREATE TABLE "CC"
(
"CCID" INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 0, INCREMENT BY 1),
"CCName" VARCHAR(100) COLLATE "ELL" NOT NULL,
"AccCode" VARCHAR(15) COLLATE "ELL",
CONSTRAINT "PrimaryKey" PRIMARY KEY ("CCID")
)

In the application I have a TEDBQuery (EDBQuery1) with an SQL Statement
SELECT * FROM CC

This is not a live result query just for the puproses of the application.

Here it comes now the use of TEDBUpdateSQL (EDBUpdateSQL1).
I have set EDBQuery1.UpdateObject = EDBUpdateSQL1

EDBUpdateSQL1.InsertSQL = INSERT INTO CC (CCName) VALUES (:CCName)

I created a button on the form with just the following code.
1. EDBUpdateSQL1.SetParams(ukInsert);
2. EDBQuery1.Append;
3. EDBQuery1CCName := 'test';
4. EDBQuery1.Post;

Execution returns error on line 2. Cannot modify a read-only dataset.

I tried several ways, even setting InsertSQL, ModifySQL, and DeleteSQL, but nothing.

How do I call EDBUpdateSQL for an execution?

Is there any sample where I can refer to?
Tue, Jan 28 2014 5:16 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Georgios,

<< Here it comes now the use of TEDBUpdateSQL (EDBUpdateSQL1).
I have set EDBQuery1.UpdateObject = EDBUpdateSQL1 >>

You can't use the TEDBUpdateSQL component like that.  It is strictly for use
with the TClientDataSet/TDataSetProvider components.

But, to answer your question - the reason for the error is that you're
trying to update (Append/Post) an insensitive result set:

http://www.elevatesoft.com/manual?action=viewtopic&id=edb2sql&topic=Result_Set_Cursor_Sensitivity

Tim Young
Elevate Software
www.elevatesoft.com
Wed, Jan 29 2014 2:43 AMPermanent Link

George

It is quite obvious why I get the error. I understand the reasons and the example was made just because I was trying to understand TEDBUpdateSQL usage. I could not find a way to use the component till now.

Is there any example from you that makes use of TEDBUpdateSQL? It would be really great if you could give us one.
Wed, Jan 29 2014 4:14 AMPermanent Link

George

Okay, I found the way to use it. I added two more components a  TDataSetProvider (DataSetProvider1) and a  TClientDataSet (ClientDataSet1).

I changed the following part:
EDBQuery1.Append;
EDBQuery1CCName := 'test';
EDBQuery1.Post;

to

ClientDataSet1.Append;
ClientDataSet1CCName := 'test';
ClientDataSet1.Post;
ClientDataSet1.ApplyUpdates(0);
Image