pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
RE : Record unassigned yet
3+ messages / 2 participants
[nested] [flat]

* RE : Record unassigned yet
@ 2004-10-01 11:28 Johann Robette <jrobette@onyme.com>
  2004-10-01 11:45 ` Re: RE : Record unassigned yet Richard Huxton <dev@archonet.com>
  0 siblings, 1 reply; 3+ messages in thread

From: Johann Robette @ 2004-10-01 11:28 UTC (permalink / raw)
  To: 'Russell Smith' <mr-russ@pws.com.au>; pgsql-hackers@postgresql.org

Oh sorry about that!
No, I was alright in the syntax. Both are defined as current.
I can't find where the problem lies...


-----Message d'origine-----
De : pgsql-hackers-owner@postgresql.org
[mailto:pgsql-hackers-owner@postgresql.org] De la part de Russell Smith
Envoyé : vendredi 1 octobre 2004 13:20
À : pgsql-hackers@postgresql.org
Objet : Re: [HACKERS] Record unassigned yet

On Fri, 1 Oct 2004 07:24 pm, Johann Robette wrote:
> Hello,
> 
> I'm experiencing a strange problem. Here it is :
> I've created a function with a FOR loop.
> 
> DECLARE
> Current RECORD;
> BEGIN
> FOR current IN SELECT * FROM employees LOOP
>   Tmp := current.id;
> END LOOP;
> ...
current != Current ?

> 
> When I call the function, I get the error :
>  ERROR:  record " current " is unassigned yet
> 
> Any idea?
> 
> 
> 
> ---------------------------(end of
broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
> 
>                http://www.postgresql.org/docs/faqs/FAQ.html
> 
> 

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if
your
      joining column's datatypes do not match






^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: RE : Record unassigned yet
  2004-10-01 11:28 RE : Record unassigned yet Johann Robette <jrobette@onyme.com>
@ 2004-10-01 11:45 ` Richard Huxton <dev@archonet.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Richard Huxton @ 2004-10-01 11:45 UTC (permalink / raw)
  To: Johann Robette <jrobette@onyme.com>; +Cc: Russell Smith <mr-russ@pws.com.au>; pgsql-hackers@postgresql.org

Johann Robette wrote:
> Oh sorry about that!
> No, I was alright in the syntax. Both are defined as current.
> I can't find where the problem lies...

The following works fine for me.

=== BEGIN test ===
DROP TABLE employees;

CREATE TABLE employees (id integer, name text);
COPY employees FROM stdin;
1   Aaron Aardvark
2   Betty Bee
3   Carl Cat
\.

CREATE OR REPLACE FUNCTION emp_test_fn() RETURNS boolean AS '
DECLARE
     current RECORD;
     Tmp     integer;
BEGIN
     FOR current IN SELECT * FROM employees LOOP
         Tmp := current.id;
         RAISE NOTICE ''tmp = %'', Tmp;
     END LOOP;
     RETURN true;
END
'
LANGUAGE 'plpgsql';

SELECT emp_test_fn();
=== END test ===

PS - please reply to the -general list not -hackers.

-- 
   Richard Huxton
   Archonet Ltd



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* RE : Record unassigned yet
@ 2004-10-01 14:51 Johann Robette <jrobette@onyme.com>
  0 siblings, 0 replies; 3+ messages in thread

From: Johann Robette @ 2004-10-01 14:51 UTC (permalink / raw)
  To: 'Tom Lane' <tgl@sss.pgh.pa.us>; +Cc: pgsql-hackers@postgresql.org

Thanks for your answer.
In fact, I had a syntax error in my function.
Sorry about that!

-----Message d'origine-----
De : Tom Lane [mailto:tgl@sss.pgh.pa.us] 
Envoyé : vendredi 1 octobre 2004 16:47
À : Johann Robette
Cc : pgsql-hackers@postgresql.org
Objet : Re: [HACKERS] Record unassigned yet 

"Johann Robette" <jrobette@onyme.com> writes:
> I've created a function with a FOR loop.

> DECLARE
> Current RECORD;
> BEGIN
> FOR current IN SELECT * FROM employees LOOP
> 		Tmp := current.id;
> END LOOP;
> ...

> When I call the function, I get the error :
> 	ERROR:  record " current " is unassigned yet

> Any idea?

What you showed us looks fine, therefore the problem is in something you
didn't show us.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2004-10-01 14:51 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2004-10-01 11:28 RE : Record unassigned yet Johann Robette <jrobette@onyme.com>
2004-10-01 11:45 ` Richard Huxton <dev@archonet.com>
2004-10-01 14:51 RE : Record unassigned yet Johann Robette <jrobette@onyme.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