Несколько внешних ключей?

Используйте методы setStandardInput: и setStandardOutput: класса NSTaks .

NSTask *task;
task = [[NSTask alloc] init];
[task setLaunchPath: @"/usr/bin/gdb"];

NSPipe *outputpipe=[[NSPipe alloc]init];
NSPipe *errorpipe=[[NSPipe alloc]init];
NSFileHandle *output,*error;

[task setArguments: arguments];
[task setStandardOutput:outputpipe];
[task setStandardError:errorpipe];

NSLog(@"%@",arguments);

output=[outputpipe fileHandleForReading];    
error=[errorpipe  fileHandleForReading];    
[task launch]; 

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedData:)  name: NSFileHandleReadCompletionNotification object:output];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receivedError:)  name: NSFileHandleReadCompletionNotification object:error];    
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(TaskCompletion:)  name: NSTaskDidTerminateNotification object:task];

//[input writeData:[NSMutableData initWithString:@"test"]];
[output readInBackgroundAndNotify];
[error readInBackgroundAndNotify];

[task waitUntilExit];
[outputpipe release];
[errorpipe release];
[task release];

-(void) receivedData:(NSNotification*) rec_not {
    NSFileHandle *out=[[task standardOutput] fileHandleForReading]; 
    NSData *dataOutput=[[rec_not userInfo] objectForKey:NSFileHandleNotificationDataItem];

    if( !dataOutput)
        NSLog(@">>>>>>>>>>>>>>Empty Data");

    NSString *strfromdata=[[NSString alloc] initWithData:dataOutput encoding:NSUTF8StringEncoding];    
    [out readInBackgroundAndNotify];
    [strfromdata release];
}

/* Called when there is some data in the error pipe */
-(void) receivedError:(NSNotification*) rec_not {
    NSFileHandle *err=[[task standardError] fileHandleForReading];  
    NSData *dataOutput=[[rec_not userInfo] objectForKey:NSFileHandleNotificationDataItem];

    if( !dataOutput)    
        NSLog(@">>>>>>>>>>>>>>Empty Data");
    else {
        NSString *strfromdata=[[NSString alloc] initWithData:dataOutput encoding:NSUTF8StringEncoding];
    [strfromdata release];
    }
    [err readInBackgroundAndNotify];
}

/* Called when the task is complete */
-(void) TaskCompletion :(NSNotification*) rec_not { 
    NSLog(@"task ended");
}

14
задан johnchen902 3 November 2013 в 05:06
поделиться

3 ответа

Вы определили первичный ключ дважды. Попробуйте:

CREATE TABLE SHIPPING_GRID(  
    id INT NOT NULL AUTO_INCREMENT PRIMARY KEY COMMENT 'Unique ID for each row',  
    shipping_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the shipping vendor (vendors_type must be 3)',  
    start_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to VENDOR.no for the vendor being shipped from',  
    end_vendor_no INT(6) NOT NULL COMMENT 'Foreign key to the VENDOR.no for the vendor being shipped to',  
    shipment_duration INT(1) DEFAULT 1 COMMENT 'Duration in whole days shipment will take',  
    price FLOAT(5,5) NOT NULL COMMENT 'Price in US dollars per shipment lbs (down to 5 decimal places)',  
    is_flat_rate TINYINT(1) DEFAULT 0 COMMENT '1 if is flat rate regardless of weight, 0 if price is by lbs',  
    INDEX (shipping_vendor_no),  
    INDEX (start_vendor_no),  
    INDEX (end_vendor_no),  
    FOREIGN KEY (shipping_vendor_no) REFERENCES VENDOR (no),  
    FOREIGN KEY (start_vendor_no) REFERENCES VENDOR (no),  
    FOREIGN KEY (end_vendor_no) REFERENCES VENDOR (no)  
) TYPE = INNODB;

первичный ключ ПОСТАВЩИКА должен быть INT (6), и обе таблицы должны иметь тип InnoDB.

9
ответ дан Valentin Rocher 3 November 2013 в 05:06
поделиться
  • 1
    При необходимости в нескольких таблицах, добавляет переключатель-t для каждой таблицы. Так, pg_dump --no-acl --no-owner -h [host ip].compute-1.amazonaws.com -U [user name] -t [table name 1] -t [table name 2] -t [table name 3] --data-only [database name] > table.dump – vansan 18 November 2013 в 15:34

Может Вы предоставлять определение таблицы

VENDOR, я понял его. Таблицей VENDOR был MyISAM... (отредактировал Ваш ответ, чтобы сказать мне делать их обоих INNODB;))

(какая-либо причина не , чтобы просто переключить тип ПОСТАВЩИКА на INNODB?)

0
ответ дан Trevor Hickey 3 November 2013 в 05:06
поделиться

Я выполнил код сюда, и сообщение об ошибке показало (и это правильно!), что Вы - идентификационное поле установки дважды как первичный ключ.

0
ответ дан Mario Marinato 3 November 2013 в 05:06
поделиться
Другие вопросы по тегам:

Похожие вопросы: