pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedCan't find which return type is incorrect.
3+ messages / 2 participants
[nested] [flat]
* Can't find which return type is incorrect.
@ 2006-08-11 14:45 Chris Lukenbill <chris@blendinteractive.com>
0 siblings, 1 reply; 3+ messages in thread
From: Chris Lukenbill @ 2006-08-11 14:45 UTC (permalink / raw)
To: pgsql-sql
Alright. I have a very large amount of columns being returned by this
stored procedure that I ported from MS SQL to Postgres. Now the problem I'm
having is that when the select * from sp_whatever(1,0,3) as ( foo int, bar
int, etc.) is executed the error "wrong record type supplied in RETURN NEXT
CONTEXT". Now this immediately red flagged me to look at the types that I
was returning and verify that those were the types that I was catching in
the as statement. I went through to verify all of the variables and they
are all correct as far as both name and the exact type. Therefore there are
only a few things left that I'm thinking could be the problem.
1. Too many variables returned (there are 44 variables being returned).
2. Some of the variables that are smallint in the select statement also do a
if isnull type of logic that will return zero if they are null. (is that
zero not coming back as a smallint then?)
3. What I'm declaring as a variable type in postgresql isn't the variable
type in PHP. The following are the different types of variables that I use:
INT
SMALLINT
BIGINT (when I do a count(*))
VARCHAR(xx)
TEXT
TIMESTAMP
NUMERIC(19,2)
Now the two there that I'm skeptical about are the timestamp and the
numeric.
Thanks ahead of time for any ideas,
Chris
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Can't find which return type is incorrect.
@ 2006-08-11 15:28 codeWarrior <gpatnude@hotmail.com>
parent: Chris Lukenbill <chris@blendinteractive.com>
0 siblings, 1 reply; 3+ messages in thread
From: codeWarrior @ 2006-08-11 15:28 UTC (permalink / raw)
To: pgsql-sql
Can you show us the code for your SP ? I'd like to see what the RETURNS statement is in the sp declaration (CREATE OR REPLACE PROCEDURE sproc(type, type, type) RETURNS SETOF returntype AS ...)
You might reconsider your SELECT * FROM sproc() AS () -- SELECT * retrieves ALL columns defined by the SP....
What happens when you drop the "AS (columns)" portion from your select ??? In other words -- what do you get when you simply "SELECT * FROM sp_whatever(1, 0, 3)" ???
""Chris Lukenbill"" <chris@blendinteractive.com> wrote in message news:fdb4b04c0608110745t6dea55aeod40cf8e19a283dc1@mail.gmail.com...
Alright. I have a very large amount of columns being returned by this stored procedure that I ported from MS SQL to Postgres. Now the problem I'm having is that when the select * from sp_whatever(1,0,3) as ( foo int, bar int, etc.) is executed the error "wrong record type supplied in RETURN NEXT CONTEXT". Now this immediately red flagged me to look at the types that I was returning and verify that those were the types that I was catching in the as statement. I went through to verify all of the variables and they are all correct as far as both name and the exact type. Therefore there are only a few things left that I'm thinking could be the problem.
1. Too many variables returned (there are 44 variables being returned).
2. Some of the variables that are smallint in the select statement also do a if isnull type of logic that will return zero if they are null. (is that zero not coming back as a smallint then?)
3. What I'm declaring as a variable type in postgresql isn't the variable type in PHP. The following are the different types of variables that I use:
INT
SMALLINT
BIGINT (when I do a count(*))
VARCHAR(xx)
TEXT
TIMESTAMP
NUMERIC(19,2)
Now the two there that I'm skeptical about are the timestamp and the numeric.
Thanks ahead of time for any ideas,
Chris
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: Can't find which return type is incorrect.
@ 2006-08-11 15:49 Chris Lukenbill <chris@blendinteractive.com>
parent: codeWarrior <gpatnude@hotmail.com>
0 siblings, 0 replies; 3+ messages in thread
From: Chris Lukenbill @ 2006-08-11 15:49 UTC (permalink / raw)
To: codeWarrior <gpatnude@hotmail.com>; +Cc: pgsql-sql
Let me try this again....My first one got delayed when my gmail defualted to
the wrong account. (the response is inside codeWarrior's message.
Thanks,
Chris
On 8/11/06, Chris Lukenbill <chris.lukenbill@gmail.com> wrote:
>
>
>
> On 8/11/06, codeWarrior <gpatnude@hotmail.com> wrote:
> >
> > Can you show us the code for your SP ? I'd like to see what the RETURNS
> > statement is in the sp declaration (CREATE OR REPLACE PROCEDURE sproc(type,
> > type, type) RETURNS SETOF returntype AS ...)
> >
>
> Here is the SP
>
> CREATE OR REPLACE FUNCTION sp_content_tree (p_folder int, p_current int,
> p_maxrows int) RETURNS SETOF RECORD as $$
>
> DECLARE
> returnRecord RECORD;
> .
> .
> .
> FOR returnRecord IN SELECT
> pseudo_temp_out_simple.levelnum,view_content.*,pseudo_temp_out_simple.children
>
> FROM pseudo_temp_out_simple
> INNER JOIN view_content ON itemID=item
> ORDER BY
> pseudo_temp_out_simple.displayorder,view_content.createdate
> LOOP
> RETURN NEXT returnRecord;
> END LOOP;
>
>
>
> RETURN;
> END;
> $$ LANGUAGE plpgsql;
>
>
> You might reconsider your SELECT * FROM sproc() AS () -- SELECT *
> > retrieves ALL columns defined by the SP....
> >
>
> I'm looking into that currently..
>
>
> What happens when you drop the "AS (columns)" portion from your select ???
> > In other words -- what do you get when you simply "SELECT * FROM
> > sp_whatever(1, 0, 3)" ???
> >
>
> I get the..."a column definition list is required for functions returning
> "record" in"...error.
>
> ""Chris Lukenbill"" <chris@blendinteractive.com> wrote in message news:fdb4b04c0608110745t6dea55aeod40cf8e19a283dc1@mail.gmail.com
> > ...
> >
> > Alright. I have a very large amount of columns being returned by this
> > stored procedure that I ported from MS SQL to Postgres. Now the problem I'm
> > having is that when the select * from sp_whatever(1,0,3) as ( foo int, bar
> > int, etc.) is executed the error "wrong record type supplied in RETURN NEXT
> > CONTEXT". Now this immediately red flagged me to look at the types that I
> > was returning and verify that those were the types that I was catching in
> > the as statement. I went through to verify all of the variables and they
> > are all correct as far as both name and the exact type. Therefore there are
> > only a few things left that I'm thinking could be the problem.
> >
> > 1. Too many variables returned (there are 44 variables being returned).
> > 2. Some of the variables that are smallint in the select statement also
> > do a if isnull type of logic that will return zero if they are null. (is
> > that zero not coming back as a smallint then?)
> > 3. What I'm declaring as a variable type in postgresql isn't the
> > variable type in PHP. The following are the different types of variables
> > that I use:
> > INT
> > SMALLINT
> > BIGINT (when I do a count(*))
> > VARCHAR(xx)
> > TEXT
> > TIMESTAMP
> > NUMERIC(19,2)
> >
> >
> > Now the two there that I'm skeptical about are the timestamp and the
> > numeric.
> >
> > Thanks ahead of time for any ideas,
> > Chris
> >
> >
>
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2006-08-11 15:49 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-11 14:45 Can't find which return type is incorrect. Chris Lukenbill <chris@blendinteractive.com>
2006-08-11 15:28 ` codeWarrior <gpatnude@hotmail.com>
2006-08-11 15:49 ` Chris Lukenbill <chris@blendinteractive.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox