sqlitestudio icon indicating copy to clipboard operation
sqlitestudio copied to clipboard

ROWID error when using replace function with null character

Open Kensit opened this issue 3 years ago • 0 comments

Details

I was getting the following message often when I was opening views and using the grid view to edit the data:

[14:42:43] Cannot edit this cell. Details: The query execution mechanism had problems with extracting ROWID's properly. This might be a bug in the application. You may want to report this.

Steps to reproduce

It was a minor issue until I started trying to utilize the view trigger feature (triggers using the INSTEAD OF clause on views). I decided to research deeper and tracked the problem to the following column definition as causing:

substr(replace(ColX, '/', x'00'), 1) AS ColTruncated

The replace function above, that replaces slashes with nulls, is a technique used to truncate a string. I used it extensively before the instr function became available in older versions of the SQLite engine. Note that it was only when I used the null value that the problem arose, views with the following worked fine (ie. no message).

substr(replace(ColX, '/', 'x'), 1) AS ColTruncated

My full view definition (that produces the error):

CREATE VIEW [aSQLStudio_Test] AS SELECT ShowNm ,substr(Replace(Notes, '/', x'00'),1) -- ,substr(Replace(Notes, '/', '//'),1) AS XNotes ,Notes FROM [ttvShow] AS C WHERE (Pf & 128) ;

Operating system

Windows 10

SQLiteStudio version

3.3.3

Kensit avatar Dec 11 '21 22:12 Kensit