C Language Stored Procedure Returning No Data
От | bfraci@aol.com |
---|---|
Тема | C Language Stored Procedure Returning No Data |
Дата | |
Msg-id | 8C7F56FF6FA1531-13B0-2A40@FWM-D45.sysops.aol.com обсуждение исходный текст |
Ответы |
Re: C Language Stored Procedure Returning No Data
|
Список | pgsql-general |
We have a Java client that is using JDBC to communicate with the Postgres database. We have a stored procedure, foo, that is written in C which returns a byte array (bytea) to the Java client. This function takes in a couple of integers and based upon their values can return a byte array or no data. From a C stored procedure, how can I tell Postgres to pass on to the Java client that there is No Data? A zero length byte array or a null value is not the same as No Data.
Thanks for any help that you can give.
The stored procedure is defined as:
CREATE OR REPLACE FUNCTION foo(int8, int8)
RETURNS bytea AS 'foolib.so', 'foo'
LANGUAGE C STRICT;
The C function foo looks like:
PG_FUNCTION_INFO_V1(foo);
Datum foo ( PG_FUNCTION_ARGS)
{
int64 int1 = PG_GETARG_INT64(0);
int64 int2 = PG_GETARG_INT64(1);
bytea *data = NULL;
if ( int1 > 12345 ) {
/* Somehow indicate that there is no data */
/* Doing the following does not tell Java that there is no data; it gets a null value */
PG_RETURN_NULL();
}
/* Some processing */
PG_RETURN_BYTEA_P( data );
}
В списке pgsql-general по дате отправления: