I have two tables to save detail, save file and I want to create a view of some of the columns of save file, the problem is that I am presented with a syntax error that I can not solve
String SQL4 = "INSERT INTO DetalleGuardarFactura (NombreFactura,cliente_nombrecliente,FechaFacturaGuardada,estado)"
+ " values (?,?,?,?)";
ps = Conexion.prepareStatement(SQL4);
ps.setString(1, nombre);
ps.setString(2, CamposCliente[2].getText());
ps.setTimestamp(3, timestamp);
ps.setBoolean(4, true);
ps.executeUpdate();
//////////////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < Modelo.getRowCount(); i++) {
if (Modelo.getValueAt(i, 0) == Boolean.TRUE) {
String SQL2 = "INSERT INTO guardarfactura (NumeroParte,NombreRepuesto"
+ " ,PrecioUnitario,TotalGanacia,CantidadRepuesto,DetalleGuardarFactura_NombreFactura,Estado)"
+ " values (?,?,?,?,?,?,?)";
ps = Conexion.prepareStatement(SQL2);
ps.setString(1, (String) Modelo.getValueAt(i, 3));
ps.setString(2, (String) Modelo.getValueAt(i, 2));
/////////////////////////////////////
Object id = Modelo.getValueAt(i, 4);
String ide = id.toString();
Double valor = Double.parseDouble(ide);
ps.setDouble(3, valor);
/////////////////////////////////////
Object id2 = Modelo.getValueAt(i, 5);
String ide2 = id2.toString();
Double valor2 = Double.parseDouble(ide2);
ps.setDouble(4, valor2);
////////////////////////////////////
Object id3 = Modelo.getValueAt(i, 4);
String ide3 = id3.toString();
int valor3 = Integer.parseInt(ide3);
ps.setInt(5, valor3);
ps.setString(6, nombre);
ps.setBoolean(7, true);
ps.executeUpdate();
}
}
//////////////////////////////////////////////////////////////////////////////////////
String SQL3 = "create view ? as SELECT NumeroParte,NombreRepuesto"
+ " ,PrecioUnitario,TotalGanacia,CantidadRepuesto"
+ " from guardarfactura WHERE DetalleGuardarFactura_NombreFactura=? and estado=?";
ps = Conexion.prepareStatement(SQL3);
ps.setString(1, nombre);
ps.setString(2, nombre);
ps.setBoolean(3, true);
ps.executeUpdate();
Enter in postgres and insert the two tables but the view does not create it, there is the error and I verify but I can not find the error, I hope you can help me