Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Delphi, Mysql and boolean

Posted on 2008-10-06
6
Medium Priority
?
745 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 900 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 600 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

715 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