Debian Codegraph @

configs/samples/func_odbc.conf.sample

raw
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 disabled by default.
15 ;single_db_connection=no
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 ; Additionally you can use ${ARGC} to determine the number of arguments that
27 ; was actually passed (or risk using leaked ARGn variables from the channel).
28 ; Also reference the minargs configuration option.
29 ;
30 ; In addition, for write statements, you have ${VAL1}, ${VAL2} ... ${VALn}
31 ; parsed, just like arguments, for the values. In addition, if you want the
32 ; whole value, never mind the parsing, you can get that with ${VALUE}.
33 ;
34 ;
35 ; If you have data which may potentially contain single ticks, you may wish
36 ; to use the dialplan function SQL_ESC() to escape the data prior to its
37 ; inclusion in the SQL statement.
38 ;
39 ; If you have data which may potentially contain backslashes, you may wish to
40 ; use the dialplan function SQL_ESC_BACKSLASHES() to escape the backslashes.
41 ; Note that not all databases may require escaping of the backslashes.
42 ;
43 ;
44 ; The following options are available in this configuration file:
45 ;
46 ; dsn An alias for "writehandle."
47 ; readhandle A comma-separated list of DSNs (from res_odbc.conf) to use when
48 ; executing the readsql statement. Each DSN is tried, in
49 ; succession, until the statement succeeds. You may specify up to
50 ; 5 DSNs per function class. If not specified, it will default to
51 ; the value of "writehandle" or "dsn," if specified.
52 ; writehandle A comma-separated list of DSNs (from res_odbc.conf) to use when
53 ; executing the writesql statement. The same rules apply as to
54 ; readhandle.
55 ; readsql The statement to execute when reading from the function class.
56 ; writesql The statement to execute when writing to the function class.
57 ; insertsql The statement to execute when writing to the function class
58 ; succeeds, but initially indicates that 0 rows were affected.
59 ; prefix Normally, all function classes are prefixed with "ODBC" to keep
60 ; them uniquely named. You may choose to change this prefix, which
61 ; may be useful to segregate a collection of certain function
62 ; classes from others.
63 ; escapecommas This option may be used to turn off the default behavior of
64 ; escaping commas which occur within a field. If commas are
65 ; escaped (the default behavior), then fields containing commas
66 ; will be treated as a single value when assigning to ARRAY() or
67 ; HASH(). If commas are not escaped, then values will be separated
68 ; at the comma within fields. Please note that turning this option
69 ; off is incompatible with the functionality of HASH().
70 ; synopsis Appears in the synopsis field for the command
71 ; 'core show function <function name>'
72 ; syntax Appears in the syntax field for the command
73 ; 'core show function <function name>'
74 ; mode This option may be set to 'multirow' to allow the function
75 ; specified to return more than a single row. However, this
76 ; changes the way that func_odbc normally works. Instead of the
77 ; invocation of the function returning a row, it returns an opaque
78 ; ID, which may be passed to ODBC_FETCH() to return each row in
79 ; turn. ODBC_FETCH_STATUS returns SUCCESS or FAILURE, to indicate
80 ; whether any results were stored, and you should call ODBC_Finish
81 ; on the ID to clean up any remaining results when you are done
82 ; with the query. Also, the variable ODBCROWS is set initially,
83 ; which may be used in an iterative fashion to return each row in
84 ; the result.
85 ; Please note that multirow queries are isolated to the channel,
86 ; and rows may not be fetched outside of the channel where the
87 ; query was initially performed. Additionally, as the results are
88 ; associated with a channel, mode=multirow is incompatible with
89 ; the global space.
90 ; rowlimit Rowlimit limits the total number of rows which can be stored for
91 ; that query. For mode=multirow, otherwise, func_odbc will
92 ; attempt to store all rows in the resultset, up to the maximum
93 ; amount of memory. In normal mode, rowlimit can be set to allow
94 ; additional rows to be fetched, rather than just the first one.
95 ; These additional rows can be returned by using the name of the
96 ; function which was called to retrieve the first row as an
97 ; argument to ODBC_FETCH().
98 ; minargs The minimum number of ARGUMENTS that has to be passed to the
99 ; function. If fewer arguments than this is passed, then the call
100 ; will fail. It is important to note that unlike Gosub() and friends,
101 ; func_odbc will not mask out ARGn variables that it's not actively
102 ; using, as such, without this, it's entirely possible to use say
103 ; ARG2 from the Gosub() inside func_odbc when the intent was to
104 ; use an argument passed to func_odbc, but it simply was never passed.
105
106
107 ; ODBC_SQL - Allow an SQL statement to be built entirely in the dialplan
108 [SQL]
109 writehandle=mysql1
110 readsql=${ARG1}
111
112 ; ODBC_ANTISOLICIT - A blacklist for known solicitors.
113 [ANTISOLICIT]
114 dsn=mysql1,mysql2 ; Use mysql1 as the primary handle, but fall back to mysql2
115 ; if mysql1 is down. Supports up to 5 comma-separated
116 ; DSNs. "dsn" may also be specified as "readhandle" and
117 ; "writehandle", if it is important to separate reads and
118 ; writes to different databases.
119 readsql=SELECT COUNT(*) FROM known_solicitors WHERE callerid='${SQL_ESC(${ARG1})}'
120 syntax=<callerid>
121 synopsis=Check if a specified callerid is contained in the known solicitors database
122
123 ; ODBC_PRESENCE - Retrieve and update presence
124 [PRESENCE]
125 writehandle=mysql1
126 readsql=SELECT location FROM presence WHERE id='${SQL_ESC(${ARG1})}'
127 writesql=UPDATE presence SET location='${SQL_ESC(${VAL1})}' WHERE id='${SQL_ESC(${ARG1})}'