Re: newbie: Creating a function
От | Thomas F. O'Connell |
---|---|
Тема | Re: newbie: Creating a function |
Дата | |
Msg-id | 3C615A70.1010000@monsterlabs.com обсуждение исходный текст |
Список | pgsql-general |
it would end up looking something like the following: create function OwnedGoods( varchar( 6 ), varchar( 2 ), int, int, int, int, int, int ) returns int as ' DECLARE GMM_ID alias for $1; Div_ID alias for $2; Loc1 alias for $3; Loc2 alias for $4; Loc3 alias for $5; Loc120 alias for $6; Loc15 alias for $7; Cheshire alias for $8; BEGIN /* * see http://developer.postgresql.org/docs/postgres/plpgsql.html * for more info... */ END; ' language 'plpgsql'; -tfo > Here's the definition in MS: > '-----START > > CREATE Function OwnedGoods > ( @GMM_ID varchar(6) > , @Div_ID varchar(2) > , @Loc1 int > , @Loc2 int > , @Loc3 int > , @Loc120 int > , @Loc15 int > , @Cheshire int > ) > Returns Int > As > Begin > Declare @Total Int > If @GMM_ID = '0001' > BEGIN > If @Div_id = '15' or @Div_id = '16' or @Div_id = '17' or @Div_id = > '23' > Set @Total = sum(@Loc120 + @Loc3 ) > Else > Set @Total = sum(@Cheshire) > END > If @GMM_ID = '0002' > BEGIN > Set @Total = sum(@loc15 + @Loc3) > END > If @GMM_ID = '0006' or @GMM_ID = '0007' > BEGIN > Set @Total = sum(@Loc1 + @loc2 +@Cheshire) > END > If @GMM_ID = '0008' > BEGIN > If @Div_id = '99' > Set @Total = sum(@Loc120 + @Loc3 ) > END > If @GMM_ID = '0003' or @GMM_ID = '0005' or @GMM_ID = '0009' or @GMM_ID > = '999' > Begin > Set @Total = sum(@Cheshire) > END > if @GMM_ID is null or @Div_id='00' --Assume if bad data is from > Cheshire > Begin > Set @Total = sum(@Cheshire) > END > > Return(@Total) > End > '----END > > >
В списке pgsql-general по дате отправления: