Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

UPDATE query throws error in selective MSI tables


5 replies to this topic

eelisdotnet

eelisdotnet
  • Members
  • 24 posts

Posted 14 July 2005 - 12:22


The following query returned error 2259: 'Table(s) Update failed'
CODE

Cscript WiRunSQL.vbs Setup.msi "UPDATE `ControlCondition` SET
`ControlCondition`.`Action`='Hide' WHERE
`ControlCondition`.`Dialog_`='FolderForm' AND
`ControlCondition`.`Control_`='AllUsersRadioGroup'"

I tried to run it in several formats (without grave marks or without the
'ControlCondition.' prefix for the column). The same error occured on the
Upgrade table during an attempt to run UPDATE query.
SELECT and DELETE queries on those tables were successfully executed.
Note also that the values were successfully updated by hardcoding in Orca.

Is there any limitations on some MSI tables ?

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 14 July 2005 - 13:40

Again quoting the SQL Syntax help topic:
QUOTE
UPDATE queries only work on nonprimary key columns.

In the ControlCondition table all four columns are key.

eelisdotnet

eelisdotnet
  • Members
  • 24 posts

Posted 14 July 2005 - 14:51

Thanks again Stefan.

How can I run an UPDATE query for those tables/columns ?
Or, is it better to DELETE and INSERT a new record ...



eelisdotnet

eelisdotnet
  • Members
  • 24 posts

Posted 15 July 2005 - 09:27

I tried to run this automation script with the View.Modify method.

CODE

Option Explicit

Const msiOpenDatabaseModeReadOnly = 0
Const msiOpenDatabaseModeTransact = 1

' Connect to Windows Installer object
On Error Resume Next
Dim installer : Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError

' Open database
Dim databasePath : databasePath = Wscript.Arguments(0)
Dim database, openMode, view, record, updateMode
openMode = msiOpenDatabaseModeTransact
Set database = installer.OpenDatabase(databasePath, openMode) : CheckError

Set view = database.OpenView("SELECT `Action` FROM ControlCondition WHERE `Dialog_`='FolderForm' AND `Control_`='AllUsersRadioGroup' AND `Action`='Show'") : CheckError
view.Execute : CheckError
updateMode = msiViewModifyReplace
Set record = view.Fetch : CheckError
If Not record Is Nothing Then
record.StringData(0) =  "Hide" ' update record
view.Modify updateMode, record : CheckError
End If

database.Commit : CheckError
Wscript.Quit 0

Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
 Set errRec = installer.LastErrorRecord
 If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText
End If
Fail message
End Sub

Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub


I keep getting errors like: Microsoft VBScript runtime error 1F4: Variable is undefined.

With a quick debugging I think the error comes from this line:
'Set record = view.Fetch : CheckError'

Can't figure out any undeclared variables...

Zweitze

Zweitze
  • Full Members
  • 522 posts

Posted 15 July 2005 - 14:37

The error probably comes from one line higher - I don't see msiViewModifyReplace being defined anywhere.

BTW Two hints for developing scripts:
1. Comment out any exception handling (On Error Resume Next), that way you'll allow the Windows Scripting Host to identify the line with the error.
2. If you have the Script Debugger installed (comes with Office, VStudio), run using this command:
WScript.exe //x "C:\my first script.vbs" "First param" "Second Param"
Note the //x: it starts your script debugger.
(You can also use CScript.exe, in that case the text of WScript.Echo is forwarded to the console).


eelisdotnet

eelisdotnet
  • Members
  • 24 posts

Posted 18 July 2005 - 12:08

Thanks Zweitze,

somehow I missed the msiViewModifyReplace const declaration... it turned to be the undefined variable of course.

The script debugger is also great in monitoring the code execution. Thanks for the debugging tips as well.

cheers!