Subject Re: [IBO] Problems with Keylinks
Author Tony Masefield
--- In IBObjects@yahoogroups.com, Lester Caine <lester@l...> wrote:
> Tony Masefield wrote:
>
> > Hi All,
> >
> > I'm using IBO with Firebird 1.5.2 and generate (via TIBO query)
the
> > select query on a view. The inset/update SQL is "auto-generated"
and
> > then modified to remove some fields that have default values on
the
> > underlying table (otherwise the defaults in the underlying table
> > have no effect) when the data changes are commited. On exiting
the
> > TIBO query one gets a "keylink error". Deleting the auto-
generated
> > keylinks statement, choosing 'OK' and setting the query as
active
> > works. But, if one returns to the query editor and opens
the 'Column
> > Attributes' tab, the firlds are blank. Hitting'Prepare dataset"
one
> > again gets an "invalid Keylinks Error. Deleting the keylink and
> > hitting "Prepare Dataset" populates the column - until one
restarts
> > the query editor!
> > Exhiting the query editor generates the, now anoying, 'Keylinks
> > Error".
> > Opening the query editor, dleteting the keylinks and then
activating
> > the query works again - but now the column attributes have once
> > again bitten the dust.
> > "Keylinks" is set, BTW, as autodefine.
> >
> > Any advice welcomed!
>
> There is something in your query that is preventing IBO from
> establishing a unique keylink for every record. You will have to
share
> with us the actual query.
> It SHOULD default to DB$KEY if it can't find anything better, but
if you
> are managing to update the record, that value may be changing and
so the
> result can not be seen.
> It is always best to include a clean keylink that can be used to
read
> the record what ever you do to it, but I have managed to confuse
things
> and so have seen 'Keylinks error' myself.
>
> --
> Lester Caine
> -----------------------------
> L.S.Caine Electronic Services

Hi Lester,

As mentioned the 'problem' query is on a view that is a subset of a
table. The code from the TIBO Query is:
SQL:

SELECT *
FROM "View_MaintReq_Originator"

(Where * is:
REQUEST_ID (Primary Key),
ORIGINATOR,
DEPARTMENT
PRIORITY,
MAINTENANCE_TYPE,
ASSET_NUMBER,
ASSET_DESC,
ORIGINATION_DATE,
LAST_UPDATED,
ORIGINATOR_COMPLETED_DATE
REQUEST_SHORT_DESCRIPTION,
ORIGINATOR_COMMENTS,
ORIGINATOR_FINISHED)

Edit SQL:

UPDATE "View_MaintReq_Originator" SET
REQUEST_ID = :REQUEST_ID,
PRIORITY = :PRIORITY,
MAINTENANCE_TYPE = :MAINTENANCE_TYPE,
ASSET_NUMBER = :ASSET_NUMBER,
ASSET_DESC = :ASSET_DESC,
REQUEST_SHORT_DESCRIPTION = :REQUEST_SHORT_DESCRIPTION,
ORIGINATOR_COMMENTS = :ORIGINATOR_COMMENTS,
ORIGINATOR_FINISHED = :ORIGINATOR_FINISHED
WHERE
RDB$DB_KEY = :DB_KEY

Insert SQL:

INSERT INTO "View_MaintReq_Originator"(
REQUEST_ID,
PRIORITY,
MAINTENANCE_TYPE,
ASSET_NUMBER,
ASSET_DESC,
REQUEST_SHORT_DESCRIPTION,
ORIGINATOR_COMMENTS,
ORIGINATOR_FINISHED)
VALUES (
:REQUEST_ID,
:PRIORITY,
:MAINTENANCE_TYPE,
:ASSET_NUMBER,
:ASSET_DESC,
:REQUEST_SHORT_DESCRIPTION,
:ORIGINATOR_COMMENTS,
:ORIGINATOR_FINISHED)

Delete SQL:

DELETE FROM "View_MaintReq_Originator"
WHERE
RDB$DB_KEY = :DB_KEY

Autogenerated keylinks:

"View_MaintReq_Originator".RDB$DB_KEY

The Edit and Insert fields are the same as for the select query
except for the 3 date fields.
Request_ID is inserted via a generator on the table (before insert).
Both ORIGINATION_DATE and LAST_UPDATED have defaults of 'Today' in
the table and are omitted from the Insert and edit SQL (otherwise
they are not set to their defaults if included in the view (see
previous post)).
The LAST_UPDATED date will be set programatically when the record is
updated. The ORIGINATOR_COMPLETED_DATE will be set based on boolean
field ORIGINATOR_FINISHED, when the maintenance request is finalised.
The ORIGINATOR_FINISHED field is a domain of type BOOL (T or F).
I mention these later aspects in case they have any bearing on the
problem.
There is a complemantary view for the maintenance personnel (rather
than the maintenance requestor/originator) but have not finalised
this query as yet because of the current problems with this view.

After completeing the query, attempting to activate the query
results in the "Invalid Keylinks Error". Deleting the autogenerated
Keylinks, hitting OK and then activating the query appears to work
(no error and the program seems OK) but if one returns to the query
and tries to change anything (such as hitting prepare dataset whilst
in the Column Attributes tab (the column attributes are blank at
this point)) one again gets the keylinks error. Deleting the keylink
and again setting active to true works but the column attributes
dissappear (although I must say I haven't set any column attributes).

Once again, any ideas? No problem with any further info if required.