I've never tried to create a FK on a temp table so can't tell you if that works or not. But you can create the temp table first and then use the alter command to add the FK afterwards. See if that works. Here's an example:
ALTER TABLE mpsinvoice ADD FOREIGN KEY (vendornum) REFERENCES vendors Karen -----Original Message----- From: Juan Otazú <[email protected]> To: RBASE-L Mailing List <[email protected]> Sent: Thu, Feb 14, 2013 1:05 pm Subject: [RBASE-L] - Create FK in temporary table Hi to all, I need to create a temporary table to enter data into a form and validate some PK, FK rules. This command work fine: CREATE TABLE tdexpara_cambios (momento DATETIME, codpais INT NOT NULL + ('ESPECIFIQUE A QUE PAIS CORRESPONDE'), material_anterior INT NOT NULL + ('INGRESE CODIGO DE MATERIAL ANTERIOR'), material_actual INT NOT NULL + ('INGRESE CODIGO DE MATERIAL ACTUAL'), artdes_anterior TEXT 40, + artdes_actual TEXT 40, PRIMARY KEY (codpais, material_anterior) + ('MATERIAL ANTERIOR DUPLICADO EN LA LISTA'), FOREIGN KEY + (material_anterior) REFERENCES sap_material + ('MATERIAL ANTERIOR NO EXISTE EN SAP'), FOREIGN KEY (material_actual) + REFERENCES sap_material ('MATERIAL ACTUAL NO EXISTE EN SAP'), CHECK + (material_actual <> material_anterior)) It is a regular table. But this do not work: CREATE TEMPORARY TABLE tdexpara_cambios (momento DATETIME, codpais INT NOT NULL+ ('ESPECIFIQUE A QUE PAIS CORRESPONDE'), material_anterior INT NOT NULL + ('INGRESE CODIGO DE MATERIAL ANTERIOR'), material_actual INT NOT NULL + ('INGRESE CODIGO DE MATERIAL ACTUAL'), artdes_anterior TEXT 40, + artdes_actual TEXT 40, PRIMARY KEY (codpais, material_anterior) + ('MATERIAL ANTERIOR DUPLICADO EN LA LISTA'), FOREIGN KEY + (material_anterior) REFERENCES sap_material + ('MATERIAL ANTERIOR NO EXISTE EN SAP'), FOREIGN KEY (material_actual) + REFERENCES sap_material ('MATERIAL ACTUAL NO EXISTE EN SAP'), CHECK + (material_actual <> material_anterior)) The message say: -ERROR- The referenced table does not exist. (2801) Do not create the temporary table. The only one change has been add "temporary" to line 1. Some issues to connect temporary FK to regular PK ? Thanks in advance. R:egards Juan Otazú R:Base 9.5 (32)

