Page 1 sur 1
AddTrack - Error executing SQL statement "COMMIT"
Publié : ven. avr. 24, 2009 6:16 am
par palmernet
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
Re: AddTrack - Error executing SQL statement "COMMIT"
Publié : ven. avr. 24, 2009 8:59 pm
par palmernet
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"
Publié : sam. avr. 25, 2009 2:39 am
par Bex
Hi palmernet,
If you post the code it's easier to understand the problem and help!
Re: AddTrack - Error executing SQL statement "COMMIT"
Publié : mer. avr. 29, 2009 6:12 am
par palmernet
Bex a écrit :Hi palmernet,
If you post the code it's easier to understand the problem and help!
The line which throws an error is
Call list.AddTrack(MyTracks.Item)
The full script is:
Code : Tout sélectionner
'
' 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 Sub
Re: AddTrack - Error executing SQL statement "COMMIT"
Publié : jeu. avr. 30, 2009 3:10 am
par Bex
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"
Publié : jeu. avr. 30, 2009 9:23 pm
par palmernet
Bex a écrit :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
thanks - is it a commit or ForceCommit I need?
Re: AddTrack - Error executing SQL statement "COMMIT"
Publié : ven. mai 01, 2009 3:26 am
par Bex
I only use Commit.
Re: AddTrack - Error executing SQL statement "COMMIT"
Publié : ven. mai 01, 2009 5:53 am
par palmernet
Bex a écrit :I only use Commit.
Great - putting a commit after the first SQL call.
It's a bit of a work around, but it works.