-
1. Re: insert "update procedures" query by inner join.
rareddy Jul 10, 2015 9:54 AM (in response to prashanthi1)see an example of the insert here. Parsing errors in Designer "Error in parsing of sql - Encountered " "new" "new "" at line 4, column 75"
In Designer, where you entered the "select" transformation with inner joins, there tabs for insert and update and delete.
Also see similar request here composite insert using Teiid
-
2. Re: insert "update procedures" query by inner join.
prashanthi1 Jul 10, 2015 10:38 AM (in response to rareddy)Hi Ramesh,
Thanks for the reply.
I have been able to insert in to multiple tables by using update procedures, but i am facing problem in inserting when the tables have to joined by INNER JOIN.
for the select query i have given above i am not able to right a equivalent insert query.
If is one common column(say ID) in all the three tables, can i insert it by INNER JOIN like i did for select(i.e enter value of ID once and it inserts in to all the three tables) or do i need to explicitly insert in to each table after joining them?
Thanks,
Prashanthi.
-
3. Re: insert "update procedures" query by inner join.
rareddy Jul 10, 2015 11:24 AM (in response to prashanthi1)There are NO JOINS in a INSERT query. INSERT by definition only works against single table.
If there are two source tables like table A { X, Y} and table B {X, Z} and, and your Teiid view table is exposing view like C {X, Y, Z} where the the transformation is like
SELECT A.X, A.Y, B.Z FROM A INNER JOIN B ON A.X = B.X
then the INSERT procedure will be like below. Note that the Insert you are writing is against the source tables you built the View with, not to the View itself.
FOR EACH ROW BEGIN ATOMIC INSERT INTO A (X, Y) values ("NEW".X, "NEW".Y); INSERT INTO B (X, Y) values ("NEW".X, "NEW".Y); END
UPDATE will be like
FOR EACH ROW BEGIN ATOMIC IF (CHANGING.Y) BEGIN UPDATE TABLE A SET Y= "NEW".y; UPDATE TABLE B SET Y= "NEW".y; END END
DELETE query will look like
FOR EACH ROW BEGIN ATOMIC DELETE FROM A WHERE X = OLD.X; DELETE FROM B WHERE X = OLD.X; END
Then once the VDB is built, you can issue the queries like below against the View Table C
SELECT * FROM C; INSERT INTO C (X, Y, Z) VALUES (1, 2, 3) UPDATE C SET Y=4, Z= 5 WHERE X = 1 DELETE FROM C WHERE X = 1
Hopefully this explains clearly what needs to be done.
Ramesh..
-
4. Re: insert "update procedures" query by inner join.
prashanthi1 Jul 13, 2015 1:04 PM (in response to rareddy)This is very clear now. Thank you very much Ramesh.