Re: variables in declare statement
Posted in 1999
Austin Castro wrote:
> I have a problem with a 4gl program. The program is receiving two
> arguments, a beginning date and an end date . The following declaring
> statement fails on the attempt to open.
>
> Let bobp = arg_val(1)
> Let eobp = arg_val(2)
>
> Declare acct_cur cursor for
> Select account_number from customer_account
> Where (close_date between eobp and eobp)
> Order by account_number>
> I get error -217 when openning the cursor. When I hard code the
> dates, I don't get any error. I know that I can work around this
> by preparing the statement in a string but I want to know why I'm
> getting this error.
IIRC, -217 is 'column not found' or words to that effect. I note
that your BETWEEN clause as written mentions eobp twice and does not
mention bobp at all. I'd debug the problem by checking on the
string that's in the generated C code if you're using the c-code
compiler, or in the object file if you're using the p-code compiler.
The usual cause of the trouble is that something you expected to be
treated as a variable isn't -- is eobp in scope when the cursor is
declared? Does the customer_account table have both an account_number
column and a close_date column?
Contrary to what 'thillick@cscsi.com' said, you can have DATE
variables used in a SELECT statement without using PREPARE, and
you do not need to protect the values with quotes in this context.
--
Jonathan Leffler (jleffler@informix.com, jleffler@earthlink.net)
Guardian of DBD::Informix v0.60 -- see http://www.perl.com/CPAN
#include <disclaimer.h>