Обсуждение: problem with my function

Поиск
Список
Период
Сортировка

problem with my function

От
"Johnson, Shaunn"
Дата:

Okay:

I must be missing something vital; I thought my function
was working properly the other day, but now I can't
seem to figure out how I broke it.

[snip code]

drop function t_fastfunc(integer);
create function t_fastfunc(integer)
returns interger
as '
declare nCnt integer;
begin
        select count (*) into nCnt
        from t_stage_member;
        if nCnt < 1500000 then
        RAISE EXCEPTION ''Number of records is more than 1.5M'';
        return nCnt;
        end if;
end;
' language 'plpgsql';

[/snip code]

When I try to create it, I get the following error:

[error]

DROP
psql:./function_cnt.sql:18: NOTICE:  ProcedureCreate: return type 'interger' is only a shell
CREATE

[/error]

Question: What exactly is it tryiing to tell me about not returning a value?
And could someone explain what it means by 'only a shell'?

Thanks!

-X

Re: problem with my function

От
Darren Ferguson
Дата:
It is a spelling mistake you are trying to return an interger instead of
an integer.

Also should the line with the IF statement not read

IF nCnt > 1500000 THEN
  RAISE EXCEPTION

??

HTH

Darren

Darren Ferguson

On Fri, 24 May 2002, Johnson, Shaunn wrote:

> Okay:
>
> I must be missing something vital; I thought my function
> was working properly the other day, but now I can't
> seem to figure out how I broke it.
>
> [snip code]
>
>
> drop function t_fastfunc(integer);
> create function t_fastfunc(integer)
> returns interger
> as '
> declare nCnt integer;
> begin
>         select count (*) into nCnt
>         from t_stage_member;
>         if nCnt < 1500000 then
>         RAISE EXCEPTION ''Number of records is more than 1.5M'';
>         return nCnt;
>         end if;
> end;
> ' language 'plpgsql';
>
> [/snip code]
>
> When I try to create it, I get the following error:
>
> [error]
>
> DROP
> psql:./function_cnt.sql:18: NOTICE:  ProcedureCreate: return type 'interger'
> is only a shell
> CREATE
>
>
> [/error]
>
> Question: What exactly is it tryiing to tell me about not returning a value?
> And could someone explain what it means by 'only a shell'?
>
> Thanks!
>
> -X
>


Re: problem with my function

От
Tom Lane
Дата:
"Johnson, Shaunn" <SJohnson6@bcbsm.com> writes:
> drop function t_fastfunc(integer);
> create function t_fastfunc(integer)
> returns interger

Try spelling "integer" correctly.

> psql:./function_cnt.sql:18: NOTICE:  ProcedureCreate: return type 'interger'
> is only a shell
> Question: What exactly is it tryiing to tell me about not returning a value?
> And could someone explain what it means by 'only a shell'?

It's trying to warn you that you are getting into deep waters.  When you
create a function that's declared to return a previously-unheard-of type
name, the system will take it, on the possibility that you are trying to
create the input function for a type you are about to declare.  So
there's an entry made in pg_type ... but it's only a "shell" not a
completed type, and you can't do anything else with it until you declare
the type properly.

            regards, tom lane

Re: problem with my function

От
"Johnson, Shaunn"
Дата:

--*sheepishly*

--yeah ... Darren already told me to clean out
my eye sockets regarding that ... i swear i'm going
to set VI to use ispell each and every time
i do stunts like this ...

-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]

> drop function t_fastfunc(integer);
> create function t_fastfunc(integer)
> returns interger

Try spelling "integer" correctly.

> psql:./function_cnt.sql:18: NOTICE:  ProcedureCreate: return type 'interger'
> is only a shell
> Question: What exactly is it tryiing to tell me about not returning a value?
> And could someone explain what it means by 'only a shell'?

--ah!  now THAT is an explanation! 

--thanks folks!

-X

It's trying to warn you that you are getting into deep waters.  When you
create a function that's declared to return a previously-unheard-of type
name, the system will take it, on the possibility that you are trying to
create the input function for a type you are about to declare.  So
there's an entry made in pg_type ... but it's only a "shell" not a
completed type, and you can't do anything else with it until you declare
the type properly.

                        regards, tom lane