View Single Post
  #1 (permalink)  
Old February 21st, 2006, 12:26 PM
melvik melvik is offline
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default 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.
__________________
Always,
Hovik Melkomian.
Reply With Quote