SqlOraPLSQLPrepare round bug 4.2, 5.1, 5.2

Post found bugs and possible workarounds.
erasmo
Brazil
Posts: 21
Joined: 21 Mar 2017, 13:17
Location: Campinas/SP - Brazil

SqlOraPLSQLPrepare round bug 4.2, 5.1, 5.2

Post by erasmo » 27 Jun 2012, 15:22

Hello,

The code below shows an error, rounding the result:

Code: Select all

!!CB!! 174
If SqlOraPLSQLPrepare( hSql, '
      begin
        :n2 := 0.000000899;
      end;' )
   If SqlOraPLSQLExecute( hSql )
      Call SalMessageBox( SalNumberToStrX( n2, 10 ), '', 0)
The return value is 0.000001 and was rounded incorrectly.

The same code with SqlPrepareAndExecute operate normally, the result is correct 0.000000899:

Code: Select all

!!CB!! 174
If SqlPrepareAndExecute( hSql,  'select 0.000000899 from dual into :n2 ' )
   If SqlFetchNext( hSql, n1 )
      Call SalMessageBox( SalNumberToStrX( n2, 10 ), '', 0 )
SqlPrepareAndExecute operating normally with 40 decimal places, SqlOraPLSQLPrepare/Execute is limited to the sixth decimal place.

Thanks
Erasmo

Jeff Luther

SqlOraPLSQLPrepare round bug 4.2, 5.1, 5.2

Post by Jeff Luther » 27 Jun 2012, 16:49

Well, I see that this same limit goes back to running in TD 4.2 and 5.2 as well. I'm asking internally, but looks like (currently at least) this is the limit of SqlOraPLSQLXXX, so it's not a bug. I'll update here if/when I hear more.


Later... I did hear back from our TD/router developer who indeed found that the old code from a couple decades ago is, as the developer wrote,
using the default printf %f precision to format the incoming float. I verified in a short C program that that won’t work for this number – it gets rounded to .000001, as reported.
This is why it it's rounding so early.

I will enter in a defect for this. Done, new defect is: TD-17912

erasmo
Brazil
Posts: 21
Joined: 21 Mar 2017, 13:17
Location: Campinas/SP - Brazil

SqlOraPLSQLPrepare round bug 4.2, 5.1, 5.2

Post by erasmo » 28 Jun 2012, 13:19

In my view is a bug because it works correctly in CTD151.

Another problem that works in 1.5.1 and does not work in 5.1, 6.0 and 6.1: if the input value (bind) is a decimates the application stops unexpectedly:

Code: Select all

Set w_n_input = 10/3
If SqlOraPLSQLPrepare( sql_tst, "
             begin
                   :w_n_return := fnc_tst_decimates(:w_n_input);
             end;
             " )
       Call SqlOraPLSQLExecute( sql_tst )
Thanks
Erasmo

Return to “Bug Reports”

Who is online

Users browsing this forum: [Ccbot] and 0 guests