def execute(self, environment): nCol = self.count() result = jsonMode.createTable(dbtemp, self.name, nCol) """ Result 0: insert 1: error 2: not found database 3: exists table """ if result == 0: insert = Struct.insertTable(dbtemp, self.name, self.columns, self.inherits) if insert == None: report = "Tabla " + self.name + " creada" else: jsonMode.dropTable(dbtemp, self.name) Struct.dropTable(dbtemp, self.name) report = insert elif result == 1: report = "Error: No se puedo crear la tabla: " + self.name elif result == 2: report = "Error: Base de datos no encontrada: " + dbtemp elif result == 3 and self.exists: report = "Tabla no creada, ya existe en la base de datos" else: report = "Error: ya existe la tabla " + self.name return report
def execute(self, environment): Struct.load() # insert = [posiblesErrores,noColumnas] insert = Struct.insertTable( instruction.dbtemp, self.name, self.columns, self.inherits ) error = insert[0] nCol = insert[1] if not error: error = Checker.checkValue(instruction.dbtemp, self.name) """ Result 0: insert 1: error 2: not found database 3: exists table """ if not error: result = jsonMode.createTable(instruction.dbtemp, self.name, nCol) if result == 0: pass elif result == 1: instruction.syntaxPostgreSQL.append("Error: XX000: Error interno") return "Error: No se puede crear la tabla: " + self.name elif result == 2: instruction.semanticErrors.append( "La base de datos " + instruction.dbtemp + " no existe" ) instruction.syntaxPostgreSQL.append( "Error: 3F000: base de datos" + instruction.dbtemp + " no existe" ) return "Error: Base de datos no encontrada: " + instruction.dbtemp elif result == 3 and self.exists: instruction.semanticErrors.append( ["La tabla " + str(self.name) + " ya existe", self.row] ) instruction.syntaxPostgreSQL.append( "Error: 42P07: La tabla " + str(self.name) + " ya existe" ) return "La tabla ya existe en la base de datos" else: instruction.semanticErrors.append( ["La tabla " + str(self.name) + " ya existe", self.row] ) instruction.syntaxPostgreSQL.append("Error: 42P07: tabla duplicada") return "Error: ya existe la tabla " + self.name pk = Struct.extractPKIndexColumns(instruction.dbtemp, self.name) addPK = 0 if pk: addPK = jsonMode.alterAddPK(instruction.dbtemp, self.name, pk) if addPK != 0: instruction.syntaxPostgreSQL.append( "Error: 23505: Error en llaves primarias de la instruccion CREATE TABLE de la tabla " + str(self.name) ) return "Tabla " + self.name + " creada" else: Struct.dropTable(instruction.dbtemp, self.name) return error
def execute(self, environment): nCol = self.count() result = jsonMode.createTable(dbtemp, self.name, nCol) """ Result 0: insert 1: error 2: not found database 3: exists table """ if result == 0: insert = Struct.insertTable(dbtemp, self.name, self.columns, self.inherits) if insert == None: pk = Struct.extractPKIndexColumns(dbtemp, self.name) addPK = 0 if pk: addPK = jsonMode.alterAddPK(dbtemp, self.name, pk) if addPK != 0: print("Error en llaves primarias del CREATE TABLE:", self.name) report = "Tabla " + self.name + " creada" else: jsonMode.dropTable(dbtemp, self.name) Struct.dropTable(dbtemp, self.name) report = insert elif result == 1: sintaxPostgreSQL.insert(len(sintaxPostgreSQL), "Error: XX000: Error interno") report = "Error: No se puede crear la tabla: " + self.name elif result == 2: sintaxPostgreSQL.insert( len(sintaxPostgreSQL), "Error: 3F000: base de datos" + dbtemp + " no existe", ) report = "Error: Base de datos no encontrada: " + dbtemp elif result == 3 and self.exists: report = "Tabla no creada, ya existe en la base de datos" else: report = "Error: ya existe la tabla " + self.name sintaxPostgreSQL.insert(len(sintaxPostgreSQL), "Error: 42P07: tabla duplicada") return report