Subject Re: [IBO] Cannot insert a new Row
Author Helen Borrie
At 12:05 PM 9/03/2004 +0000, you wrote:
>I'm trying to insert a new record in a IBOQuiery with the follow SQL
>sentence:
>
> >> Select T1.*, T2.SEC_LEVEL PARENT_SEC_LEVEL, t2.PROF_ID PARENT_PROF
> >> From UCS_PACCESS T1 left outer join UCS_PACCESS T2 on
> >>
> >> T2.PROF_ID = (Select PARENT_PROF From UCS_PROFILES WHERE
> >> PROF_ID = T1.PROF_ID) and
> >> T2.APP_ID = T1.APP_ID and
> >> T2.COMP_ID = T1.COMP_ID and
> >> T2.FORM_ID = T1.FORM_ID
> >>
> >> Where (t1.APP_ID = :APP_ID1 or 0=:APP_ID2) and
> >> T1.PROF_ID = :PROF_ID
> >>
> >> ORDER BY T1.APP_ID, T1.FORM_ID, T1.COMP_ID
>
>Any idea why I get this message?

You can't perform any ordinary insert, update or delete on a joined
set. You need to write stored procedures that do the operations you
require. Write the stored procedures with input parameters for each column
value from the output set that is needed for the update, delete or insert
operation. Obviously, for an insert, that will be all of them.

In your dataset, use the InsertSQL property to place a parameterised
EXECUTE statement that will be invoked when your application posts an
Insert. If the field names and parameter names match, IBO will take care
of the parameter assignments - otherwise you will need to assign them
yourself in BeforePost.

(To be able to update and delete rows, you will need to do likewise for
EditSQL and DeleteSQL). This technique can also be used for stored
procedures and non-updateable views.

If you only want to update *one* of the underlying tables, you can use the
KeyRelation property instead. Set this property to the name of the
underlying table that is to receive the changes. IBO will take care of
creating the statements for data changes.

Everything will work, as long as your KeyLinks are
good. KeyLinksAutoDefine won't work for joined sets - you must provide
them explicitly.

Helen