473,508 Members | 2,373 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Really going crazy with NOT NULL

Ike
Suppose I set up the following table with 5.0.18-nt:

CREATE TABLE `leads` (
`id` int(11) NOT NULL auto_increment,
`uniqueId` varchar(40) default NULL,
`upcardkey` int(11) NOT NULL default '0',
`associatekey` int(11) NOT NULL default '0',
`date` varchar(16) default NULL,
`time` varchar(11) default NULL,
`sensor` int(3) NOT NULL default '0',
`heads` int(3) NOT NULL default '1',
`upskey` int(11) NOT NULL default '0',
`closed` int(3) NOT NULL default '0',
`howdidyouhear` int(11) NOT NULL default '0',
`bb` int(3) NOT NULL default '0',
`tor` int(3) NOT NULL default '0',
KEY `id` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
When I go to perform the following insert:

INSERT INTO leads( uniqueId, upcardkey, associatekey, date, time, sensor,
heads, upskey, howdidyouhear, bb, tor )
VALUES (
'-1|-1|7|2006-01-24 Tue|15:13:07|0|1|39', '', '7', '2006-01-24 Tue',
'15:15:05', '0', '1', '39', '3', '0', '0'
)

My insert fails:
MySQL said:

#1264 - Out of range value adjusted for column 'upcardkey' at row 1

This did not occur with MySQL < 5.0. Can someone clue me in on things here?
Is there a workaround I can employ such that my code would be compatible
with MYSQL 4.x and 5.x ? Thanks, Ike

Jan 24 '06 #1
1 1197
"Ike" <rx*@hotmail.com> wrote in message
news:kk*****************@newsread3.news.atl.earthl ink.net...
`upcardkey` int(11) NOT NULL default '0', .. . . INSERT INTO leads( uniqueId, upcardkey, associatekey, date, time, sensor,
heads, upskey, howdidyouhear, bb, tor )
VALUES (
'-1|-1|7|2006-01-24 Tue|15:13:07|0|1|39', '', '7', '2006-01-24 Tue',
'15:15:05', '0', '1', '39', '3', '0', '0'
) .. . . #1264 - Out of range value adjusted for column 'upcardkey' at row 1
Looks like you're trying to put a zero-length string '' into an int column.
An empty string cast to an integer is not the same thing as a NULL, so it
does not use the default value you specified; it uses 0. By coincedence,
this is the same as your default value in this case, but if you have a
different value as the default, it still uses 0 when casting '' as an
integer.
This did not occur with MySQL < 5.0. Can someone clue me in on things
here?
Is there a workaround I can employ such that my code would be compatible
with MYSQL 4.x and 5.x ? Thanks, Ike


Yes -- specify legitimate integer values when inserting data into integer
columns.

Regards,
Bill K.
Jan 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
4534
by: spoilsport | last post by:
Ive got to write a multi-function program and I'm plugging in the functions but I keep getting this error from line 40. Im new to this and cant find an answer anywhere. Sam #include...
27
4241
by: Chess Saurus | last post by:
I'm getting a little bit tired of writing if (a = malloc(...) == NULL) { // error code } I mean, is it really possible that a malloc call could fail, except in the case of running out of...
3
2607
by: alef | last post by:
Hi, I have the following code which is driving me crazy. I compile it on MacOSX and it keeps crashing upon entering a command in the program (ran trough gdb) pwd Program received signal...
19
1688
by: Daniel Billingsley | last post by:
I think it's really nice to be able to do code like someVariable = someMethod(new SomeClass("some text")); However, as method signatures are number and types of parameters, you're limited to...
3
1466
by: Larry Tate | last post by:
I have had a monstrous time getting any good debugging info out of the .net platform. Using ... ..NET Framework 1.1 Windows 2K Server VB.NET <- is this the problem? error handling in the...
6
2182
by: thomas.luce | last post by:
Okay, I have been programming for a long time, and am getting back into C after about a 4 year break from it. Below is some code that won't compile for the life of me, and it is driving me crazy!...
2
3532
by: Pat | last post by:
Hello everyone, I have a question that even my instructor is perplexed. I have created a template class within a header file. Then in a cpp file I have the methods that go with the class. I have...
10
1270
by: shapper | last post by:
Hello, I have a custom control under namespace MyNameSpace.WebControls with a property of type validation: ' Validation Private _Validation As Validation < _ Bindable(True), _...
1
2655
by: shapper | last post by:
Hello, On my CMS I am signed as administrator and I am creating a Membership user and its profile: MembershipCreateStatus status; MembershipUser user = Membership.CreateUser("Joe", "Pass",...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7115
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7321
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7489
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5624
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4705
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
1
762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
414
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.