'How to get the parameter value and assign to agent in source block

I have an agent with parameters AccountNo, start date,end_date ,Value,type_of_account,cycle_time. For AccountNo I have created a custom distribution based on the actual data. So when an agent is generated at source block it will be assigned an AccountNo value. Now before agent leaves source block i want to update other parameter from the SQL table SQL table has AccountNo , Value,type_of_account, Cycle_time fields. On exit at source I want to update the agent parameters as below:

  1. agent.start_date=date()
  2. agent.end_date= agent.start_date+ cycle_time (from SQL table for same agent based on same account no)
  3. agent.type_of_acount=type_of_account (from sql table with corresponding value based on same account No) How I can assign the parameter values from SQL table? I tried writing query to get the value from db.

.

 ((MyAgent1)agent).start_time=date();

  double a= ((MyAgent1)agent).actno;

  double b = selectFirstValue(false, double.class, "SELECT cycle_time FROM sheet1 WHERE actno = a;");

It is throwing error

user lacks privilege or object not found

is there a good way to update parameter values ?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source