Upgrade 3CX to v18 and get it hosted free!

Asterisk PGSQL

Author image

NOTE

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

Synopsis

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.

Examples

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


Article Reviews

Write a Review

Your email address will not be published. Required fields are marked *

Required Field. Minimum 5 characters.

Required Field. Minimum 5 characters, maximum 50.

Required field.There is an error with this field.

Required Field.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

There are no reviews for this article. Be the first one to write a review.

Related Posts:

Get 3CX - Absolutely Free!
Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.