# Database Discussions > Sybase >  Extended Stored Procedure/Open Server

## hanskramer

Hi,

I am trying to write an extended store procedure that returns its data via an output parameter, similar to what one can do with regular stored procedures.
However, I've had no luck with it. Perhaps somebody with a better understand of the Sybase internals can help me out. I have tried tried virtually every combination of arguments... sigh.. it seems it ain't possible (wish ASE
was open source) but I cannot believe that (I am using ASE 12.5.3) help!!! ;-)

Anyway, I get stuck with the first call to srv_descfmt. The server replies: "XP Server Error: 16165/10/0: srv_descfmt(): CS_SET for SRV_RPCDATA not valid"

Here an excerpt of my code:
First I created a procedure called xp_test in ASE:

create procedure xp_test @param INTEGER OUTPUT AS external name "test.so"

I test this with the following SQL code:
declare @output integer 
select @output=1 
exec xp_test @output OUTPUT 
select @output

Part of my ESP code:

    CS_DATAFMT  paramfmt;
    memset(&paramfmt, (CS_INT) 0, (CS_INT) sizeof(CS_DATAFMT));

    CS_INT data = 23;

    paramfmt.namelen   = 0;
    paramfmt.datatype  = CS_INT_TYPE;
    paramfmt.format    = 0;
    paramfmt.maxlength = 4;
    paramfmt.count     = 1;
    paramfmt.locale    = NULL;
    paramfmt.status    = CS_RETURN;

    srv_descfmt(srvproc, CS_SET, SRV_RPCDATA, 1, &paramfmt);

    CS_INT      len = sizeof(CS_INT);
    CS_SMALLINT outlen = CS_GOODDATA;

srv_bind(srvproc, roc, CS_SET, SRV_RPCDATA, q, &paramfmt, (CS_BYTE *) &data,
&len, &outlen);

    srv_xferdata(srvproc, CS_SET, SRV_RPCDATA)

Thanks

----------

