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.
Sql query dynamic table name
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
Usually, error message tells the reason of the problem.Unfortunately I get an error when trying this.
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%');
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).
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).
-
- Posts: 2832
- Joined: Tue May 16, 2006 4:41 am
- Contact:
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.
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.