1. Pepe Cuenca
  2. PowerBuilder
  3. Wednesday, 28 April 2021 07:27 AM UTC

Good Morning Everyone, 

I'm having an strange issue while testing an application which connects to an Informix Database.

The thing is that it connects ok, but when I execute an SQL command:

 

select sum(importe) into :lc_importe_menos
from ftransf
where cenbanc = :is_cenbanc
and csubanc = :is_csubanc
and ncuenta = :is_ncuenta
and clvdeha = '1'
and foper <= :id_fecha
and foper >= :id_fec_saldo_ini
using itr_sqlca;

 

If I run the application, it works good, but if I debug it, the transaction dbcode is -1206 and the sqlerrtext is "SQL Error -1206 : Invalid day in date".

Why, if the code is the same, acts different running and debugging?

Is there any way to solve this?

 

Thank you very much! 

Benjamin Gaesslein Accepted Answer Pending Moderation
  1. Wednesday, 28 April 2021 13:50 PM UTC
  2. PowerBuilder
  3. # 1

Hi Pepe,

I'm guessing id_fecha and id_fec_saldo_ini are date values? Looks like the date format gets bungled in the process, probably switching the day and month values. In my experience, directly feeding date variables into embedded sql is a gamble at best because it's hard to be sure that the format gets converted correctly.

Try converting the Powerbuilder date variables into a string and re-converting that string into a date using the to_date function of your database. Something like this:

string ls_fecha

string ls_fec_saldo_ini

ls_fecha = string(id_fecha, 'dd-mm-yyyy')
ls_fec_saldo_ini = string(id_fec_saldo_ini , 'dd-mm-yyyy')

select sum(importe) into :lc_importe_menos
from ftransf
where cenbanc = :is_cenbanc
and csubanc = :is_csubanc
and ncuenta = :is_ncuenta
and clvdeha = '1'
and foper <= to_date(:ls_fecha, 'dd-mm-yyyy')
and foper >=  to_date(:ls_fec_saldo_ini, 'dd-mm-yyyy')
using itr_sqlca;

Not sure if the to_date syntax is correct for informix but there should be something similar.

 

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.