Question about functions

From: Michael Meskes <meskes(at)postgresql(dot)org>
To: PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Question about functions
Date: 2000-01-27 14:55:17
Message-ID: 20000127155517.A2367@fam-meskes.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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(at)Fam-Meskes(dot)De | Use PostgreSQL!

Browse pgsql-hackers by date

  From Date Subject
Next Message Hiroshi Inoue 2000-01-27 15:38:20 RE: [HACKERS] Sure enough, SI buffer overrun is broken
Previous Message Patrick Welche 2000-01-27 13:13:34 Re: [HACKERS] (libpq) Anyone still having problems with COPY?