I was send an example for a function definition created with ecpg:

EXEC SQL INCLUDE sqlca;

int my_fun (void)
	{
	EXEC SQL BEGIN DECLARE SECTION;
	int			sql_index = 0;
	EXEC SQL END DECLARE SECTION;	

	EXEC SQL WHENEVER SQLERROR GOTO Error;
	EXEC SQL SELECT MIN(index) INTO :sql_index FROM tab;

	return (sql_index);

Error:
	return (sqlca.sqlcode);	
	}

I have never tried this so I wonder if this is possible. Any comments?

Anyway it does not seem to work as it should. I did create a mini table to
test it:

mm=> select * from tab;
index
-----
   14
    7
(2 rows)
mm=> select my_fun();
my_fun
------
  -220
(1 row)

Now -220 certainly is not the minimum of 14 and 7. So what did I do wrong
here?

Michael
-- 
Michael Meskes                         | Go SF 49ers!
Th.-Heuss-Str. 61, D-41812 Erkelenz    | Go Rhein Fire!
Tel.: (+49) 2431/72651                 | Use Debian GNU/Linux!
Email: Michael@Fam-Meskes.De           | Use PostgreSQL!

Thu, 27 Jan 2000 15:55:17 +0100
Michael Meskes <meskes@postgresql.org>
Question about functions