dbTalk Databases Forums  

Re: [BUGS] a bug in plpgsql

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] a bug in plpgsql in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] a bug in plpgsql - 11-04-2004 , 01:50 PM






Jaime Casanova <systemguards (AT) yahoo (DOT) com> writes:
Quote:
CASE rs_dtran.fpg_codigo
WHEN ''EF'' THEN
IF rs_ttran.tra_tipo = ''+'' THEN
valor_ef := valor_ef + rs_dtran.dtr_valor;
ELSE
valor_ef := valor_ef - rs_dtran.dtr_valor;
END IF;
WHEN ''CH'' THEN
IF rs_ttran.tra_tipo = ''+'' THEN
valor_ch := valor_ch + rs_dtran.dtr_valor;
ELSE
valor_ch := valor_ch - rs_dtran.dtr_valor;
END IF;
END;

but in that line there is a valid IF .. THEN .. ELSE
block.
if/then/else is a statement, not a component of an expression.
CASE is an expression construct, not a statement. I think
you need to rewrite the CASE as an if/then/elsif statement.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Jaime Casanova
 
Posts: n/a

Default Re: [BUGS] a bug in plpgsql - 11-04-2004 , 01:57 PM






--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
Quote:
Jaime Casanova <systemguards (AT) yahoo (DOT) com> writes:
CASE rs_dtran.fpg_codigo
WHEN ''EF'' THEN
IF rs_ttran.tra_tipo = ''+'' THEN
valor_ef := valor_ef + rs_dtran.dtr_valor;
ELSE
valor_ef := valor_ef - rs_dtran.dtr_valor;
END IF;
WHEN ''CH'' THEN
IF rs_ttran.tra_tipo = ''+'' THEN
valor_ch := valor_ch + rs_dtran.dtr_valor;
ELSE
valor_ch := valor_ch - rs_dtran.dtr_valor;
END IF;
END;

but in that line there is a valid IF .. THEN ..
ELSE
block.

if/then/else is a statement, not a component of an
expression.
CASE is an expression construct, not a statement. I
think
you need to rewrite the CASE as an if/then/elsif
statement.

regards, tom lane

I will try but this work in v7.4.2 that's why i think
is an error.

regards,
Jaime Casanova

__________________________________________________ _______
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #3  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] a bug in plpgsql - 11-04-2004 , 02:06 PM



Jaime Casanova <systemguards (AT) yahoo (DOT) com> writes:
Quote:
--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
if/then/else is a statement, not a component of an
expression.
CASE is an expression construct, not a statement. I
think
you need to rewrite the CASE as an if/then/elsif
statement.

I will try but this work in v7.4.2 that's why i think
is an error.
It most certainly did not work in 7.4.2, or any other PG release.
plpgsql doesn't have a CASE statement.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html


Reply With Quote
  #4  
Old   
Jaime Casanova
 
Posts: n/a

Default Re: [BUGS] a bug in plpgsql - 11-04-2004 , 02:08 PM



--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
Quote:
Jaime Casanova <systemguards (AT) yahoo (DOT) com> writes:
--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
if/then/else is a statement, not a component of
an
expression.
CASE is an expression construct, not a statement.
I
think
you need to rewrite the CASE as an if/then/elsif
statement.

I will try but this work in v7.4.2 that's why i
think
is an error.

It most certainly did not work in 7.4.2, or any
other PG release.
plpgsql doesn't have a CASE statement.

regards, tom lane


This is a production server... and the same script...
(It was an error in v7.4.2 to permit this?)

[postgres@nautilus bin]$ ./psql uescc
Welcome to psql 7.4.2, the PostgreSQL interactive
terminal.

Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit

uescc=# \i func.sql
BEGIN
DROP FUNCTION
CREATE FUNCTION
ROLLBACK
uescc=#


regards,
Jaime Casanova

__________________________________________________ _______
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #5  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] a bug in plpgsql - 11-04-2004 , 02:36 PM



Jaime Casanova <systemguards (AT) yahoo (DOT) com> writes:
Quote:
--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
It most certainly did not work in 7.4.2, or any
other PG release.
plpgsql doesn't have a CASE statement.

This is a production server... and the same script...
(It was an error in v7.4.2 to permit this?)
Are you sure the function has ever been executed? 7.4 gives me

regression=# select recaudaciones.rec_f_aperturarcaja(1::int2,2::int2) ;
ERROR: syntax error at or near "ELSE"
CONTEXT: compile of PL/pgSQL function "rec_f_aperturarcaja" near line 51

8.0 is just reporting the error when the function is defined instead
of at first call.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo (AT) postgresql (DOT) org so that your
message can get through to the mailing list cleanly


Reply With Quote
  #6  
Old   
Jaime Casanova
 
Posts: n/a

Default Re: [BUGS] a bug in plpgsql - 11-04-2004 , 02:52 PM



--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
Quote:
Jaime Casanova <systemguards (AT) yahoo (DOT) com> writes:
--- Tom Lane <tgl (AT) sss (DOT) pgh.pa.us> escribió:
It most certainly did not work in 7.4.2, or any
other PG release.
plpgsql doesn't have a CASE statement.

This is a production server... and the same
script...
(It was an error in v7.4.2 to permit this?)

Are you sure the function has ever been executed?
7.4 gives me

regression=# select
recaudaciones.rec_f_aperturarcaja(1::int2,2::int2) ;
ERROR: syntax error at or near "ELSE"
CONTEXT: compile of PL/pgSQL function
"rec_f_aperturarcaja" near line 51

8.0 is just reporting the error when the function is
defined instead
of at first call.

Ok, you are right. I was sure i have ran this but
maybe i ran one older.

sorry for the trouble.

regards,
Jaime Casanova

__________________________________________________ _______
Do You Yahoo!?
Información de Estados Unidos y América Latina, en Yahoo! Noticias.
Visítanos en http://noticias.espanol.yahoo.com

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.