i want to list all Oracle clients installed in my corporate computers.
query 1: q: if exists key "HKEY_LOCAL_MACHINE\SOFTWARE\Oracle" of registry then names of keys of key "HKEY_LOCAL_MACHINE\SOFTWARE\Oracle" of registry else "Oracle clients not installed" A: JInitiator
query 2: q: if exists key "HKEY_LOCAL_MACHINE\SOFTWARE\Oracle" of native registry then names of keys of key "HKEY_LOCAL_MACHINE\SOFTWARE\Oracle" of native registry else "Oracle clients not installed" A: JavaDeploy
how can i query for the same product under both native and 32 bit registry branches?
The difference is, my version works on both 32bit and 64bit systems, while the singular version will throw an error on 32bit systems.
This should be what you need:
unique values of names of keys of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Oracle" of (x32 registries;x64 registries)
The IF/THEN/ELSE isnât required if all of the relevance is pluralized. It is more efficient in this form.
As a general rule, always use plural relevance. (except in cases where singular relevance is required⌠and even then there are workarounds to use plural relevance in most cases)
Just out of curiousity, why will mine give an error?
Because if I use the software distribution of BigFix and I look at the relevance generated from the msi (and so from BigFix), I see the following:
whose ( value "DisplayVersion" of it as string as
version >= "2.2.4.5570" as
version AND value "Language" of
it as
string = "1033") of keys
"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
of ( x32 registry; (if exists x64 registry then x64 registry else nothing)
The use of singuler (x32 registry; x64 registry) will thow an error on 32-bit systems where âx64 registryâ does not exist (the error will be something along the lines of âSingular expression refers to a non-existant objectâ.
The autogenerated version you cite uses an if/then/else clause to avoid referencing x64 registry if it does not exist; but @jgstewâs example is simpler to read by using the plural forms. A plural value can refer to 0 instances, as would be the case when âx64 registriesâ is evaluated on a 32-bit system.
It is not intuitive but when you use plural relevance, you are saying there should be 0 or more of these things, but when you use singular relevance, you are saying that there must be exactly 1 of these, no more, no less.
This is why I always use plural relevance. You might write relevance on a computer with a single NIC, but then it will throw errors on those with multiple.
I always like to assume that there will be either 0 or more than 1 of the result, and plural relevance handles 0, 1, or more than 1 result all equally well.
Plural relevance effectively suppresses most errors.