Jump to content
mr.wallstrom

@Variable@ not expanding correctly into scripted SQL query?

Recommended Posts

If I set my script line to manually:

SELECT ComputerId FROM `plugin_vm_hvhosts` WHERE fqdn = 'hostname.domainname.xyz';

But then replace the FQDN with a variable that contains exactly the same FQDN (pulled from powershell command, that pulls it from registry,) the SQL query fails.

SELECT ComputerId FROM `plugin_vm_hvhosts` WHERE fqdn = '@VMHostFQDN@';

Note, that the SQL query with written out FQDN works fine in SQLYog as well - so I know the query is OK.  I am suspecting maybe something like where the documentation says you must use @= instead of @?

It's driving me nuts, because @VMHostFQDN@ = 'hostname.domainname.xyz' !!

(This whole thing goes around your elbow ... because I'm trying to capture the VM HOST of a Guest.  There will be a monitor that runs on the GUEST, but triggers a script that must run partially on the HOST - powershell commands - to restart said GUEST.)  I have captured the Host's name, FQDN and if this gets working, the computerID, into EDF fields - so that it can function as an offline script when the GUEST is offline...

Share this post


Link to post
Share on other sites

I find it helpful to set the query to run into a variable, like @SQLQUERY@. Then you can "Script Log" @SQLQUERY@ to confirm how it is actually being represented, and then SQL EXECUTE [@SQLQUERY@]  ... (Or SQL Get Value, or Variable Set: SQL Query, etc..)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×