Asterisk PGSQL


This function is not available in asterisk. Either use ODBC or write this funtion.


Do several SQLy things :-)

Syntax (Asterisk 1.2)

PGSQL(Connect var option-string)

Connects to a database. Option string contains standard PostgreSQL parameters like host=, dbname=, user=. Connection identifer returned in ${var}

PGSQL(Query var ${connection_identifier} query-string)

Executes standard SQL query contained in query-string using established connection identified by ${connection_identifier}. Reseult of query is is stored in ${var}.

PGSQL(Fetch statusvar ${result_identifier} var1 var2 ... varn)

Fetches a single row from a result set contained in ${result_identifier}. Assigns returned fields to ${var1} ... ${varn}. ${statusvar} is set TRUE if additional rows exist in reseult set.

PGSQL(Clear ${result_identifier})

Frees memory and datastructures associated with result set.

PGSQL(Disconnect ${connection_identifier})

Disconnects from named connection to PostgreSQL.


exten => s,2,PGSQL(Connect connid host=localhost user=asterisk dbname=credit)
exten => s,3,PGSQL(Query resultid ${connid} SELECT username,credit FROM credit WHERE callerid=${CALLERIDNUM})
exten => s,4,PGSQL(Fetch fetchid ${resultid} datavar1 datavar2)
exten => s,5,GotoIf(${fetchid}?6:8)
exten => s,6,Festival("User ${datavar1} currently has credit balance of ${datavar2} dollars.")
exten => s,7,Goto(s,4)
exten => s,8,PGSQL(Clear ${resultid})
exten => s,9,PGSQL(Disconnect ${connid})

See also

Created by: JustRumours, Last modification: Mon 21 of Mar, 2011 (18:15 UTC) by millsu2
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+