Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
The query is a follows

Table A
gid(pK) Flag Buffer_distance the_geom
1 1 23
2 2 235
3 1 55
4 3 66
5 2 42
6 1 2123


Table B
GID (PK) Buffer_distance
1 1000
2 2000
3 3000
table a should get the buffer distance from table B and when I change the value of flag in table A and along with this it should also update the_geom colmn


Table A
gid(pK) Flag Buffer_distance the_geom
1 1 23
2 2 235
3 3 3000
4 3 66
5 2 42
6 1 2123


the result should be like this and the_geom field also change dynamically

i want a trigger that i always update the flag in table A it should fetch the buffer distance from table B and replace it with Buffer_distance in table A and its geometry field should also change.

regards
Manish sharma
Posted

1 solution

Your trigger should be more or less like this one..
SQL
Alter TRIGGER rowInsteadOfupDATE ON [dbo].[Table_1]
INSTEAD OF Update
AS
    declare @flag int;
    declare @distance int;
    declare @gid int;
    select  @flag =i. flag from inserted i;;
    select @gid =i.gid from inserted i;
    BEGIN
        Select @distance=distance from Table_2 where gid=@flag
        print @distance
        print @flag
            update Table_1 set flag=@flag, distance=@distance where gid=@gid;

              PRINT 'Record Updated ';

    END
GO
 
Share this answer
 
v2
Comments
manesh sharma 15-Nov-12 10:38am    
can u give the code in postgresql
Divya RS 16-Nov-12 22:48pm    
sorry manesh, am new to postgresql...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900