p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   MySQL (http://p2p.wrox.com/forumdisplay.php?f=99)
-   -   Cant ADD CONSTRAINT (ergent) (http://p2p.wrox.com/showthread.php?t=38809)

melvik February 21st, 2006 12:26 PM

Cant ADD CONSTRAINT (ergent)
 
Hi there:
I have 2 tables & I want to add forien key CONSTRAINT between them as:
Code:

ALTER TABLE `test`.`t_InquiredProforma`
ADD CONSTRAINT `FK_t_InquiredProforma_1` FOREIGN KEY `FK_t_InquiredProforma_1`
(`bPartnerId`) REFERENCES `t_BusinessPartner` (`bPartnerId`)
    ON DELETE CASCADE
    ON UPDATE RESTRICT;


but it gives me an error
Can't create table '.\test\#sql-57c_3a.frm' (errno: 150)

Please help me.
tnx in advance.

My tables r as below:
Code:

CREATE TABLE  `test`.`t_InquiredProforma` (
  `serial` bigint(20) NOT NULL default '0',
  `salesmanProformaSerial` varchar(255) default NULL,
  `date` date default NULL,
  `validity` date default NULL,
  `warehousingExp` int(11) default NULL,
  `consideration` varchar(255) default NULL,
  `discount` int(11) default NULL,
  `deposit` bigint(20) default NULL,
  `status` varchar(255) default NULL,
  `acceptedByManager` tinyint(1) default NULL,
  `acceptedByCommision` tinyint(1) default NULL,
  `selected` tinyint(1) default NULL,
  `totalCost` bigint(20) default NULL,
  `bPartnerId` bigint(20) NOT NULL default '0',
  `t_PurchaseOrder_serial` bigint(20) NOT NULL default '0',
  PRIMARY KEY  (`serial`)
) TYPE=InnoDB;


CREATE TABLE  `test`.`t_BusinessPartner` (
  `bPartnerId` bigint(20) unsigned NOT NULL default '0',
  `t_BusinessPartner_KargozarId` bigint(20) unsigned default NULL,
  `name` varchar(255) NOT NULL default '',
  `economicalCode` varchar(255) default NULL,
  `webSite` varchar(255) default NULL,
  `email` varchar(255) default NULL,
  `telephone1` varchar(255) NOT NULL default '',
  `telephone2` varchar(255) default NULL,
  `fax` varchar(255) default NULL,
  `postalCode` varchar(255) default NULL,
  `postBox` varchar(255) default NULL,
  `address` varchar(255) default NULL,
  `level` varchar(255) NOT NULL default '',
  `type` varchar(255) NOT NULL default '',
  `category` varchar(255) NOT NULL default '',
  `commissionEvaluation` varchar(255) default NULL,
  `manager` varchar(255) default NULL,
  `tradeManager` varchar(255) default NULL,
  `id` bigint(20) default NULL,
  `manager_fk` int(11) default NULL,
  `tradeManager_fk` int(11) default NULL,
  `businesspartner_fk` bigint(20) default NULL,
  PRIMARY KEY  (`bPartnerId`)
) TYPE=InnoDB;



Always:),
Hovik Melkomian.

melvik February 28th, 2006 02:05 AM

ok guys I got it!

Always:),
Hovik Melkomian.

Dj Kat March 6th, 2006 04:02 AM

Hi,

What was the solution? I have the same trouble.

thnx

__________________________________________________ ________
This is my junk I'm gona eat it

melvik April 18th, 2006 01:16 AM

Well I dont have a long experiance in MySql but as I got since now MySql is so sensitive or has not the good performance as I felf in MS-SQL & Oracle!
Anyway the things u should check is:
1_ Primary & Forien key must be in DataType
2_ Check unsign tag in ur table
3_ Both tables must be in same Engine

HTH.

Always:),
Hovik Melkomian.


All times are GMT -4. The time now is 04:21 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.