Information on how to run SQL queries on the CUCM itself please

Good Day All,
I need to run an sql query on the CUCM to list all of my directory numbers, their partition, and their external mask values.
I came across this excerpt below earlier so I have a bit of an idea how to do it but iw would be great to see some other examples of sql queries.
Any assistance is most appreciated.
Also, is there a document somewhere to tell me how to run these queries?
Thanks in advance
Regards
Amanda
Currently Being Moderated
05/04/2011 5:18 AM (in response to Joshua Royle)
Re: Is there a way of pulling a report off CM showing all phones that have diverts on?
Try if running this SQL query from the CLI helps you, it should list all DN's that have CFA enabled to VM or a DN:
run sql select dnorpattern,cfadestination,cfavoicemailenabled from CallForwardDynamic c, numplan n where c.fknumplan = n.pkid and (cfadestination != '' or cfavoicemailenabled ='t')

Hi Amanda
Basically it's standard SQL, so it wouldn't hurt to google 'informix select statements' and do a little reading to get the basics. There are millions of permutations of queries so it's a matter of understanding the syntax, and then applying that to the database in question. The only difference when running commands from the CLI are that:
- You prefix the standard informix SQL statement with 'run sql'
- You don't get any help from CUCM with the syntax, so you might be well advised to use something that understands SQL a little and colorises it as you type, and then paste the resulting commands into the CUCM SSH window. I use a text editor named JEdit, if you create a text file and save it as a file ending in .sql it will highlight your syntax.
- Other programs are available that do reasonable syntax highlighting (e.q. SquirrelSQL) that are designed for querying the DB directly, but you can't actually query directly against the DB for security reasons. You'd still have to copy/paste the commands.
Now... to understand the DB you'll need a reference describing all the tables etc. This is here:
http://www.cisco.com/en/US/products/sw/voicesw/ps556/products_programming_reference_guides_list.html
Pick your version of CUCM and download the 'Data Definition' document.
A few notes on the command:
run sql : is just the CLI command that tells the shell to run the following text as SQL.
select : the SQL command to retrieve data
dnorpattern,cfadestination,cfavoicemailenabled : the column names to retrieve
callforwarddynamic c, numplan n : the names of two tables, and the abbreviations you want to refer to them as
where c.fknumplan = n.pkid : this tells SQL to return values from the two tables where these fields match up. In the data definition you'll see notes that c.fknumplan (i.e. the fknumplan column in the callforwarddynamic table, as noted by the c. prefix) refers to the PKID column in the numplan field. This is a very standard type of join in the CCM DB.
and (cfadestination != '' or cfavoicemailenabled ='t') : another clause, basically in this query we want to see only rows where cfadestination isn't blank or cfavoicefmailenabled is set to 't' for true).
Most tables are linked in one of two ways in this database:
- a column prefixed 'fk' refers to the pkid field (there is always only one pkid field per table) in the table following the 'fk' prefix. E.g. above fknumplan refers to the numplan table, pkid field. fkdevice would refer to the device table, pkid field.
- a column prefiex 'tk' refers usually to an enum table which is prefixed with 'type'. This is a table that maps the number value in the 'tk' field to a string. An example would be tkmodel - this represents the phone physical model type (e.g. 7962), and maps to a table called typemodel, and the 'enum' column in that table.
Regards
Aaron HarrisonPrincipal Engineer at Logicalis UK
Please rate helpful posts...

