Author Topic: dispatching a database message and using the results  (Read 11682 times)

billsimon

  • Newbie
  • *
  • Posts: 8
    • View Profile
dispatching a database message and using the results
« on: March 16, 2015, 08:56:02 PM »
If I dispatch a database message from regexroute, e.g.

^1$=dispatch database;account=something;query=SELECT ...;results=true

how do I get the SELECT results out of the message answer?

Monica Tepelus

  • Administrator
  • Full Member
  • *****
  • Posts: 198
    • View Profile
Re: dispatching a database message and using the results
« Reply #1 on: March 17, 2015, 02:40:51 AM »
Hi,

You can't do that from regexroute. Try using Javascript instead:

http://docs.yate.ro/wiki/How_to_access_a_database_from_Yate%27s_Javascript_module

billsimon

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: dispatching a database message and using the results
« Reply #2 on: March 17, 2015, 06:01:03 AM »
Thank you Monica. I am doing everything else with register.conf and regexroute and hate to load Javascript just for this. Does Javascript perform better than register or regexroute? If so I may try to convert my logic.

Monica Tepelus

  • Administrator
  • Full Member
  • *****
  • Posts: 198
    • View Profile
Re: dispatching a database message and using the results
« Reply #3 on: March 18, 2015, 05:54:39 AM »
It's not about what performs better it's about finding the right tool for a specific action :).
Getting results from a SELECT implies a very custom feature and this is usually implemented in javascript or from an external module.

If you can do this from register.conf then use it, otherwise you will need a piece of scripting. The power of Yate lies in the fact that you can mix existing modules and custom scripting.

billsimon

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: dispatching a database message and using the results
« Reply #4 on: March 18, 2015, 08:03:08 AM »
Thanks for your advice. For this specific routing need I was not able to do it with the register module but accomplished it fine with Javascript.