|
-
May 10th, 2024, 11:36 PM
#1
Thread Starter
Fanatic Member
Help required with SQLite syntax (attached db)
Code:
Dim cOld As cConnection
Set cOld = New cConnection
m_CN.AttachDataBase "D:\backup.db", "old"
m_CN.Execute "UPDATE main.stuff SET " & _
"main.resultsfrombatchaligner=old.resultsfrombatchaligner," & _
"main.acatranscriptionforbatchaligner=old.acatranscriptionforbatchaligner," & _
"main.f0text=old.f0text," & _
"main.pmtext=old.pmtext " & _
"WHERE main.rowid=old.rowid"
Debug.Assert m_CN.AffectedRows > 0
m_CN.DetachDataBase "old"
I am getting the error "Cannot compile SQL-Statement: near ".": syntax error".
What I want to do it restore the value of the columns resultsfrombatchaligner, acatranscriptionforbatchaligner, f0text and pmtext as I had accidentally set them to ''.
No other harm was done to the db, so I wanted to just restore these values using an older backup db.
Thank you for any help as I don't see my mistake.
Thank you.
Last edited by tmighty2; May 11th, 2024 at 10:36 AM.
-
May 10th, 2024, 11:50 PM
#2
Re: Help required with SQLite syntax (attached db)
You have to take care with the explicit naming of columns.
The prefixed namespaces "main" and "old" refer to DBs (not Tables).
A full name-referenc to a column needs to be given via DBName.TableName.ColumnName -
and not (as currently) DBName.ColumnName.
Olaf
-
May 11th, 2024, 01:16 AM
#3
Re: Help required with SQLite syntax (attached db)
Thread moved from VB6 CodeBank, which is for sharing working VB6 code snippets, to the Database Development forum.
-
May 11th, 2024, 10:36 AM
#4
Thread Starter
Fanatic Member
Re: Help required with SQLite syntax (attached db)
Olaf, thank you, but the error message does not go away even with this code:
Dim cOld As cConnection
Set cOld = New cConnection
m_CN.AttachDataBase "D:\backup.db", "old"
m_CN.Execute "UPDATE main.stuff SET " & _
"main.stuff.resultsfrombatchaligner=old.stuff.resultsfrombatchaligner," & _
"main.stuff.acatranscriptionforbatchaligner=old.stuff.acatranscriptionforbatchaligner," & _
"main.stuff.f0text=old.stuff.f0text," & _
"main.stuff.pmtext=old.stuff.pmtext " & _
" WHERE main.stuff.rowid=old.stuff.rowid"
Debug.Assert m_CN.AffectedRows > 0
m_CN.DetachDataBase "old"
-
May 12th, 2024, 04:49 AM
#5
Re: Help required with SQLite syntax (attached db)
Remove all main. Including the dot
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
May 12th, 2024, 12:19 PM
#6
Thread Starter
Fanatic Member
Re: Help required with SQLite syntax (attached db)
Thank you, but that doesn't work either.
-
May 12th, 2024, 02:18 PM
#7
Re: Help required with SQLite syntax (attached db)
Does the query work in a SQLite-client, e.g. DB Browser for SQLite?
Last edited by Zvoni; Tomorrow at 31:69 PM.
----------------------------------------------------------------------------------------
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------------------
People call me crazy because i'm jumping out of perfectly fine airplanes.
---------------------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad
-
May 12th, 2024, 09:58 PM
#8
Re: Help required with SQLite syntax (attached db)
Is this SQL part of a TRIGGER? If so, try changing the "main." to "new.". If that doesn't work, please post a minimally reproducible code sample for us to work with.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|