func_odbc.conf.sample 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. ;
  2. ; func_odbc.conf
  3. ;
  4. [general]
  5. ;
  6. ; Asterisk uses separate connections for every database operation.
  7. ; If single_db_connection is enabled then func_odbc will use a single
  8. ; database connection per DSN.
  9. ; This option exists for those who expect that a second func_odbc call
  10. ; works on the same connection. That allows you to do a LAST_INSERT_ID()
  11. ; in a second func_odbc call.
  12. ; Note that you'll need additional dialplan locks for this behaviour to work.
  13. ; There are better ways: using stored procedures/functions instead.
  14. ; This option is enabled by default.
  15. ;single_db_connection=yes
  16. ;
  17. ;
  18. ; Each context is a separately defined function. By convention, all
  19. ; functions are entirely uppercase, so the defined contexts should also
  20. ; be all-uppercase, but there is nothing that enforces this. All functions
  21. ; are case-sensitive, however.
  22. ;
  23. ; For substitution, you have ${ARG1}, ${ARG2} ... ${ARGn}
  24. ; for the arguments to each SQL statement.
  25. ;
  26. ; In addition, for write statements, you have ${VAL1}, ${VAL2} ... ${VALn}
  27. ; parsed, just like arguments, for the values. In addition, if you want the
  28. ; whole value, never mind the parsing, you can get that with ${VALUE}.
  29. ;
  30. ;
  31. ; If you have data which may potentially contain single ticks, you may wish
  32. ; to use the dialplan function SQL_ESC() to escape the data prior to its
  33. ; inclusion in the SQL statement.
  34. ;
  35. ;
  36. ; The following options are available in this configuration file:
  37. ;
  38. ; readhandle A comma-separated list of DSNs (from res_odbc.conf) to use when
  39. ; executing the readsql statement. Each DSN is tried, in
  40. ; succession, until the statement succeeds. You may specify up to
  41. ; 5 DSNs per function class. If not specified, it will default to
  42. ; the value of writehandle or dsn, if specified.
  43. ; writehandle A comma-separated list of DSNs (from res_odbc.conf) to use when
  44. ; executing the writesql statement. The same rules apply as to
  45. ; readhandle. "dsn" is a synonym for "writehandle".
  46. ; readsql The statement to execute when reading from the function class.
  47. ; writesql The statement to execute when writing to the function class.
  48. ; insertsql The statement to execute when writing to the function class
  49. ; succeeds, but initially indicates that 0 rows were affected.
  50. ; prefix Normally, all function classes are prefixed with "ODBC" to keep
  51. ; them uniquely named. You may choose to change this prefix, which
  52. ; may be useful to segregate a collection of certain function
  53. ; classes from others.
  54. ; escapecommas This option may be used to turn off the default behavior of
  55. ; escaping commas which occur within a field. If commas are
  56. ; escaped (the default behavior), then fields containing commas
  57. ; will be treated as a single value when assigning to ARRAY() or
  58. ; HASH(). If commas are not escaped, then values will be separated
  59. ; at the comma within fields. Please note that turning this option
  60. ; off is incompatible with the functionality of HASH().
  61. ; synopsis Appears in the synopsis field for the command
  62. ; 'core show function <function name>'
  63. ; mode This option may be set to 'multirow' to allow the function
  64. ; specified to return more than a single row. However, this
  65. ; changes the way that func_odbc normally works. Instead of the
  66. ; invocation of the function returning a row, it returns an opaque
  67. ; ID, which may be passed to ODBC_FETCH() to return each row in
  68. ; turn. ODBC_FETCH_STATUS returns SUCCESS or FAILURE, to indicate
  69. ; whether any results were stored, and you should call ODBC_Finish
  70. ; on the ID to clean up any remaining results when you are done
  71. ; with the query. Also, the variable ODBCROWS is set initially,
  72. ; which may be used in an iterative fashion to return each row in
  73. ; the result.
  74. ; Please note that multirow queries are isolated to the channel,
  75. ; and rows may not be fetched outside of the channel where the
  76. ; query was initially performed. Additionally, as the results are
  77. ; associated with a channel, mode=multirow is incompatible with
  78. ; the global space.
  79. ; rowlimit Rowlimit limits the total number of rows which can be stored for
  80. ; that query. For mode=multirow, otherwise, func_odbc will
  81. ; attempt to store all rows in the resultset, up to the maximum
  82. ; amount of memory. In normal mode, rowlimit can be set to allow
  83. ; additional rows to be fetched, rather than just the first one.
  84. ; These additional rows can be returned by using the name of the
  85. ; function which was called to retrieve the first row as an
  86. ; argument to ODBC_FETCH().
  87. ; ODBC_SQL - Allow an SQL statement to be built entirely in the dialplan
  88. [SQL]
  89. dsn=mysql1
  90. readsql=${ARG1}
  91. ; ODBC_ANTIGF - A blacklist.
  92. [ANTIGF]
  93. dsn=mysql1,mysql2 ; Use mysql1 as the primary handle, but fall back to mysql2
  94. ; if mysql1 is down. Supports up to 5 comma-separated
  95. ; DSNs. "dsn" may also be specified as "readhandle" and
  96. ; "writehandle", if it is important to separate reads and
  97. ; writes to different databases.
  98. readsql=SELECT COUNT(*) FROM exgirlfriends WHERE callerid='${SQL_ESC(${ARG1})}'
  99. syntax=<callerid>
  100. synopsis=Check if a specified callerid is contained in the ex-gf database
  101. ; ODBC_PRESENCE - Retrieve and update presence
  102. [PRESENCE]
  103. dsn=mysql1
  104. readsql=SELECT location FROM presence WHERE id='${SQL_ESC(${ARG1})}'
  105. writesql=UPDATE presence SET location='${SQL_ESC(${VAL1})}' WHERE id='${SQL_ESC(${ARG1})}'