Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
Inserting data problem
Old 06-18-2008, 07:20 AM Inserting data problem
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
I have two tables and I have a query that copies data from one table to another using an insert query.

The data is inserted ok into the table and the query works, but for some reason in alot of the fields for example, phone,fax etc it inserts the first letter of the organisation name (stored in organisationName coloumn)

for example,

PHP Code:
organisationName,  Phone,   Fax,  Email
Organisation1
,     O,       O,    
and in the same row for the phone, fax and email columns it inserts the first letter of the value stored in the organisationName column, so in the example above it inserts the letter O in each column for that record.

Any ideas why it does this?

Thanks,

Last edited by drew22299; 06-18-2008 at 09:22 AM..
drew22299 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-18-2008, 12:32 PM Re: Inserting data problem
nyef's Avatar
Ultra Talker

Posts: 265
Name: Lucas
Trades: 0
There's no reason it SHOULD be doing that, so you'd have to post the exact INSERT query that is being executed for us to identify what is causing it.
__________________
~nyef

Please login or register to view this content. Registration is FREE
nyef is offline
Reply With Quote
View Public Profile Visit nyef's homepage!
 
Old 06-18-2008, 02:44 PM Re: Inserting data problem
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
It's because of something the developer did. It could be that all the columns are set to only allow 1 character, but that's not it. In SQL Server, if that were the case, you would get a "string or binary data would be truncated" error when you tried to insert. And that also wouldn't explain the first letter being replicated to all columns.

So, it's probably that the part of your insert command that supplies the values is taking the first character from one column, and trying to put it into all of them.

Alternately, it could be a trigger, but this is less common.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 06-18-2008, 02:49 PM Re: Inserting data problem
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
Quote:
In SQL Server, if that were the case, you would get a "string or binary data would be truncated" error when you tried to insert.
Yeah, but 99.999% chances that this is a mysql DB.
Which truncate without notice, who convert a null to blank if the column is set to not nu ll and you try to insert a null and so on....
You see why I consider mysql for a basic toy ?

Anyway, Drew, like Nyef and John said, it's probably the insert statement that is at fault.
Or more precisely, the code that generate the SQL to be used, which mix up the datas.
Try to locate the part which create this statement in your file, and to paste it here.
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 06-18-2008, 03:51 PM Re: Inserting data problem
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
Thanks for your suggestions guys It wasn't working because I used a vairable twice, once in the while loop and again within the while loop.

Thanks,
drew22299 is offline
Reply With Quote
View Public Profile
 
Old 06-18-2008, 06:45 PM Re: Inserting data problem
Learning Newbie's Avatar
Defies a Status

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
Dynamic SQL rears its ugly head once again! I'd just like to point out that using a stored procedure with input parameters would have prevented this from being a problem in the first place.

Quote:
Originally Posted by tripy View Post
Yeah, but 99.999% chances that this is a mysql DB.
Which truncate without notice, who convert a null to blank if the column is set to not nu ll and you try to insert a null and so on....
Are you serious? I think I just had a mini stroke!

Quote:
Originally Posted by tripy View Post
You see why I consider mysql for a basic toy ?
Sure do - that's really amazing. I had brought it up for SQL Server assuming that MYSQL would work more or less the same way - probably different error text, but surely still an error, and not a silent failure! Anyway, sorry for the digression.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Inserting data problem
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.64247 seconds with 12 queries