Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread Canned result and update database
Wed, Nov 29 2006 8:08 AMPermanent Link

Tom
Hello,

I have canned sql result in TDBISAMQuery, I can edit data in grid but it is not saved in database.
I can't change or improve SQL to make it live for technical reason but
I think it is possible to update database manually somehow using Update SQL and OnPost event.

Mayeb someone has suggestions?

Regards,
Tomas
Wed, Nov 29 2006 12:16 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Tomas,

<< I have canned sql result in TDBISAMQuery, I can edit data in grid but it
is not saved in database. I can't change or improve SQL to make it live for
technical reason but I think it is possible to update database manually
somehow using Update SQL and OnPost event. >>

Sure, just use the AfterPost and AfterDelete events of the TDBISAMQuery
component to propogate any updates to the canned result set to the actual
table(s).  The only requirement is that the query select at least all of the
required primary key values from all tables that need to be updated.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Nov 29 2006 3:19 PMPermanent Link

Tom
Maybe someone could share code how to do that in optimal way?

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote:

Tomas,

<< I have canned sql result in TDBISAMQuery, I can edit data in grid but it
is not saved in database. I can't change or improve SQL to make it live for
technical reason but I think it is possible to update database manually
somehow using Update SQL and OnPost event. >>

Sure, just use the AfterPost and AfterDelete events of the TDBISAMQuery
component to propogate any updates to the canned result set to the actual
table(s).  The only requirement is that the query select at least all of the
required primary key values from all tables that need to be updated.

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Nov 29 2006 6:02 PMPermanent Link

"Robert"

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:70F96B33-039E-478A-A63D-DC9B3484B40F@news.elevatesoft.com...
>
> Sure, just use the AfterPost and AfterDelete events of the TDBISAMQuery

BEFORE delete, after delete it is too late.

Robert

Thu, Nov 30 2006 2:20 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Robert,

<< BEFORE delete, after delete it is too late. >>

You could save the row values in the BeforeDelete, but you can't say for
sure that the delete was successful until the AfterDelete is fired.

--
Tim Young
Elevate Software
www.elevatesoft.com

Thu, Nov 30 2006 2:28 PMPermanent Link

"Robert"

"Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message
news:FF3E9B7B-83D7-44E4-8B17-5E18A46956A3@news.elevatesoft.com...
> Robert,
>
> << BEFORE delete, after delete it is too late. >>
>
> You could save the row values in the BeforeDelete, but you can't say for
> sure that the delete was successful until the AfterDelete is fired.
>

Yeah, I guess you're right, though I have never seen a delete fail, so I
code these things before delete and seems to be OK.

But the problem can get more interesting. What if you have before post edits
in your live table? You can post the canned dataset only to have the posting
of the live dataset fail because some field values are incorrect. So always
use a try except.

Anyway, if it was easy we would not be making so much money, right?

Robert

Fri, Dec 1 2006 1:56 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Robert,

<< Yeah, I guess you're right, though I have never seen a delete fail, so I
code these things before delete and seems to be OK. >>

A record lock failure would prevent a delete from occurring.  That's
probably the most common.

<< But the problem can get more interesting. What if you have before post
edits in your live table? You can post the canned dataset only to have the
posting of the live dataset fail because some field values are incorrect. So
always use a try except. >>

Yep, or an OnPostError.

<< Anyway, if it was easy we would not be making so much money, right? >>

Yeah, that sounds about right....  Wink

--
Tim Young
Elevate Software
www.elevatesoft.com

Image