Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

C float value not found in Oracle NUMBER column

570443Mar 9 2011 — edited Mar 10 2011
I have a 'C' program which contains embedded SQL ~ that was not returning the results I expected. I was able to figure out a 'work around', but was wondering if there was a cleaner/better way to handle the problem. The problem occurred with a query which was looking for given floating point values in an Oracle table that had the columns declared as NUMBER(8,6) ~ for the latitudes, and NUMBER(9,6) ~ for the longitudes. Here is the original code, and the crazy work around I used to temporarily get past it. Will appreciate any suggestions for a better method... thanks...

Vicki

EXEC SQL select count(*)
into :cnt_var
from gateway.resolved
where min_lat = :min_lat and
min_lon = :min_lon and
max_lat = :max_lat and
max_lon = :max_lon;

temporary work around
----------------

sprintf(min_lat_str, "%lf", min_lat);
sprintf(min_lon_str, "%lf", min_lon);
sprintf(max_lat_str, "%lf", max_lat);
sprintf(max_lon_str, "%lf", max_lon);

EXEC SQL select count(*)
into :cnt_var
from gateway.resolved
where min_lat = to_number(:min_lat_str) and
min_lon = to_number(:min_lon_str) and
max_lat = to_number(:max_lat_str) and
max_lon = to_number(:max_lon_str);
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2011
Added on Mar 9 2011
4 comments
534 views