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 = "">
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 );
}
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
- Follow-Ups:
- Re: C Language Stored Procedure Returning No Data
- From: Michael Fuhr
- Re: C Language Stored Procedure Returning No Data
- Prev by Date: Re: Gotcha's in copying data between servers via file copy
- Next by Date: Re: pg 8.1.2 ERROR: direct correlated subquery unsupported as initplan
- Previous by thread: Gotcha's in copying data between servers via file copy
- Next by thread: Re: C Language Stored Procedure Returning No Data
- Index(es):