Re: ESQL/C question
Posted in 2011
On Fri, Sep 16, 2011 at 09:16, Link, David A <DALink@west.com> wrote:
> Version Info****
>
> ** **
>
> Currently installed version: 3.50.UC8 – AIX 5.3****
>
> Hitting IBM Informix Dynamic Server Version 11.50.FC9 - AIX 5.3****
>
> ** **
>
> I have a stored procedure:****
>
> ** **
>
> CREATE PROCEDURE test_sp(PorderNum INT, PbatchID CHAR(20)) …****>
> ** **
>
> We are attempting to use get descriptor to get the input parameters of the
> prepare statement:****
>
> ** **
>
> [...sequence of prepare and describe fixed...]
>
> EXEC SQL allocate descriptor 'stmt_params_in' with max 50;****
>
> EXEC SQL prepare :hv_stmt_alias from "execute procedure test_sp(?,?)";****
>
> EXEC SQL describe input :hv_stmt_alias using sql descriptor
> 'stmt_params_in';
>
> …****
>
> ** **
>
> hv_index = 1;****
>
> EXEC SQL get descriptor 'stmt_params_in' VALUE :hv_index :hv_type = TYPE,
> :hv_length = LENGTH, :hv_indicator = INDICATOR;****
>
> TRACE_LOG(TL_LEVEL1)("query_informix_statement: hv_index=%d hv_type=%d
> hv_length(%d)", hv_index, hv_type, hv_length);****
>
> ** **
>
> hv_index = 2;****
>
> EXEC SQL get descriptor 'stmt_params_in' VALUE :hv_index :hv_type =
> TYPE, :hv_length = LENGTH, :hv_indicator = INDICATOR;****
>
> TRACE_LOG(TL_LEVEL1)("query_informix_statement: hv_index=%d hv_type=%d
> hv_length(%d)", hv_index, hv_type, hv_length);****
>
> ** **
>
> The trace logs the following:****
>
> ** **
>
> 20110916120919139143 0,0,0 0,0,1,1 0.000000 query_informix_statement:
> hv_index=1 hv_type=2 hv_length(4)****
>
> 20110916120919139164 0,0,0 0,0,1,1 0.000000 query_informix_statement:
> hv_index=2 hv_type=0 hv_length(0)****
>
> ** **
>
> We are trying to figure out why the second argument is giving us a length
> of 0 as opposed to 20. ****
>
> ** **
>
> It should give us 20, correct? We have done this for standard SQL
> statements before just fine but this is the first time we have tried it with
> a store procedure.****
>
I don't see that there is anything you are doing wrong, so the problem is
likely in the server. Your expectation is reasonable; there is no obvious
reason why the description should not indicate the length 20. Of course,
Informix being the cooperative DBMS it is, it will accept character strings
of lengths longer (and shorter) than 20 and truncate or pad appropriately,
but it should still tell you the expected/usable length.
I suggest taking a simple reproduction (not much more complex than what
you've shown) to IBM Tech Support.
--
Jonathan Leffler <jonathan.leffler@gmail.com> #include <disclaimer.h>
Guardian of DBD::Informix - v2011.0612 - http://dbi.perl.org
"Blessed are we who can laugh at ourselves, for we shall never cease to be
amused."