Обсуждение: Function return type does not match
Hi I modified my function to:
CREATE FUNCTION buscablista (character varying, character varying) RETURNS
SETOF cabezalista
AS '
select * from cabezalista where idlista like CAST($1 AS CHAR(20)) and
idlibro like CAST($2 AS CHAR(6));
' LANGUAGE sql;
But when called it gives me the error:
ERROR: Query-specified return tuple and actual function return tuple do not
match
ERROR: Query-specified return tuple and actual function return tuple do not
match
As i see it, the return types are the same (cabezalista) whic is a table in
my database... I think something went wrong when i dropped and re created
the table in order to add a column and do some other minor changes (like
changing char(6) to char (7) in some columns)
Thanks a lot
JuanF
Juan Francisco Diaz wrote:
> Hi I modified my function to:
>
> CREATE FUNCTION buscablista (character varying, character varying) RETURNS
> SETOF cabezalista
> AS '
>
> select * from cabezalista where idlista like CAST($1 AS CHAR(20)) and
> idlibro like CAST($2 AS CHAR(6));
>
> ' LANGUAGE sql;
>
> But when called it gives me the error:
>
> ERROR: Query-specified return tuple and actual function return tuple do not
> match
> ERROR: Query-specified return tuple and actual function return tuple do not
> match
I guess that you are calling the function like is a function:
select buscablista('foo', 'bar');
the function is a Table Function so :
select * from buscablista('foo', 'bar');
Regards
Gaetano Mendola
On Thursday, September 25, 2003, at 11:55 AM, Juan Francisco Diaz wrote: > As i see it, the return types are the same (cabezalista) whic is a > table in > my database... I think something went wrong when i dropped and re > created > the table in order to add a column and do some other minor changes > (like > changing char(6) to char (7) in some columns) Because of how functions caches database information, dropping the table and/or columns results in an error. You just need to re-create the function in question and all should be fine. -heath
Thanks heat for your help but I did that and it still ives me the same error... I restarted the srver and the computer and nothing seems to work... Do you know any other reason for this to happen? Thanks a lot JuanF El 9/25/03 12:55 PM, "Heath Tanner" <heath@inligo.com> escribió: > On Thursday, September 25, 2003, at 11:55 AM, Juan Francisco Diaz > wrote: > >> As i see it, the return types are the same (cabezalista) whic is a >> table in >> my database... I think something went wrong when i dropped and re >> created >> the table in order to add a column and do some other minor changes >> (like >> changing char(6) to char (7) in some columns) > > Because of how functions caches database information, dropping the > table and/or columns results in an error. > > You just need to re-create the function in question and all should be > fine. > > -heath >
On Thursday, September 25, 2003, at 03:09 PM, Juan Francisco Diaz wrote: > I restarted the srver and the computer and nothing seems to work... > > Do you know any other reason for this to happen? Generally, when asking for assistance, you'll want to provide more details. In this instance, for example, you should provide: 1) the version of Postgres you're working with. (You can type "select version();" to find out if you're not sure.) 2) a copy of the entire function in question (or relevant parts of it's a lengthy function and only one part of it is causing problems 3) the exact SQL statement that triggered the error or unexpected result (e.g. "select my_function() from my_table;") 4) the resulting error message or unexpected results. (If it's an error, you should copy and paste the entire error message.) From what you've provided in your previous email, I have no idea what is causing the error, but with a little more detail I'm sure someone will be able to help you. -heath