Similar Messages

  • How to run .sql file in tsql or powershell

    Hi All,
    HOw to run .sql file inside the TSQL or powershell using with IF else condition. This below query works fine but when i executing through the SQL Agent it's geeting an error.Please could help how to run through the SQL agent already using execution type
    in agent as 'Operating system(CmdExec)'
    Declare @computerName varchar(100), @InstanceName varchar(50)                             
    SET @ComputerName = REPLACE(CAST(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS varchar),'\','$')  
    SET @InstanceName = REPLACE(CAST(SERVERPROPERTY('instancename') AS varchar),'\','$')
    IF (@InstanceName = 'SQL2008R2')
    Begin  
    :r C:\BackupFolder\Test1.sql    
    :r C:\BackupFolder\Test2.sql    
    End
    IF (@InstanceName = 'SQLINS2')
    BEGIN
    :r C:\BackupFolder\Test3.sql
    END
    IF (@InstanceName = 'SQL2012')
    BEGIN
    :r C:\BackupFolder\Test4.sql
    END
    Thansk in Advance
    A-ZSQL

    In T-SQL, you can try using sqlcmd to invoke sql file
    if @@SERVERNAME='abcd'
    begin
    Master..xp_cmdshell 'sqlcmd -S <ServerName> -i BackupDetails.sql -E'
    end
    OR 
     PowerShell 
    Load the snapins
    Add-PSSnapin SqlServerCmdletSnapin100
    Add-PSSnapin SqlServerProviderSnapin100
    Function Get-SqlInstances {
    Param($ServerName = '.')
    $localInstances = @()
    [array]$captions = gwmi win32_service -computerName $ServerName | ?{$_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe"} | %{$_.Caption}
    foreach ($caption in $captions) {
    if ($caption -like "MSSQLSERVER") {
    $localInstances += $ServerName
    } else {
    $temp = $caption | %{$_.split(" ")[-1]} | %{$_.trimStart("(")} | %{$_.trimEnd(")")}
    $localInstances += "$ServerName\$temp"
    $localInstances
    $instance=Get-SqlInstances -ServerName HQDBSP17
    foreach($i in $instance)
    if($i -like 'CRM2011')
    write-host 'CRM Database'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    if( $i -like 'SQL2012')
    write-host 'SQL 2012 instance'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    --Prashanth

  • How to run two query  in the same preparedStatement

    Hi all,
    Please tell me how to run two queries in the same preparedStatement object ?
    In my module I have to run two queries and I don't want to make two methods for running two different queries.
    I just want to call this method for both of my queries.
    methodName(long param)
    Connection conn=null;
    PreparedStatement pstmt=null;
    //////////////// some coding
    Please Help !
    Thanks in advance
    amitindia

        public void foo()
            Connection connection = null;
            PreparedStatement stmt = null;
            try {
                connection = ...get from pool...;
                stmt = connection.prepareStatement("...");
                ...fetch results...;
                stmt.close();
                stmt = null; // So the finally statement works if there is an exception
                stmt = connection.prepareStatement("...");
                ...fetch results...;
            } finally {
                if (stmt != null) ..close it...;
                if (connection != null) ..return it to pool...;
        }

  • How to use SQL functions in the queries

    hey guys i wanna know how to use SQL functions in the queries is it possible or not .

    Hi,
    Wat exactly that set values are?
    those from sql query?
    How to use count():
    The COUNT() function returns the number of rows that matches a specified criteria.
    SQL COUNT(column_name) Syntax
    The COUNT(column_name) function returns the number of values (NULL values will not be counted) of the specified column:
    SELECT COUNT(column_name) FROM table_name
    SQL COUNT(*) Syntax
    The COUNT(*) function returns the number of records in a table:
    SELECT COUNT(*) FROM table_name
    SQL COUNT(DISTINCT column_name) Syntax
    The COUNT(DISTINCT column_name) function returns the number of distinct values of the specified column:
    SELECT COUNT(DISTINCT column_name) FROM table_name
    The IN function helps reduce the need to use multiple OR conditions.
    The syntax for the IN function is:
    SELECT columns
    FROM tables
    WHERE column1 in (value1, value2, .... value_n);

  • Long Running SQL Queries

    We have a customer that runs our Crystal Reports and they have complained that some of the reports cause long running sql queries and they have to kill these queries manually from SQL Management tools. We have changed the code so that we now dispose the report source and viewer objects as we call .dispose() function on them;
    reportSource.dispose();
    viewer.dispose();
    At first this seemed work but customer later complained that the issue still occurs. Can anyone help with why some of these CR queries are still running way after report is generated (with correct set of data), and based on the customer some of them running for more than 2 hours? What else can we do to make sure that all CR related queries cease to exist once report is generated? Appreciate all the help.

    1. Run the report from with Crystal designer. You should see the query being sent to DB server. After the report is viewed and you close it in designer, do you see the DB connection being dropped? If not, this may not be a SDK\ API related issue.
    2. Try using latest set of CRJ Jars [here|http://downloads.businessobjects.com/akdlm/crystalreportsforeclipse/2_0/crjava-runtime_12.2.213.zip] in your application. Also update the crystalreportviewers folder with the new viewer found at this link.
    3. Make sure that you are calling reportClientDocument.close() at the end when user is done viewing the report.
    4. When you say logn running queries are seen in DB, are you referring to a DB connection left open? or is it actually running any query and returning results?

  • How to execute sql-queries through shell scripting in linux?

    How to execute sql-queries through shell scripting in linux?

    http://www.oracle.com/technology/pub/articles/saternos_scripting.html
    Two simple examples:
    #!/usr/bin/env bash
    set_orafra () {
       orafra=`echo 'set heading off
       select name from v$recovery_file_dest;
       exit' | sqlplus -s / as sysdba`
    set_orafra
    echo $orafra
    #!/usr/bin/env bash
    export ORACLE_SID=instance_name
    export ORACLE_HOME=/path_to_oracle_home_directory
    export LD_LIBRARY_PATH=$ORACLE_HOME/lib
    export PATH=/$ORACLE_HOME/bin/$PATH
    $ORACLE_HOME/bin/sqlplus -s <<EOF
    connect scott/tiger@my_instance_name
    INSERT INTO table VALUES (sysdate);
    exit
    EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM

  • How to run SQL files from Java?

    Hi,
    Can someone point me towards a link on how to run sql files in Java? Thanks.
    P.S...if I've been completely blind please go easy on me!

    Sorry forgot the formating code thingy
    public static boolean executeScript(File script, Connection conn){
        boolean success = true;
        success = script.exists();
        if(success){
          DEBUG.print("ES::READING SCRIPT:" + script.getAbsolutePath());
          StringBuffer buffer = new StringBuffer();
          success=readScript(script,buffer);
          if(success){
            try{
              String creationScript = buffer.toString();
              Statement st = conn.createStatement();
              int start = 0;
              int end = 0;
              while (end != -1 && start < creationScript.length()) {
                end = creationScript.indexOf("GO", start);
                if (end != -1) {
                  DEBUG.print(creationScript.substring(start, end));
                  st.executeUpdate(creationScript.substring(start, end));
                  start = end + 2; //2 is the length of "GO"
              st.close();
            }catch(Exception e){
              success=false;
              DEBUG.printStackTrace(e);
        }else{
          DEBUG.print("ES::SCRIPT FILE DOES NOT EXISTS");
          success=false;
        return success;
      public static boolean readScript(File script, StringBuffer buffer){
        boolean success = true;
        DEBUG.print("RS:: reading file :" + script.getAbsolutePath());
        try{
          InputStreamReader isr = new InputStreamReader(new FileInputStream(script),"UTF16");
          int ch;
          while ( (ch = isr.read()) > -1) {
            buffer.append( (char) ch);
          if (isr != null)
            isr.close();
        }catch(Exception e){
          success=false;
          DEBUG.printStackTrace(e);
        return success;
      }

  • How to Add  3 queries in the same work book?

    Hi Gurus,
    Can any one tell How to Add  3 queries in the same work book?
    Example, daily report,Monhly and yearly reports for sales should be in the same workbook.
    Please help me if any one have a pointer or a how to doc if available.
    <<Text removed>>
    Thanks
    James
    Edited by: Matt on Apr 26, 2010 9:36 AM

    Hi James,
    According to BI 7.0 Version
    Steps of creating workbook and to insert more than one query in a workbook.
    When you run a query and it opens in Bex Analyzer you can click the save button and pick "Save as Workbook".
    Once you save it as a workbook Click on the "Design Mode" button in the Bex toolbar (looks like an A).
    Click in the sheet where you want the new query to go, click the "Analysis Grid" button. It will add the analysis grid to your new sheet.
    Right click on the Analysis grid and go to properties.
    Click on button to change data provider and select the query you want to attach.
    Exit design mode and you should be all set.

  • How to execute SQL Query from the Crystal report X1

    Dear All,
    I am using crystal report X1. In my application am creating run time MS Access tables and giving table name at run time based on my requirement . From these tables I want to fetch data based on some condition and to display using crystal report X1. I have never used the SQL Queries in the Crystal reports. Please help me out.
    Thanks and Regards,
    Rahaneef T

    Please note;
    This forum is dedicated to all other development-related questions which are not directly addressed by other forums. This includes Business Objects SDKs, products, or technologies which do not fall under BusinessObjects Enterprise, BusinessObjects Edge, Crystal Reports Server, or Crystal Reports (for example Desktop Intelligence SDK, Universe Designer SDK, Portal Integration Kits, Java User Function Libraries, and other third party technologies or development languages).
    This looks more like a Crystal Reports design issue?
    Ludek

  • How to insert  two queries in the same workbook in new BI 7.0 Bex web analy

    Hi
    Can you please advise how to insert multiple queries in the same workbook in BI 7.0 web analyser.
    Sarah

    Hi,
    You need to switch to design mode (BEx Analyser Menu - Design Toolbar - Design Mode). For each query that you want to embed, insert an analysis grid item in the workbook. Link each analysis grid to its corresponding data provider (query).
    Hope this helps.
    Regards,
    Rajkandula

  • How to run hardware diagnostic with the help of terminal?

    how to run hardware diagnostic with the help of terminal? any cmds

    Macs newer than 10.7's release just need to boot with the 'D' key.  
    Otherwise you need to find the original installer disk of the Mac, or call AppleCare for it to be able to run the hardware diagnostic.

  • I need to restore my apple ID, but it send the info to the wrong e-mail when that e-mail isn't on my ID information. How do I send it to the correct e-mail?

    I need to restore my apple ID, but it send the info to the wrong e-mail when that e-mail isn't on my ID information. How do I send it to the correct e-mail?

    How can it sent it to the wrong email address? Apple sends it to the email address listed in the information you provided for your account. Thus, I really do not understand your problem.
    Maybe this will help.
    Frequently Asked Questions About Apple ID

  • HT1212 I've forgotten my ipad passcode but when I try to restore on the computer it won't let me as I have to turn "find your ipad" off but i don't know how when I can't use the  ipad itself. How do I do this on the cloud?

    I've forgotten my ipad passcode but when I try to restore on the computer it won't let me as I have to turn "find your ipad" off but i don't know how when I can't use the  ipad itself. How do I do this on the cloud?

    If the iPad was running iOS 7,  iCloud: Find My iPhone Activation Lock in iOS 7
    http://support.apple.com/kb/HT5818
    How can I unlock my iPad if I forgot the passcode?
    http://www.everymac.com/systems/apple/ipad/ipad-troubleshooting-repair-faq/ipad- how-to-unlock-open-forgot-code-passcode-password-login.html
    iOS: Device disabled after entering wrong passcode
    http://support.apple.com/kb/ht1212
    How can I unlock my iPad if I forgot the passcode?
    http://tinyurl.com/7ndy8tb
    How to Reset a Forgotten Password for an iOS Device
    http://www.wikihow.com/Reset-a-Forgotten-Password-for-an-iOS-Device
    Using iPhone/iPad Recovery Mode
    http://ipod.about.com/od/iphonetroubleshooting/a/Iphone-Recovery-Mode.htm
    Saw this solution on another post about an iPad in a school environment. Might work on your iPad so you won't lose everything.
    ~~~~~~~~~~~~~
    ‘iPad is disabled’ fix without resetting using iTunes
    Today I met my match with an iPad that had a passcode entered too many times, resulting in it displaying the message ‘iPad is disabled – Connect to iTunes’. This was a student iPad and since they use Notability for most of their work there was a chance that her files were not all backed up to the cloud. I really wanted to just re-activate the iPad instead of totally resetting it back to our default image.
    I reached out to my PLN on Twitter and had some help from a few people through retweets and a couple of clarification tweets. I love that so many are willing to help out so quickly. Through this I also learned that I look like Lt. Riker from Star Trek (thanks @FillineMachine).
    Through some trial and error (and a little sheer luck), I was able to reactivate the iPad without loosing any data. Note, this will only work on the computer it last synced with. Here’s how:
    1. Configurator is useless in reactivating a locked iPad. You will only be able to completely reformat the iPad using Configurator. If that’s ok with you, go for it – otherwise don’t waste your time trying to figure it out.
    2. Open iTunes with the iPad disconnected.
    3. Connect the iPad to the computer and wait for it to show up in the devices section in iTunes.
    4. Click on the iPad name when it appears and you will be given the option to restore a backup or setup as a new iPad (since it is locked).
    5. Click ‘Setup as new iPad’ and then click restore.
    6. The iPad will start backing up before it does the full restore and sync. CANCEL THE BACKUP IMMEDIATELY. You do this by clicking the small x in the status window in iTunes.
    7. When the backup cancels, it immediately starts syncing – cancel this as well using the same small x in the iTunes status window.
    8. The first stage in the restore process unlocks the iPad, you are basically just cancelling out the restore process as soon as it reactivates the iPad.
    If done correctly, you will experience no data loss and the result will be a reactivated iPad. I have now tried this with about 5 iPads that were locked identically by students and each time it worked like a charm.
    ~~~~~~~~~~~~~
    Try it and good luck. You have nothing more to lose if it doesn't work for you.
     Cheers, Tom

  • HT201407 My iphone suddenly stops working and asked for activation required. I did restore it thru itunes but it asks me to turn off "find my iphone". How can i disable "find my iphone" if i can open the iphone itself. please help me.

    My iphone suddenly stops working and asked for activation required. I did restore it thru itunes but it asks me to turn off "find my iphone". How can i disable "find my iphone" if i can open the iphone itself. please help me.

    My iphone 5 suddenly stops working and asked for activation required. I did restore it thru itunes but it asks me to turn off "find my iphone". How can i disable "find my iphone" if i can't open the iphone itself. please help me.

  • I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    I reset my phone and it now receives calls that were meant for my husband. I know how to fix this with messaging and facetime, but can't seem to find how to make it stop with the calls. Please help.

    It may be due to Continuity
    The following quote is from  Connect your iPhone, iPad, and iPod touch using Continuity
    Turn off iPhone cellular calls
    To turn off iPhone Cellular Calls on a device, go to Settings > FaceTime and turn off iPhone Cellular Calls.

Maybe you are looking for

  • BAPI_CONTRACT_CREATEFROMDATA Billing Plan Tab

    In BAPI_CONTRACT_CREATEFROMDATA I cannot figure out how to populate the 'Billing Plan' tab information in the header data. The table that this information is stored in is table FPLA.

  • External password store alias length issue

    Environment: HP8420-11i PA-RISC64 UNIX SQLPLUS Problem: wallets for external passwords with an alias over seven (7) bytes in length is throwing an ORA-01017 error. Six (6) bytes or less function properly. Is this a known issue/bug? Thank you in advan

  • Having thousands of Host-Named Site Collections - which authentication type?

    So Microsoft seems to state the claims + Host-Named Site Collection (HNSC) approach is the way to go forward. Assuming we have thousands of site collections, and we don't want to go with good ol' NTLM authentication as our claim authentication type,

  • Java.lang.indexoutofbound Exception

    HI all i am trying to convert multiple jpg images to single tiff image..i am getting an exception that is "java.lang.indexoutofbound Exception"..can anyone help me import com.sun.media.imageio.plugins.tiff.TIFFImageWriteParam; import java.awt.image.B

  • How the translation date(BKPF-WWERT) in FI document is decided?

    Hello, experts,   When FI documents are created, translation date is automatically set.   Can someone tell me the rule what date is set to the translation date?   Basically, it looks it is coming from posting date. However, there are the case other k