Example LUA script that should work on w2012 and MSSQL:
----------------
-- Do you want also the informational messages
debug=0
-- Open MSSQL DB and check rc
rc = database.open ("Driver={SQL Server}; Server=bgbulab57; Database=CA_UIM; Uid=sa; Pwd=??????;")
if rc == 0
then
if debug == 1
then
printf ("Open db CA_UIM ok, rc:%d",rc)
end
else
printf ("Open db CA_UIM NOK, rc:%d",rc)
end
-- Get rows from table
--rs,rc = database.query("SELECT r.robot_id,robot, r.ip, p.probe_name,p.pkg_version, p.probe_status FROM cm_nimbus_robot r, cm_nimbus_probe p where r.robot_id = p.robot_id order by robot, probe_name")
rs,rc = database.query("SELECT robot,ip FROM cm_nimbus_robot")
if rc == 0
then
if debug == 1
then
printf ("Select DB ok, rc:%d #rows: %d",rc,#rs)
end
else
printf ("Select DB NOK, rc:%d",rc)
end
-- print info of row 1 directly
printf ("xxx robot:%s, ip:%s",rs[1].robot,rs[1].ip)
vara=rs[1].robot
printf ("yyy robot saved: %s",vara)
-- Loop in return of sql
for i=1,#rs do
printf ("%02d robot:%s, ip:%s",i,rs[i].robot,rs[i].ip)
end
-- Close db
database.close()
Original Message:
Sent: 08-13-2019 07:38 AM
From: Vishwanathan Rangaswamy
Subject: DB connection error on NAS profile Script
UIM 9.0.2 is installed on a cloud server with the windows Server 2012 OS.
I have created a ODBC datasource on the server and the test is successful. But when I try the same on the NAS probe, it fails.
Is it possible to use the datasource on the database.open()?, as the datasource already has the connection details
------------------------------
~Vis
Original Message:
Sent: 08-09-2019 04:02 PM
From: Gene HOWARD
Subject: DB connection error on NAS profile Script
what is the OS type and version on the primary?
The connection string assumes windows and will not work on Linux/unix
------------------------------
Gene Howard
Principal Support Engineer
Broadcom
Original Message:
Sent: 08-09-2019 03:52 PM
From: Vishwanathan Rangaswamy
Subject: DB connection error on NAS profile Script
When I tried to connect to a MS SQL DB from NAS probe Script, it cannot connect to the Database. I know am using the right DB server name, db name, user ID and password, but something am missing here.
I used the below syntax as given in the communities, https://ca-broadcom.wolkenservicedesk.com/external/article?articleId=46250
database.open ("Driver={SQL Server}; Server=servername; Database=database; Uid=username; Pwd=password;")
Do I need to install any driver here? I don't see any log except saying the "Error : Unable to open the Database".
Any help on this would be appreciated! Thanks!
------------------------------
~Vis
------------------------------