Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Default Value Errors?

Author  Topic 

Erin Card
Starting Member

6 Posts

Posted - 2012-01-18 : 12:40:37
I am working on developing a ZenCart for my work, but am having some pretty serious issues when it comes to SQL INSERT queries and blank, aka '', values. I am running MAMP locally and can install a configuration just fine, such as this one:
INSERT INTO configuration_group VALUES ('', 'Manufacturers All Config', 'Manufacturers All Config', '1', '1');
But when I try to install it on my server, i get an error "1366 Incorrect integer value: '' for column 'configuration_group_id' at row 1." The '' as the first value SHOULD default to the incremental value in the table, correct? This happens whenever there is a '' trying to go into a numerical column. If it is for a text-based column, it enters '', whether there's a default value of '' or something else and I am not given the error.

I have talked with my server administrator, and he is convinced there is nothing wrong and has told me to just fix my code. ugh. the code works fine in MAMP and i'm guessing in just about every other installation on every other server as i shouldn't have the same problem with ever ZenModule I work with, as well as the custom queries I've written myself. Has anyone else run into this before? I'm convinced it's a server (or possibly database) configuration problem but I can't for the life of me figure out what.

I have the phpinfo(); printouts for both the working server and my local MAMP if that will clarify anything. Let me know if I need to attach/send/etc them.

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 12:45:37
First..you should ALWAYS supply a column list for your INSERT..sinve you may have many columns it may be trying to put the values in the wrong columns

Post the DDL of your table if that doesn't fix it

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 12:46:25
Hello Erin Card,


It is difficult to say as one cannot determine what is the structure of configuration_group table from the information provided.

Does the table contain an identity column? Perhaps your insert is trying to assign an explicit value to an identity column? I can only guess. Perhaps you can modify your insert statement with explicit columns and it will help reveal the issue. Something like:

INSERT INTO configuration_group (col1, col2, col3, etc...) VALUES (val1, val2, val3, etc...)


HTH.

EDIT: sniped... :)
Go to Top of Page

Erin Card
Starting Member

6 Posts

Posted - 2012-01-18 : 13:15:14
This particular INSERT query is not something i've written, but there is a value for each of the columns (there are only 5 in this table). If I rewrite it (which I'm annoyed at having to do all the time, now), it will go as thus:

INSERT INTO configuration_group (configuration_group_id, configuration_group_title, configuration_group_description, sort_order, visible) VALUES ('', 'Manufacturers All Config', 'Manufacturers All Config', '1', '1');

and that doesn't work on the server, but does in MAMP, just checked. Rewriting to remove the configuration_group_id works on both servers.

INSERT INTO configuration_group (configuration_group_title, configuration_group_description, sort_order, visible) VALUES ('Manufacturers All Config', 'Manufacturers All Config', '1', '1');


configuration_group DDL (i think i understand you correctly when you say DDL)

column, type, collation, attributes, null, default, extra
configuration_group_id, int(11), '', '', no, none, auto_increment
configuration_group_title, varchar(64), latin1_general_ci, '', no, '', ''
configuration_group_description, varchar(255), latin1_general_ci, '', no, '', ''
sort_order, int(5), '', '', yes, NULL, ''
visible, int(1), '', '', yes, 1

this isn't the only table i'm having issues with - it's my entire database. whether it's a coupon table, product information, etc., '' values throw errors whenever there is an int type.

I'm REALLY hoping there is a fix for this and don't have to resign to recoding every time a field or value has the potential to be left blank, especially when i don't have to on my local setup.
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 13:19:36
Unless I am mistaken, it appears that configuration_group_id is an identity (auto increment) field and as such cannot be assigned a value in an insert statement.

HTH.
Go to Top of Page

Erin Card
Starting Member

6 Posts

Posted - 2012-01-18 : 13:25:22
quote:
Originally posted by ehorn

Unless I am mistaken, it appears that configuration_group_id is an identity (auto increment) field and as such cannot be assigned a value in an insert statement.

HTH.



Makes sense. Until you consider the statement works on my MAMP server with the empty ( '' ) value. When '' is entered in lieu of 1 or 'yes', it's not actually assigning a value, am I correct?
Go to Top of Page

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2012-01-18 : 13:28:20
quote:
Originally posted by Erin Card

quote:
Originally posted by ehorn

Unless I am mistaken, it appears that configuration_group_id is an identity (auto increment) field and as such cannot be assigned a value in an insert statement.

HTH.



Makes sense. Until you consider the statement works on my MAMP server with the empty ( '' ) value. When '' is entered in lieu of 1 or 'yes', it's not actually assigning a value, am I correct?



I cannot say for certain. But I would have to assume that MAMP is not setup as auto increment or has some different settings than the other DB's (i.e. IDENTITY_INSERT is ON in dev environment).

HTH.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 13:30:17
ummmm


Since what you are doing is NOT a best practice, you SHOULD rewrite your INSERTs to have the column list match your input values

What happens if they alter the table and add a column?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Erin Card
Starting Member

6 Posts

Posted - 2012-01-18 : 13:49:57
quote:
Originally posted by X002548

ummmm
Since what you are doing is NOT a best practice, you SHOULD rewrite your INSERTs to have the column list match your input values

What happens if they alter the table and add a column?



That's fine. there are only 5 lines of code to copy/insert to fix THAT particular file (I did not write the INSERT codes for that, i'm more picky and would have put each column in, initially). I can fix this instance, as I've had to do with 20 other files that should work as-is.

quote:
I cannot say for certain. But I would have to assume that MAMP is not setup as auto increment or has some different settings than the other DB's (i.e. IDENTITY_INSERT is ON in dev environment).


The database was exported from MAMP to the server. The two table structures are exactly the same and executing INSERT INTO configuration_group VALUES ('', 'Manufacturers All Config', 'Manufacturers All Config', '1', '1'); in MAMP correctly auto-increments. :/

I mentioned the coupon table earlier, which is set up by ZenCart. Installed fine on my local server, but both an upload of the files to the server AND a fresh install gave me the same 1366 Incorrect integer value. I have not been able to find a resolution of this in the ZenCart forums. Results of "1366 Incorrect integer value" pop up in threads every so often haven't found a solved one, yet. :/
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 13:58:49
Did we confirm that this is SQL Server?



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Erin Card
Starting Member

6 Posts

Posted - 2012-01-18 : 14:04:16
Yes? Would SQL queries work on it if it is not?

Client API version: mysqlnd 5.0.8-dev - 20102224 - $Revision: 310735 $
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 14:07:41
Sure

ANSI SQL would execute on many platforms


Are you using SQL Server Management Studio?

Do you know how to script out a table DDL

I was curious, because I don't ever remember seeing SQL Server say Auto-Increment


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2012-01-18 : 14:09:55
ummmmm

http://forums.mysql.com/read.php?34,498575,498575



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Erin Card
Starting Member

6 Posts

Posted - 2012-01-18 : 14:14:09
Ahh, I misread. I added a word to read "an SQL server." I manage the databases using phpmyadmin. Am I in an incorrect forum area?
Go to Top of Page
   

- Advertisement -