SQL-Scripting
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
SQL-Scripting
I would like to fill the Custom fields automatically from other fields in the database. I know SQL very well, but I don't get the starting point how to do it within Mediamonkey with a script. Where would I be supposed to look for documentation about that topic?
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
There is no setting in MM that scripts can run at startup. I believe it has been requested.
Download MediaMonkey | License
Help: Knowledge Base | MediaMonkey for Windows 5 | MediaMonkey for Android
Lowlander (MediaMonkey user since 2003)
Help: Knowledge Base | MediaMonkey for Windows 5 | MediaMonkey for Android
Lowlander (MediaMonkey user since 2003)
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
You can try queries in whatever programming language you are using. Just check the results if they are what was expected.
If you are going to work with queries that modify things in the DB you should backup the DB in case something goes wrong.
The easiest way of creating queries for me is using Access query wizard and than copy the SQL code afterwards (don't use the query in the DB in code as that is not part of other users DBs). Just make sure you define the relationships between tables when writing queries.
And generally programming software give errors when mistakes are made in the query.
If you are going to work with queries that modify things in the DB you should backup the DB in case something goes wrong.
The easiest way of creating queries for me is using Access query wizard and than copy the SQL code afterwards (don't use the query in the DB in code as that is not part of other users DBs). Just make sure you define the relationships between tables when writing queries.
And generally programming software give errors when mistakes are made in the query.
Download MediaMonkey | License
Help: Knowledge Base | MediaMonkey for Windows 5 | MediaMonkey for Android
Lowlander (MediaMonkey user since 2003)
Help: Knowledge Base | MediaMonkey for Windows 5 | MediaMonkey for Android
Lowlander (MediaMonkey user since 2003)
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
Ok, I managed to write a really easy script that simply runs an Update-SQL on the database. Thanks a lot!
But still I'm not happy: My plan was to make (numerical) categories (0..3 meaning NEVER..OFTEN) from the PLAYED#-values into the CUSTOM1 field. This works fine with the following SQL:
I then wanted to put a sorting on that CUSTOM1 field into my auto-playlists, but unfortunately it is not possible to sort on the custom-fields.
Any ideas?
But still I'm not happy: My plan was to make (numerical) categories (0..3 meaning NEVER..OFTEN) from the PLAYED#-values into the CUSTOM1 field. This works fine with the following SQL:
Code: Select all
Sub SetCUSTOM1
'Update CUSTOM1
SDB.Database.ExecSQL("UPDATE Songs SET Custom1 = IIf([PlayCounter] =0 , 0 , IIf([PlayCounter] <3 , 1 , IIf([PlayCounter]<10 , 2 , 3 ) ) );")
End Sub
Any ideas?
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
Another question: is it possible to put the query into a separate file? Something like:
Code: Select all
SDB.Database.ExecSQL(query.sql)
- Sorting by Custom fields will be possible in the next release.
- You can have the query in a separate file, but you would have to open it somehow (FileSystem object could do it - see VBScript reference at http://www.microsoft.com/scripting and Export.vbs for examples).
Jiri
- You can have the query in a separate file, but you would have to open it somehow (FileSystem object could do it - see VBScript reference at http://www.microsoft.com/scripting and Export.vbs for examples).
Jiri
One way would be to run your query, make sure your custom field is visible & click on it's header to sort by that field. It will give you some functionality until the next version.hurrlipurr wrote:Ok, I managed to write a really easy script that simply runs an Update-SQL on the database. Thanks a lot!
But still I'm not happy: My plan was to make (numerical) categories (0..3 meaning NEVER..OFTEN) from the PLAYED#-values into the CUSTOM1 field. This works fine with the following SQL:
I then wanted to put a sorting on that CUSTOM1 field into my auto-playlists, but unfortunately it is not possible to sort on the custom-fields.Code: Select all
Sub SetCUSTOM1 'Update CUSTOM1 SDB.Database.ExecSQL("UPDATE Songs SET Custom1 = IIf([PlayCounter] =0 , 0 , IIf([PlayCounter] <3 , 1 , IIf([PlayCounter]<10 , 2 , 3 ) ) );") End Sub
Any ideas?
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
Autostart scripts on events
I read something about beta-support for running scripts based on events in 2.2.2. Is there a possibility to run scripts on MM start up right now?jiri wrote:As for running script on some events (e.g. MM start up), the next release will have a number of new scripting related features and this is one of them. You'll also be able to add new tree nodes, etc. All developers, get ready!
Greetings
hurrlipurr
-
- Posts: 26
- Joined: Tue Jul 06, 2004 2:49 pm
- Location: Germany
I tried this likejiri wrote:Btw, check 'scripting' topic in the MM.chm help file, it's possible even now to run a script on start of playback.
Code: Select all
[SetCustom1]
FileName=SetCUSTOM1.vbs
ProcName=SetCUSTOM1
Order=5
DisplayName=Set CUSTOM1
Description=Group Played# into CUSTOM1
Language=VBScript
ScriptType=2