Subject Re: [IBO] ADVICE PLEEASE!!!
Author Lucas Franzen
Dion,

As Leigh wrote, use a stored procedure.

create procedure SP_TWO_TABLES (
T1_ID INTEGER,
T2_ID INTEGER,
T1_NAME VARCHAR(30), /* or whatever */
T2_NAME VARCHAR(30),
MYACTION CHAR(1)
)
as
begin
IF ( MYACTON = 'I' ) THEN
BEGIN
INSERT INTO Table_1 ( T1_ID, NAME ) VALUES ( :T1_ID, :T1_NAME );
INSERT INTO Table_2 ( T2_ID, NAME ) VALUES ( :T2_ID, :T2_NAME );
END
ELSE IF ( MYACTION = 'U' ) THEN
BEGIN
UPDATE TABLE_1 SET T1_NAME = :T1_NAME WHERE T1_ID = :T1_ID;
UPDATE TABLE_2 SET T2_NAME = :T2_NAME WHERE T2_ID = :T2_ID;
END
end;

Now you can execute this procedure by using the UpdateSQL property of th
TIB_Query.

In the EditSQL you can enter:
EXECUTE PROCEDURE SP_TWO_TABLE S( :T1_ID, :T2_ID, :T1_NAME, :T2_NAME,
'U' );
and in the Insert SQL you can enter:
EXECUTE PROCEDURE SP_TWO_TABLE S( :T1_ID, :T2_ID, :T1_NAME, :T2_NAME,
'I' );

Note:
- I added the MYACTION-param so tht you can use one proceudres for both
actions: as well inserting as updating. If you don't need it, omit it.
- The param-names of the procedure (in the edit-/insert-SQL) should
reflect the fieldnames of your join.
- set the RequestLive-property of your query to true

HTH
Luc.



Dion schrieb:
>
> Hi all,
>
> I have spent a lot of time investigating the following problem and have come to the conclusion that the problem can be only be solved by changing the GUI and data input strategy, unless I am missing an important IBO feature. I need to do the following:-
>
> Table_1
> T1_ID
> NAME
>
> Table_2
> T2_ID
> NAME
>
> Table_1_Table_2
> T1_ID
> T2_ID
> T1_NAME
> T2_NAME
>
> Grid
> ------------------------------------------------------
> T1_ID : T2_ID : T2_NAME :
> ------------------------------------------------------
> : : : :
>
> Is it possible to 'somehow' insert a record into Table_2 when I insert into Table_1_Table_2 and edit the fields of Table_2(T2_NAME) from within the context of the Table_1_Table_2 join. ie directly add the name from within the Grid in this case?
>
> Many Thanks,
> Dion.
>
> [Non-text portions of this message have been removed]
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/