Multiple update commands separated by ";" (dot and comma) in Sqlite!

Asked

Viewed 61 times

1

Problem

I am trying to apply the following script/command to a version of my Sqlite database:

UPDATE UF
   SET DATE_CREATE = DATE_UPDATE;

UPDATE CIDADE
   SET DATE_CREATE = DATE_UPDATE;

UPDATE CLIENTE
   SET DATE_CREATE = DATE_UPDATE;

But only applies on the table CLIENTE, and the field too DATE_CREATE continues NULL.

This happens when applying on Android with the db.execSQL(script) how much in the Sqlitestudio in my local machine.

In Sqlitestudio the following message is displayed on the console:

[15:14:14] Query finished in 0.055 second(s). Rows affected: 531

Where the 531 Rows are the 531 table records of CLIENTE where I am testing the scripts. The table of CIDADE has 5603 records and UF has 27 records.

Question

Can anyone tell me if Sqlite has any restrictions when applying multiple commands in the same script? Or is there a flaw in my script?

  • 2

    That reply (http://stackoverflow.com/a/12742226/2236741) made me think of a suggestion: make each UPDATE in one line and see if it works.

  • The fact that the Sqlitestudio message shows only the 531 affected records is not a problem, since it should always refer to the last executed sentence. Strange is the update has not been applied in the UF and CIDADE tables. Another suggestion, put ; on a separate line as shown here (http://stackoverflow.com/a/12742282).

  • What version of your Sqlite?

  • @David, 3.8.6 on Android and 3.8.10 on Sqlitestudio!

  • @Cantoni, I tried what you suggested to break the line to put the ";" (point and comma), yet it continues the same behavior!

  • 1

    And each update in a row?

  • @Cantoni, it’s like the question, but as far as I know it wouldn’t matter if it’s on the same line or not, since the ";" (point and comma) was supposed to be the separator between one command and the other. Intriguing this behavior! =(

  • Yes. I also think the same. I found it so strange that I proposed these two attempts.

  • 1

    Really @ramaral, the answers of the duplicate answer the question, I had already implemented in this way, running each command in a execSQL(), but had not seen in the documentation that this was a limitation! And the Sqlitestudio should use a execSQL also with the same limitation to apply the scripts so the problem happens in it too! Thanks for the clarification.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.