Click here to Skip to main content
12,075,066 members (64,568 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: PostgreSQL
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 14-Nov-12 17:20pm

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Your trigger should be more or less like this one..
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
  Permalink  
v2
Comments
manesh sharma 15-Nov-12 10:38am
   
can u give the code in postgresql
Anusha SR 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160208.1 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100