Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 527863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:55:40+00:00 2026-05-13T08:55:40+00:00

I have to work with a legacy system based on SQL Anywhere 5, db

  • 0

I have to work with a legacy system based on SQL Anywhere 5, db access layer is in C++ using embedded SQL. The problem I have is not really a C++ problem, but embedded SQL forces us to SQL statements which cannot be dynamically generated. There are many tables containing a lot of columns having the datatype double. Though the main application expects these columns to be not NULL, there are no NOT NULL contraints on most of this columns. To avoid application crashes, we use a lot of ISNULL in our SQLs. For example, instead of just writing

SELECT d1,d2,d3,d4 FROM table1;

we write

SELECT ISNULL(d1,0),ISNULL(d2,0),ISNULL(d3,0),ISNULL(d4,0) FROM table1;

So far, problem solved, everything seems fine – we thought. Now, we have found, that, when for example d1 contains 1.2345678987654321 in one row, then

SELECT d1 ...

results in

1.2345678987654321

but

SELECT ISNULL(d1,0) ...

results in

1.234567

The reason for this seems to be that when you call ISNULL with a double and a number like 0, there happens some type conversion of both arguments of ISNULL to NUMBER(30,6) first, so d1 is cutted to 6 decimals. Simple fix is here

SELECT ISNULL(d1,CAST(0 AS DOUBLE)) ...

This will give the expected 1.2345678987654321 again, but it results in very lengthy SQL statements:

SELECT ISNULL(d1,CAST(0 AS DOUBLE)),ISNULL(d2,CAST(0 AS DOUBLE)),ISNULL(d3,CAST(0 AS DOUBLE)), ISNULL(d4,CAST(0 AS DOUBLE))

So we tried to find a shorter way to write a DOUBLE zero literally in SQL:

SELECT ISNULL(d1,0e0)... or SELECT ISNULL(d1,0.0)...

does not work, gives 1.234567 again.

SELECT ISNULL(d1,SIN(0))... or SELECT ISNULL(d1,1e-307)...

works both, yields correct 1.2345678987654321, but seems both very ugly just for writing a 0.

So here is the question: any ideas on how to write this shorter / more readable / avoid the problem totally? Remember, neither generating SQL statements is an option under our constraints, nor is changing the DB schema.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T08:55:40+00:00Added an answer on May 13, 2026 at 8:55 am

    no sure if it will work for v5
    try to set the database option to treat floats as doubles via sql
    run the query

    set option FLOAT_AS_DOUBLE = 'ON'
    

    if you want it to hold for the current connection only use

    set TEMPORARY option FLOAT_AS_DOUBLE = 'ON'
    

    you can then try to use your query’s first version

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Very backwards question really, but we have a legacy system which only works with
At my place of work we have a legacy document management system that for
I have a work around for this problem, but I've been noticing some peculiar
We have a situation at work where developers working on a legacy (core) system
I have been using Windows 7 for a while but have not had to
I am using AJAX extensively and my PHP based notification system was not sufficient.
Currently I have to deal with the legacy system written in VB. I'm not
The commandlink link2 does not have work after an ajax call is made to
I have a work page that shows all projects. I am using a taxonomy
I often have to work with fragile legacy websites that break in unexpected ways

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.