Solved

Delphi, Mysql and boolean

Posted on 2008-10-06
6
741 Views
Last Modified: 2013-11-05
Hi,

I have a problem with delphi and mysql.. when i save a boolean in the database, the false is 0 and the true is -1.

Is there any way to force mysql to save it as 1 instead of -1?

Thanks
Luc
0
Comment
Question by:Mysterion
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 15

Expert Comment

by:mikelittlewood
ID: 22652933
Some databases use -1 as true, some use 1.
Only other way I can think would be to not use boolean and use smallInt
0
 
LVL 38

Accepted Solution

by:
Geert Gruwez earned 300 total points
ID: 22657383
in what context are you using the loaded value ?

you could use
FieldByName('FIELDNAME').AsString = '0'
for False and

FieldByName('FIELDNAME').AsString <> '0'
for True

or is it the .AsBoolean which allways returns false ?
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 22657404
looking at the MySQL docs the value is stored as 0 or 1 into a TinyInt(1) field

http://dev.mysql.com/doc/refman/6.0/en/numeric-type-overview.html

how do you store the value into the mysql database ?
and what components do you use for this ?
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 46

Assisted Solution

by:aikimark
aikimark earned 200 total points
ID: 22658167
@Luc

Why would it matter how any database engine stores its boolean data values as long as your program accurately reflects their TRUE and FALSE values when records are retrieved?

If you need to sum a boolean column to determine the number of TRUE values, then take the absolute value of the SUM() function.
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 22666761
Please read the help before you ask your next question
especially about accepting answers

http://beta.experts-exchange.com/help.jsp
0
 
LVL 46

Expert Comment

by:aikimark
ID: 22668376
@Geert_Gruwez

Please be a bit more specific in what you are urging Mysterion to consider or change in evaluation of future answers.

Your answer was very language specific, where my answer was database/SQL specific.  Somewhere between the two of our answers, Luc seems to have gotten an acceptable work-around.  Looking at the new grading recommendations, I don't see anything amiss in the B grade and the split points.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses
Course of the Month8 days, 3 hours left to enroll

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question