Search code examples
javasqlderby

SQL update statement - trying to update whole table error


I'm using a Derby db and I'm trying to update every single column in one of my tables.

I'm using the following statement:

String stmt = "UPDATE APP.DATAVAULT SET DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ? WHERE DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ?";

I've done an update before, using the following statement:

String stmt = "UPDATE APP.PERSON SET PSNAME = ? WHERE PID = ?";

Is there an easier way to update an entire table? If not, what am I doing wrong with this statement, as I keep receiving the following error:

Syntax error: Encountered "," at line 1, column 137.

Solution

  • This

    WHERE DID = ?, DTITLE = ?, DUNAME = ?, DPASS = ?, DSANSWER = ?, DPIN = ?, DURL = ?, DNOTES = ?, PID = ?
    

    should be this

    WHERE DID = ? AND DTITLE = ? AND DUNAME = ? AND DPASS = ? AND DSANSWER = ? AND DPIN = ? AND DURL = ? AND DNOTES = ? AND PID = ?
    

    So replace , with AND.