Anyone ever do this successfully? (PB 2022 R3)
In the postgres database I have defined this FUNCTION
CREATE OR REPLACE FUNCTION public.rpc_ordersbycustomer(
custid integer DEFAULT 0,
INOUT order_count integer DEFAULT 0)
RETURNS integer
LANGUAGE 'plpgsql'
COST 100
VOLATILE PARALLEL UNSAFE
AS $BODY$
begin
select count(*)
into order_count
from dbo.order
where customerid = custid;
end;
$BODY$;
ALTER FUNCTION public.rpc_ordersbycustomer(integer, integer)
OWNER TO postgres;
Which takes a customer id and returns the number of orders for them.
On my Transaction object I have this:
FUNCTION long rpc_ordersbycustomer(long custid, ref long order_count) RPCFUNC;
And I try to use it in some code in my application:
long ll_orders, ll_custid, ll
string ls
IF row > 0 THEN
TRY
ll_custid = this.getitemnumber(row,'customerid')
ll = SQLCA.rpc_ordersbycustomer(ll_custid,ll_orders)
IF SQLCA.Sqlcode <> 0 THEN
MessageBox('RPC Error', SQLCA.sqlerrtext)
END IF
st_ordercount.text = 'CustID: ' + string(ll_custid) + ' Orders: ' + string(ll_orders)
CATCH (runtimeerror er)
MessageBox('RPC Error', 'Runtime error.~r~n' + er.GetMessage())
END TRY
END IF
In all cases the number of orders (ll_orders in the above code) always returns 0. The return from the call ('ll' in the example) is also 0.
Ideas?