When using the AddTrack call, I get an: Error executing SQL statement "COMMIT"
I have seen this error statement elsewhere on the forum, but as I am calling AddTrack, I have no way of debugging what is happening inside the MediaMonkey code to throw the error.
How do I resolve this?
MediaMonkey: 3.0.4.1185
OS: Windows XP SP3
AddTrack - Error executing SQL statement "COMMIT"
Moderators: Gurus, Addon Administrators
Re: AddTrack - Error executing SQL statement "COMMIT"
I have read somewhere this relates to the spead the script runs. Could this be true? Is this a bug? What is the work around?
Re: AddTrack - Error executing SQL statement "COMMIT"
Hi palmernet,
If you post the code it's easier to understand the problem and help!
If you post the code it's easier to understand the problem and help!
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Re: AddTrack - Error executing SQL statement "COMMIT"
The line which throws an error isBex wrote:Hi palmernet,
If you post the code it's easier to understand the problem and help!
Call list.AddTrack(MyTracks.Item)
The full script is:
Code: Select all
'
' MediaMonkey Script
'
' NAME: TextToPlaylist 1.0
'
'Derived from http://www.mediamonkey.com/forum/viewtopic.php?f=2&t=6879&start=0
'
' [TextToPlaylist]
' FileName=TextToPlaylist.vbs
' ProcName=TextToPlaylist
' Order=18
' DisplayName=Combine Albums
' Description=Change album naming conventions
' Language=VBScript
' ScriptType=0
'
Sub TextToPlaylist
'create logfile
Dim wsh : Set wsh = CreateObject("WScript.Shell")
Dim loc : loc = wsh.ExpandEnvironmentStrings("%TEMP%")&"\TextToPlaylist.log"
Set logf = SDB.Tools.FileSystem.CreateTextFile(loc,True)
Call logf.WriteLine("")
res = InputBox ("Enter filename of TxT to import:","Import TXT playlist")
Set progress = SDB.Progress
progress.Text = "Opening: "&res
Set filesys = CreateObject("Scripting.FileSystemObject")
If filesys.FileExists(res) Then
Set file = filesys.OpenTextFile(res, 1, false)
name = filesys.getFileName(res)
name = mid(name,1,len(name)-4)
progress.Text = "Creating playlist: "&name
Set list = SDB.PlaylistByTitle("").CreateChildPlaylist(name)
do while not file.AtEndOfStream
line = file.ReadLine
line = line & vbTab & ""
progress.Text = "Finding: "&line
line_arr = split(line, vbTab)
'Dim sql : sql = ""
'sql = "SELECT Songs.Id FROM Songs WHERE (Songs.artist='"& Trim(Replace(line_arr(1),"'","''")) &"' AND Songs.songtitle='"& Trim(Replace(line_arr(0),"'","''")) &"')"
'Dim qit : Set qit = SDB.Database.OpenSQL(sql)
sql_where = "AND (Songs.artist='"& Trim(Replace(line_arr(1),"'","''")) &"' AND Songs.songtitle='"& Trim(Replace(line_arr(0),"'","''")) &"')"
Set MyTracks = SDB.Database.QuerySongs(sql_where)
l_added = 0
If Not MyTracks.EOF Then
Call list.AddTrack(MyTracks.Item)
'Call list.AddTrackById(qit.StringByIndex(0))
l_added = l_added + 1
progress.text = "Adding: "&line_arr(0)&" ("&l_added&")"
Else
'sql = "SELECT Songs.Id FROM Songs WHERE (Songs.artist like '%' || '"& Trim(Replace(line_arr(1),"'","''")) &"' || '%' AND Songs.songtitle like '%' || '"& Trim(Replace(line_arr(0),"'","''")) &"' || '%')"
'Set qit = SDB.Database.OpenSQL(sql)
sql_where = "AND (Songs.artist like '%' || '"& Trim(Replace(line_arr(1),"'","''")) &"' || '%' AND Songs.songtitle like '%' || '"& Trim(Replace(line_arr(0),"'","''")) &"' || '%')"
Set MyTracks = SDB.Database.QuerySongs(sql_where)
If Not MyTracks.EOF Then
Call list.AddTrack(MyTracks.Item)
'Call list.AddTrackById(qit.StringByIndex(0))
l_added = l_added + 1
progress.text = "Adding: "&line_arr(0)&" ("&l_added&")"
'MyTracks.next
End If
End If
if l_added = 0 then
progress.text = "notfound_SQL: "&sql_where
no_entry = no_entry + " " + "'"&line_arr(0)&", "&line_arr(1)&"'"
logf.WriteLine(line_arr(0)& vbTab &line_arr(1) & vbTab & sql_where)
end if
loop
res = SDB.MessageBox("Entries not found: "&no_entry, mtError, array(mbOK))
progress.Text = "Closing: "&res
file.close
Else
res = SDB.MessageBox("This playlist could not be found", mtError, Array(mbOk))
End If
Set progress = nothing
logf.Close
filesys.Close
End Sub
Sub AddTrack(itm,rel,out)
Dim InAlbum : InAlbum = False
If InStr(itm.Path,rel) = 1 Then
InAlbum = True
End If
If Not(AlbumOnly) Or InAlbum Then
If Debug Then Call logf.WriteLine("---"&itm.Path)
Call out.WriteLine(SDB.toASCII("#EXTINF:"&Left(CStr(itm.SongLength),3)&","&itm.ArtistName&" - "&itm.Title))
If Err.Number <> 0 Then
Call out.WriteLine("#EXTINF:"&itm.ID&" ["&Err.Number&"]")
Err.Clear
End If
If FullPath Then
Call out.WriteLine(itm.Path)
Else
If InAlbum Then
Call out.WriteLine(Replace(itm.Path,rel,""))
Else
Call out.WriteLine(itm.Path)
End If
End If
If Err.Number <> 0 Then
Call out.WriteLine("#"&SDB.toASCII(itm.Path)&" ["&Err.Number&"]")
Err.Clear
End If
Else
If Debug Then Call logf.WriteLine("---(Ignoring track: "&itm.Path&")")
End If
End SubRe: AddTrack - Error executing SQL statement "COMMIT"
I'll see when I get the time to look into this. You can check other scripts and how they use SDB.Database.BeginTransaction/SDB.Database.Commit. That's what I think you need to add to smart places in your script.
http://www.mediamonkey.com/wiki/index.php/SDBDatabase
http://www.mediamonkey.com/wiki/index.php/SDBDatabase
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Re: AddTrack - Error executing SQL statement "COMMIT"
thanks - is it a commit or ForceCommit I need?Bex wrote:I'll see when I get the time to look into this. You can check other scripts and how they use SDB.Database.BeginTransaction/SDB.Database.Commit. That's what I think you need to add to smart places in your script.
http://www.mediamonkey.com/wiki/index.php/SDBDatabase
Re: AddTrack - Error executing SQL statement "COMMIT"
I only use Commit.
Advanced Duplicate Find & Fix Find More From Same - Custom Search. | Transfer PlayStat & Copy-Paste Tags/AlbumArt between any tracks.
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Tagging Inconsistencies Do you think you have your tags in order? Think again...
Play History & Stats Node Like having your Last-FM account stored locally, but more advanced.
Case & Leading Zero Fixer Works on filenames too!
All My Scripts
Re: AddTrack - Error executing SQL statement "COMMIT"
Great - putting a commit after the first SQL call.Bex wrote:I only use Commit.
It's a bit of a work around, but it works.