0

I am working on a Java application that perform query on the DB using JDBC and I have the following problem with a very simple update query.

So I have this query (acytually incomplete):

sb.append("UPDATE coda_tx c SET c.FK_STATO = ");
sb.append(newStatus);
sb.append(",c.DATA_OUT = ");
sb.append(???)
sb.append(" WHERE c.PK_CODA = ");
sb.append(pkCoda);

So this query have simple to update 2 fields of the coda_tx table.

The FK_STATO field update is not a problem (it is update with a string and it works fine, I tryied in a previous query verion) but I don't know how to correctly update the DATA_OUT field that is a DATE SQL field.

In the specific I have that it is updated with the sysdate, it say:

  • CODA_TX.data_out = sysdate

So I think that it have to be update with the current date retrieved from Java. Is it right or am I missing something? What exactly is this sysdate? How can I correctly retrieve and use it?

What hava I to put instead the ??? into sb.append(???) to update the field?

Tnx

AndreaNobili
  • 40,955
  • 107
  • 324
  • 596

1 Answers1

1

Just use the system date value from the database. Use:

c.DATA_OUT = sysdate

in the update statement.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • So, in my previous query, I can do sb.append(sysdate); or what? – AndreaNobili Mar 18 '15 at 10:25
  • 2
    @AndreaNobili - no, `sysdate` is a database function, not something Java knows about; so either `sb.append("sysdate")` or include it in the previous append (and merge the following one too, perhaps). – Alex Poole Mar 18 '15 at 10:38