Search Postgresql Archives

C Language Stored Procedure Returning No Data

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
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]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux