View Issue Details

IDProjectCategoryView StatusLast Update
0011448MMW v4Framework: Scripts/Extensionspublic2013-11-04 15:16
Reporterzvezdan Assigned To 
PrioritynoneSeverityfeatureReproducibilityN/A
Status newResolutionopen 
Summary0011448: ISDBDatabase::CustomQuerySongs method needed
DescriptionWith the existing QuerySongs we could get SDBSongIterator object by specifying a condition part of some SQL statement. However, sometimes it is desirable to get a list of files using full SQL statement, e.g. because it is composed from several tables, not only Songs.

Something similar to that we already have with the SDBTracksWindow object which have two methods for those two approaches - with AddTracksFromQuery we could fill the filelist using a condition part of SQL statement, and with AddTracksFromCustomQuery we could fill the filelist using full SQL statement.

Currently, to be able to get list of SongData objects using full SQL statement I need to use something like this:

    sFullQuery = "SELECT Songs.ID FROM Songs INNER JOIN Medias ON Songs.IDMedia = Medias.IDMedia WHERE some_thing"
    Set oDbIter = SDB.Database.OpenSQL(sFullQuery)
    Do While Not oDbIter.EOF
        sWherePart = "Songs.ID = " & oDbIter.ValueByIndex(0)
        If SDB.VersionHi < 3 Then sWherePart = "AND " & sWherePart
        Set oSongIter = SDB.Database.QuerySongs(sWherePart)
        If Not oSongIter.EOF Then
            oSongList.Add oSongIter.Item
        End If
        Set oSongIter = Nothing
        oDbIter.Next
    Loop
    Set oDbIter = Nothing

However, with such code I have two iterators, one inside another, and I am afraid it could raise some errors because of the database locking. Another alternative is to use some temporary array for storing Songs.IDs inside of the first database iterator (oDbIter) and to use the second song iterator (oSongIter) outside of it, i.e. after Set oDbIter = Nothing, but all of that is too complicated for something that should be easier for scripters.
TagsNo tags attached.
Fixed in build

Activities

There are no notes attached to this issue.