Hi,

I am trying to use some esql/c to run a stored procedure which should return 2 output parameters. I have tested the stored proc in Query analyser and it works fine however when I run the esql/c code I get a -179 error which apparantly indicates that I am trying to send constants to the stored proc when using the Output param which is illegal! As I have not declared any of the varaibles as constants I have no idea why I am getting this error, can anyone help?

The stored proc is defined as:

CREATE PROCEDURE p_stl_esqltest
@input_int INT ,
@input_char VARCHAR(255) OUTPUT ,
@rc INT OUTPUT,
@error_desc VARCHAR(255) OUTPUT
AS
BEGIN

set @rc = @input_int * 10
set @error_desc = 'Heres your input char:' + @input_char
insert into temp (dd,inint,outint,instr,outstr) values (getdate(),@input_int,@rc,@input_char,@error_desc)
END
GO


If I run it through query analyser it works fine:

/* sql run thro query analyser - and works
declare @input_int INT
declare @input_char VARCHAR(255)
declare @rc INT
declare @error_desc VARCHAR(255)

select @input_int=10
select @input_char='MyInput'

exec p_stl_esqltest @input_int, @input_char, @rc output, @error_desc output
print @input_int
print @input_char
print @rc
print @error_desc


However as soon as I uses embedded sql to run the stored procedure it doesn't run:

int dotemp()
{
exec sql begin declare section;
int iin=10;
int iout=0;
int iout2=0;
char szIn[256]="MyInString:";
char szOut[256];
int iret = 0;
exec sql end declare section;

EXEC SQL exec p_stl_esqltest :iin, :szIn, :iout output, :szOut output;

iret = sqlca.sqlcode;
DBSWITCH_COMMIT
return iret;
}


Have tried all these in the place of the EXEC SQL in the esql/c but to no avail:

/* do not work */
EXEC SQL EXEC p_stl_esqltest :iin, :szIn, :iout, :szOut into iout2;
EXEC SQL select exec p_stl_esqltest :iin, :szIn, :iout, :szOut into iout2;
EXEC SQL exec p_stl_esqltest :iin, :szIn, output :iout,output :szOut;
EXEC SQL EXEC p_stl_esqltest :iin, :szIn, :iout output, :szOut output;


/* works but out values not returned */
EXEC SQL exec p_stl_esqltest :iin, :szIn, :iout, :szOut;