[Help]ExtensionState

Hi,
Is anyone successfully use the ExtensionState command in asterisk manager? I would like to get the extension status to a variable and using this I want to update my Database.How we can use ExtensionState command for this. Please help me out.
Thanks in advance,
ijb