![]() ![]() I have attached a pic that may shed light on the end use. I think the code supplied by Andreik in post #3 will work better as the column will be incremented before the new record is added and I shouldn't need to run the code each time as the DB will take care of it with the trigger. The process would be to query if the number (7) was available, If not run the code below to increment the numbers (7 +) in the table up one to allow insertion. If the user selects 5, all is well but if number 7 is entered into the drop down, A prompt will feedback that that number is taken and offer to insert the selected setup program, thus pushing number 7 to 8 and so on. The idea is to get a list of the numbers that are already used and create a list of available numbers in a drop down list. As I have already got a number 8 and the column entries are set to be unique there will be a conflict. If I have 10 apps, install order 1 to 10 and I decide to add another that needs to be at number 8. The idea is I'll add a program to the list and select an integer that determines when it is installed in the whole sequence once the list is sorted. Some programs or updates may need to be installed before others so I have the InstallOrder column (used to be sorted in an array when using the inis). As I had some spare time (which disappears when I open AutoIt), I thought I would combine them into a datbase with a gui front end to add records. I used to use ini files to store the information about the installers for a bunch of programs that install unattendedly. ![]() The SQL string might be utter tosh from the ON CONFLICT part but prior to that it works.įunc _DB _InsertApp ( $s_Installer, $s_Switches, $i_Order, $s_Icon, $s_Name, $s_Version, $s_Description, $s_Users ) Local $s_SQL = "INSERT INTO Apps VALUES (NULL," & _ _SQLite _FastEscape ( $s_Installer ) & "," & _ _SQLite _FastEscape ( $s_Switches ) & "," & _ Number ( $i_Order ) & "," & _ _SQLite _FastEscape ( $s_Icon ) & "," & _ _SQLite _FastEscape ( $s_Name ) & "," & _ _SQLite _FastEscape ( $s_Version ) & "," & _ _SQLite _FastEscape ( $s_Description ) & "," & _ _SQLite _FastEscape ( $s_Users ) & ") ON CONFLICT(INSTALLORDER) DO UPDATE Apps SET InstallOrder=InstallOrder+1 WHERE InstallOrder>=" & Number ( $i_Order ) & " " If _SQLite _Exec ( - 1, $s_SQL ) = $SQLITE_OK Then Return Return SetError (, , _SQLite _ErrMsg ( ) ) EndFunc =>_DB_InsertApp The autoit function is shaping up like this. Still a beginner with SQLite so it may not be possible. Either adding code to the sql string or a clause in the DB. I just need to know if there is anywhere this code can be run from. The 1 will be replaced by the variable value entered for the InstallOrder. UPDATE 'Apps' SET InstallOrder = Installorder + 1 WHERE InstallOrder >= 1 I have been playing around with the DB in SQLite Expert and using the code below, I can update the values as I want. This is not a primary key or auto incremented. I have set the "InstallOrder" column to contain unique values (integers) and I am tring to work out how to auto increment when conflicting values are inserted into the DB. One of the options is an Install Order which determines the order of installation. I am creating a database to use with an installer (I'm rewriting to remove the reliance on ini files) created in AutoIt that allows for various programs to be installed unattendedly. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |