On Wednesday 29 March 2006 09:43, Arí Ricardo Ody wrote:
> At 14:19 29/3/2006, you wrote:
> >OK I think I understand at least one of your issues. For you to be able
> > to 'update' the SQL select statement must have a PK. The PK is used when
> > making an update statement (I have not tried using delete but I bet it
> > needs a PK to delete).
> >
> >BTW I think you can program the update,delete, and insert statements in
> > the connection. I'm not sure about this because I haven't tried it.
> > The connection has the 'executedirect' procedure. So just pass the sql
> > string to the procedure. Of course that would mean you are not using the
> > query control to handle the updates etc....
> >
> >John
>
> I think that it isn't true, John. A DB2 table must have a PK, both of
> us know it. But, considering that I'm using DBNavigator/DBGrid I
> think that the commands update and delete must be doing using a
> similar way of the "WHERE CURRENT"
> clause. The treatment of PK's(an their indexes) is done by the
> database routines. I never saw a program execute commands to update
> indexes and so on.
> In a simple way: All key/index maintenance is done at DB2 internal
> routines level.
>
> [ ]
>
> Ricardo
In my case I used "Select custno,company from arcust" as my sql statement in
the sqlquery. I then attempted to update the data using the sqlquery 'post',
'applyupdates' procedures. It immediately failed. However, "select * from
arcust" work as expected. The reason the first fail and the second succeed
was the lack of the PK being availabe to the sqlquery. When you open the
sqlquery as in 'sqlquery1.open;' in the background a request is made to the
database engine that returns the PK field name. I discovered this by
reviewing the logs of the database engine (in my case that is a Postgres
database engine). So when you update the data using the 'applyupdates'
procedure the sqlquery control knows how to write the update statement. In
other words sqlquery creates the update as follows:
update table set field = something where PKfield = some number
The opening of the sqlquery (sqlquery.open;) determined the 'PKfield' in the
above statement.
If I am incorrect could someone enlighten both of us!
John
_________________________________________________________________
To unsubscribe: mail [EMAIL PROTECTED] with
"unsubscribe" as the Subject
archives at http://www.lazarus.freepascal.org/mailarchives