Subject | Re: [IBO] Re: Entering Litterals, Expressions directly into TIBOQuery Update SQL |
---|---|
Author | Helen Borrie |
Post date | 2006-06-23T10:10:25Z |
At 06:33 PM 23/06/2006, Lester wrote:
and stretch his code to make IBO do what it does automatically.
You don't need the TIBOUpdateSQL *at all* - it's only there for
compatibility when people are converting an old BDE
application. TIBOQuery has the UpdateSQL properties embedded
(EditSQL, InsertSQL and DeleteSQL). What's more, you don't have to
set them yourself unless you've got datasets that have to be update
with specialised statements such as EXECUTE PROCEDURE calls.
For your master-detail setup, do the following basics:
1. Set up the master and its datasource first, e.g. qMaster and
dsMaster, with SQL that is typically
select mstrpkfield, fieldx, fieldy from mymaster
where <some parameterised conditions)
Set its KeyLinks property to mstrpkfield and set RequestLive true.
If you are generating primary keys then set GeneratorLinks as:
pkfield=mypkgeneratorname
2. Then set up the detail, e.g. QDetail and its datasource
dsDetail. The SQL will be in one of two forms:
a) if the fieldnames of the detail's foreign key and the master's
primary key are the same then your query will be:
select detlpkfield, mstrpkfield, fieldwhatever, .... from mydetail
b) if the foreign key of the detail set and the PK of the master set
don't have matching names then the detail's SQL will be
select detlpkfield, mstr_gulp_pkfield, fieldwhatever, ....from mydetail
where mstr_gulp_pkfield = :mstr_gulp_pkfield
Set the Keylinks to detlpkfield and set RequestLive true.
Set the Datasource property to dsMaster.
If you are generating primary keys then set GeneratorLinks as:
detlpkfield=mydetlpkgeneratorname
In both cases, by setting correct Keylinks and setting RequestLive
true, you are telling IBO to generate the three UpdateSQL statements
automatically.
If the detail's FK name and the master's PK name are same (situation
a) above) then you are done. Your master-detail interface will "just work".
If the names are different then you have one more thing to do. Go to
the AfterScroll event of the master set and add the following code:
QDetail.ParamByName('mstr_gulp_pkfield').AsInteger :=
Dataset.FieldByName('mstrpkfield').AsInteger;
And now you are ready to roll.
Helen
>BECAUSE Field2 is in your SQL it MUST have a valid value. The DEFAULTNot in the least - I totally agree with you. Tony is trying to bend
>will only be used by Firebird when Field2 is missing from the query. By
>putting it in the query you also need to supply a value for it.
>
>Helen will probably slap my hand ;) but I think that you are being
>pushed to do things that are far more complex than is needed.
and stretch his code to make IBO do what it does automatically.
You don't need the TIBOUpdateSQL *at all* - it's only there for
compatibility when people are converting an old BDE
application. TIBOQuery has the UpdateSQL properties embedded
(EditSQL, InsertSQL and DeleteSQL). What's more, you don't have to
set them yourself unless you've got datasets that have to be update
with specialised statements such as EXECUTE PROCEDURE calls.
For your master-detail setup, do the following basics:
1. Set up the master and its datasource first, e.g. qMaster and
dsMaster, with SQL that is typically
select mstrpkfield, fieldx, fieldy from mymaster
where <some parameterised conditions)
Set its KeyLinks property to mstrpkfield and set RequestLive true.
If you are generating primary keys then set GeneratorLinks as:
pkfield=mypkgeneratorname
2. Then set up the detail, e.g. QDetail and its datasource
dsDetail. The SQL will be in one of two forms:
a) if the fieldnames of the detail's foreign key and the master's
primary key are the same then your query will be:
select detlpkfield, mstrpkfield, fieldwhatever, .... from mydetail
b) if the foreign key of the detail set and the PK of the master set
don't have matching names then the detail's SQL will be
select detlpkfield, mstr_gulp_pkfield, fieldwhatever, ....from mydetail
where mstr_gulp_pkfield = :mstr_gulp_pkfield
Set the Keylinks to detlpkfield and set RequestLive true.
Set the Datasource property to dsMaster.
If you are generating primary keys then set GeneratorLinks as:
detlpkfield=mydetlpkgeneratorname
In both cases, by setting correct Keylinks and setting RequestLive
true, you are telling IBO to generate the three UpdateSQL statements
automatically.
If the detail's FK name and the master's PK name are same (situation
a) above) then you are done. Your master-detail interface will "just work".
If the names are different then you have one more thing to do. Go to
the AfterScroll event of the master set and add the following code:
QDetail.ParamByName('mstr_gulp_pkfield').AsInteger :=
Dataset.FieldByName('mstrpkfield').AsInteger;
And now you are ready to roll.
Helen