Sql query dynamic table name

All questions related to installations, configurations and maintenance of Advanced Host Monitor (including additional tools such as RMA for Windows, RMA Manager, Web Servie, RCC).
Post Reply
otip
Posts: 9
Joined: Tue Sep 10, 2013 1:28 am

Sql query dynamic table name

Post by otip »

Hello,

%fvar_clientname% is a variable defined on the folder /root/client/ of the folder tree. I have tested it and this variable is working correctly.

I would like to use it to define in which table write the logs.

I have written this SQL query :

Insert into '%fvar_clientname%' (eventtime, testname, status, reply, testid, testmethod, foldername, FullFolderPath) VALUES ('%DateTime%','%TestName%', '%Status%', '%Reply%', %TestID%, '%TestMethod%','%fvar_clientname% ','%FullPath%')

Unfortunately I get an error when trying this.

Is what I want to do possible?

thanks.
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

Unfortunately I get an error when trying this.
Usually, error message tells the reason of the problem.
What exactly error is logged into system log?

Looks like you need to remove quotes near %fvar_clientname%:
Insert into %fvar_clientname% (eventtime, testname, status, reply, testid, testmethod, foldername, FullFolderPath) VALUES ('%DateTime%','%TestName%', '%Status%', '%Reply%', %TestID%, '%TestMethod%','%fvar_clientname% ','%FullPath%');
otip
Posts: 9
Joined: Tue Sep 10, 2013 1:28 am

Post by otip »

I should have tell that I have tried without the quotes.

Without the quotes the error message is : incorrect syntaxe near '%fvar_clientname%'
With the quote the error message is : incorrect syntaxe near '%'

system log :
9/26/2013 4:48:26 PM Primary log error. ODBC error code: 4294967295 ([Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'client1') Logging initiated by "Free space: local on localhost" test.
9/26/2013 4:48:26 PM Primary log error. ODBC error code: 4294967295 ([Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near '%fvar_clientname%') Logging initiated by "173.194.35.1" test.
9/26/2013 4:48:26 PM Primary log error. ODBC error code: 4294967295 ([Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'client1') Logging initiated by "Ping: 173.194.35.7" test.
9/26/2013 4:48:26 PM More than 8 consecutive log errors occured. Primary logging paused for 5 min (use Options dialog to resume logging manually).
9/26/2013 4:48:36 PM More than 8 consecutive log errors occured. Primary logging paused for 5 min (use Options dialog to resume logging manually).
KS-Soft Europe
Posts: 2832
Joined: Tue May 16, 2006 4:41 am
Contact:

Post by KS-Soft Europe »

As you can see from your log, HostMonitor correctly parsed %fvar_clientname% variable for test item, located in folder with %fvar_clientname%==client1
While test items, located in folders without %fvar_clientname% specified cause SQL errors.

You need to set %fvar_clientname% variable for all folders and create tables for all clients.
Post Reply