Perl SQL output as CSV

Version 1
    This document was generated from CDN thread

    Created by: Michael Schmidt on 13-05-2013 12:27:48 PM
    Hi,
    can anybody help me with this Perl command to get the SQL command output as a CSV file.
    This Perl is working perfect and I get the output as CSV file:
     
    #!/Program Files/Cisco/perl
    use strict;
    use warnings;
    use SOAP::Lite +trace => 'debug';
    use Data:umper;
    use MIME::Base64;
    #define variables
    my $cucmip;
    my $axl_port = "8443";
    my $user;
    my $password;
    my $desc;
    my $error_text;
    my $sql = "select e.userid, e.lastname, e.firstname, e.mailid, e.telephonenumber, n.dnorpattern, d.name, d.description from enduser as e, device as d, numplan as n, devicenumplanmap as m, endusernumplanmap as x where (m.fkdevice = d.pkid and m.fknumplan = n.pkid and e.pkid = x.fkenduser and x.fknumplan = n.pkid and x.tkdnusage = 1)";
    #get CUCM IP, username and password
    $cucmip = "CUCM-IP";
    $user = "AXL-User";
    chomp($user);
    $password = "AXL-Pass";
    chomp($password);
    #set up soap
    my $cm = new SOAP::Lite
    encodingStyle => '',
    uri => 'http://www.cisco.com/AXL/API/1.0',
    proxy => "https://$cucmip:$axl_port/axl/" ;
    #disable certificate check
    BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 }
    #authenticate to CUCM
    $cm = Login($cm,"$user","$password");
    #axl request
    my $axldata = SOAP:ata->name( "sql" => $sql );
    my $res = $cm->executeSQLQuery( $axldata );
    #show the returned value
    my $file = "Enduser_CUCM_Device.csv";
    open(FH, "> $file") or die "\nKonnte die Datei $file nicht zum Anhängen oeffnen\n";
       
    unless ($res->fault) {
    my( $reply ) = $res->paramsall();
    $desc = $reply->{row};
    foreach(@$desc) {
    print FH "$_->{userid}\;";
    print FH "$_->{lastname}\;";
    print FH "$_->{firstname}\;";
    print FH "$_->{mailid}\;";
    print FH "$_->{telephonenumber}\;";
    print FH "$_->{dnorpattern}\;";
    print FH "$_->{name}\;";
    print FH "$_->{description}\n";
    }
     
    close(FH);
    }
    else
    {
     $error_text = $res->faultcode.' '.$res->faultstring."\n";
     print $error_text
    }
    ################################################
    sub Login
    {
     $cm->transport->http_request->header (
     'Authorization' => 'Basic ' . encode_base64("$user:$password", ''));
     return $cm;
     }
     
    But this Perl is not working and I get back this error “Not an ARRAY reference at line 44” although the SQL command is working fine at CUCM CLI:
     
    Line 44 is: foreach(@$desc) {
     
    #!/Program Files/Cisco/perl
    use strict;
    use warnings;
    use SOAP::Lite +trace => 'debug';
    use Data:umper;
    use MIME::Base64;
    #define variables
    my $cucmip;
    my $axl_port = "8443";
    my $user;
    my $password;
    my $name;
    my $error_text;
    my $sql = "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='dnorpattern'";
    #get CUCM IP, username and password
    $cucmip = "CUCM-IP";
    $user = "AXL-User";
    chomp($user);
    $password = "AXL-Pass";
    chomp($password);
    #set up soap
    my $cm = new SOAP::Lite
    encodingStyle => '',
    uri => 'http://www.cisco.com/AXL/API/1.0',
    proxy => "https://$cucmip:$axl_port/axl/" ;
    #disable certificate check
    BEGIN { $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0 }
    #authenticate to CUCM
    $cm = Login($cm,"$user","$password");
    #axl request
    my $axldata = SOAP:ata->name( "sql" => $sql );
    my $res = $cm->executeSQLQuery( $axldata );
    #show the returned value
    my $file = "output.csv";
    open(FH, "> $file") or die "\nKonnte die Datei $file nicht zum Anhängen oeffnen\n";
       
    unless ($res->fault) {
    my( $reply ) = $res->paramsall();
    $name = $reply->{row};
    foreach(@$name) {
    print FH "$_->{name}\n";
    }
     
    close(FH);
    }
    else
    {
     $error_text = $res->faultcode.' '.$res->faultstring."\n";
     print $error_text
    }
    ################################################
    sub Login
    {
     $cm->transport->http_request->header (
     'Authorization' => 'Basic ' . encode_base64("$user:$password", ''));
     return $cm;
     }
     
    What is the error in the last Perl and how can I get is working?
    BR
    Michael

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 12:59:27 PM
    Hi Michael,
     
    I think you need to check $name to see if it's a hash or a reference to a hash.  Give the below a shot and let me know if it works for you.  Using Data Dumper to examine the structure of the XML response is a big help to track down issues when the structure changes.
     
    my( $reply ) = $res->paramsall();
    $name = $reply->{row};
     if (ref($name) eq 'HASH') {
    print FH "$name->{name}\n";
    } else
    foreach(@$name) {
    print FH "$_->{name}\n";
    }

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 13-05-2013 01:28:25 PM
    Hi Martin,
     
    thank you for your answer but using your changes I get back these errors:
     
    syntax error at line 47, near "foreach"
    syntax error at line 52, near "}"
    syntax error at line 57, near "}"
    Illegal declaration of subroutine main::Login at line 59.
     
    BR
    Michael

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 01:34:09 PM
    Yeah, sorry it looks like I forgot a brace for the else.  Try this one and just make sure the if/else and others are properly opened/closed.  I don't have my system in front of me but I'm trying to bring it up to test.
     
    my( $reply ) = $res->paramsall();
    $name = $reply->{row};
     if (ref($name) eq 'HASH') {
    print FH "$name->{name}\n";
    } else {
    foreach(@$name) {
    print FH "$_->{name}\n";
       }
    }

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 13-05-2013 01:40:44 PM
    Wow great it`s working :-). I thank you very much.
     
    BR
    Michael

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 01:43:34 PM
    Excellent!  You're welcome and I'm glad I could help.

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 13-05-2013 02:12:47 PM
    Hi Martin,

    as you are a Perl specialist I want to ask you another thing :-)
     
    The above mentioned SQL "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='dnorpattern'" I want to combine with this working Perl to update phones.
     
    The SQL find out the devices associated with the dn. When the SQL provides only one device associated with the dn it`s working but when the SQL find out more than one device only the first found device will be updated.

    How can I make a loop into this working Perl so that all found devices with SQL "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='dnorpattern'" will be updated?
     
    ##Beginn###################################################################################################################################
    #!/usr/bin/perl
    ############################################################################################
    $cucm_ip = 'CUCM-IP';    
    $user_axl = 'AXL-User';          
    $password_axl = 'AXL-Pass';
    $pfad_datei=$pfad."input.txt";
    ############################################################################################################################################
    $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
    use DBI;
    use SOAP::Lite;
    BEGIN
    {
      sub SOAP::Transport::HTTP::Client::get_basic_credentials
      {
        return
        ($user_axl => $password_axl)
      }
    }
    my $CUCM = SOAP::Lite
      ->uri("http://www.cisco.com/AXL/API/1.0")
      ->proxy("https://$cucm_ip/axl/");
    if (-e $pfad_datei)
    {
      print "File vorhanden\n";
      print ON "File vorhanden\n";
      open(IN,"$pfad_datei");
      while (<IN>)
      {
        print "==\n";
        $dn=""; 
        $neueDescription="";
        $line=$_;
        chomp($line);
        @values=split(/\;/,$line,2);
        $dn=(shift @values);
        $neueDescription=(shift @values);     
    ############################################################################################################################################
        $res =
          $CUCM->executeSQLQuery(
          SOAP:ata->name('sql' => "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'")
          );
        $_device_name=$res->valueof('//return/row/name');
    ############################################################################################################################################
        $res =
          $CUCM->executeSQLUpdate(
          SOAP:ata->name('sql' => "update device set description='$neueDescription' where name='$_device_name'")
          );
      }
    }
    else
    {
      print "File nicht gefunden\n";
    }
    ###Ende#####################################################################################################################################
     
    BR
    Michael

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 02:27:03 PM
    Michael,

    I was able to get access to test this and I'm pretty sure you were returning a single result from your second query which is why the updated code worked.  If you look at the AXL response with Data Dumper for a single record return versus multiple records there is a slight difference.  Below is a return message from my system with a 1-record-return first and 2-record-return on the next:
    $VAR1 = {
              'row' => {
                         'name' => 'TCTMSLOAN'
                       }
            };


    ______________________________
    $VAR1 = {
              'row' => [
                         {
                           'name' => 'TCTMSLOAN'
                         },
                         {
                           'name' => 'CSFmsloan'
                         }
                       ]
            };



    Notice the extra '[' that gets added with multiple records, which is why you create the '@$name' variable and access the content with $_.  With a single record, you have direct access to the hash with key=>value.  The if/else I gave you just checks this structure to see how if should handle it before processing the data.  This particular issue set me back for a while so I hope the explanation helps moving forward.  Once I got the hang of reading the XML structure with Data Dumper I started to get past these issue quicker.
    Marty
     
     

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 13-05-2013 02:36:57 PM
    Hi Martin,
    thanks for testing.
     
    I also just tested it once again but only one device description was updated.
     
    I have 2 Cisco 7942 configured with the same DN but with the Perl I wrote only the description at one Cisco 7942 was updated.
     
    BR
    Michael

    Subject: Re: New Message from Michael Schmidt in AXL Developer - Administration XML
    Replied by: Christopher Lamer on 13-05-2013 02:47:22 PM
    What is your SQL update syntax.  Because if you are updating the phone
    description...it has to be done per phone.  If you are updating the line
    description it will change on both phones...but it will not update the
    Display or Line Text label since that is a per device line setting.

    Christopher Lamer
    Global Information Services
    Enterprise Voice Services




    From:   Cisco Developer Community Forums <cdicuser@developer.cisco.com>
    To:     "cdicuser@developer.cisco.com" <cdicuser@developer.cisco.com>
    Date:   05/13/2013 02:41 PM
    Subject:        New Message from Michael Schmidt in AXL Developer -
    Administration XML Questions: RE: Perl SQL output as CSV



    Michael Schmidt has created a new message in the forum "Administration XML
    Questions": --------------------------------------------------------------
    Hi Martin,
    thanks for testing.

    I also just tested it once again but only one device description was
    updated.

    I have 2 Cisco 7942 configured with the same DN but with the Perl I wrote
    only the description at one Cisco 7942 was updated.

    BR
    Michael
    --
    To respond to this post, please click the following link:
    http://developer.cisco.com/web/axl-developer/forums/-/message_boards/view_message/15208790
    or simply reply to this email.

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 13-05-2013 02:57:49 PM
    Hi Christopher,
     
    for testing I want to update the phone description with "update device set description='$neueDescription' where name='$_device_name'"
     
    The variable $_device_name I get from the first SQL "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'".
     
    If I run manually the SQL "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'" at CUCM CLI I get back both phone names.
     
    But with my perl only one of the 2 Cisco phone description was updated.
     
    BR
    Michael
     

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 03:02:52 PM
    Hi Michael,

    If I understand corretly you want to use the results from your sql select as the source for multiple updates to the description?  If so, instead of printing the devicename to file, push it to an array and then loop through the array sending the applicable update.  As long the description is the same for each udpate request you're okay.  If you need to map unique descriptions to device name it would take some more work.  Try something like this:
    my( $reply ) = $res->paramsall();
    $name = $reply->{row};
     if (ref($name) eq 'HASH') {
    push (@nameList,$name->{name});
    } else {
    foreach(@$name) {
    push (@nameList,$_->{name});
       }
    }
    foreach (@nameList) {
    SQL UPDATE CODE
    }
     
    And within the sql update statement reference the devicename as $_

    You'll have to fill in the error handling and things for the sql update code but I think you get the picture of pushing the devicenames to an array and then iterating through them in the foreach loop.
    Let me know if you get it working.
    Marty

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 13-05-2013 03:24:03 PM
    Hi Martin,

    I changed the code to this:
     
    ############################################################################################################################################
    my( $reply ) = $res->paramsall();
    $CUCM->executeSQLQuery(
          SOAP:ata->name('sql' => "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'")
          );
    $name = $reply->{row};
     if (ref($name) eq 'HASH') {
    push (@nameList,$name->{name});
    } else {
    foreach(@$name) {
    push (@nameList,$_->{name});
       }
    }
    foreach (@nameList) {
    $CUCM->executeSQLUpdate(
          SOAP:ata->name('sql' => "update device set description='$neueDescription' where name='$name'")
          );
    }
    ############################################################################################################################################
      }
    }
    else
    {
      print "File nicht gefunden\n";
    }
    ###Ende#####################################################################################################################################
     
    But I get back now the error "Can't call method "paramsall" on an undefined value at line 40, <IN> line 1.".
     
    BR
    Michael

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 03:28:45 PM
    Try to take out the first 'my( $reply ) = $res->paramsall();' at the top of the above, it should clear the error. 
     
    Also, I think our earlier messages crossed in flight.  My post about reading the XML structure was related to your question on the select statements but it appears I was replying to your latest issue when you read it inline.  Just FYI.

    Subject: Re: New Message from Michael Schmidt in AXL Developer - Administration XML
    Replied by: Christopher Lamer on 13-05-2013 03:32:22 PM
    The params all line would go after the request.  IE:

        $res =
          $CUCM->executeSQLQuery(
          SOAP:ata->name('sql' => "select d.name from device as
    d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and
    devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='59641'")
          );
        $_device_name=$res->paramsall();


    Christopher Lamer
    Caterpillar Inc.
    Global Information Services
    Enterprise Voice Services
    725-9641 - Tieline
    +1 309-675-9641 - Office
    Lamer_Christopher@cat.com



    From:   Cisco Developer Community Forums <cdicuser@developer.cisco.com>
    To:     "cdicuser@developer.cisco.com" <cdicuser@developer.cisco.com>
    Date:   05/13/2013 03:28 PM
    Subject:        New Message from Michael Schmidt in AXL Developer -
    Administration XML Questions: RE: Perl SQL output as CSV



    Michael Schmidt has created a new message in the forum "Administration XML
    Questions": --------------------------------------------------------------
    Hi Martin,

    I changed the code to this:

    ############################################################################################################################################
    my( $reply ) = $res->paramsall();
    $CUCM->executeSQLQuery(
          SOAP:ata->name('sql' => "select d.name from device as
    d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and
    devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'")
          );
    $name = $reply->{row};
    if (ref($name) eq 'HASH') {
    push (@nameList,$name->{name});
    } else {
    foreach(@$name) {
    push (@nameList,$_->{name});
       }
    }
    foreach (@nameList) {
    $CUCM->executeSQLUpdate(
          SOAP:ata->name('sql' => "update device set
    description='$neueDescription' where name='$name'")
          );
    }
    ############################################################################################################################################
      }
    }
    else
    {
      print "File nicht gefunden\n";
    }
    ###Ende#####################################################################################################################################

    But I get back now the error "Can't call method "paramsall" on an
    undefined value at line 40, <IN> line 1.".

    BR
    Michael
    --
    To respond to this post, please click the following link:
    http://developer.cisco.com/web/axl-developer/forums/-/message_boards/view_message/15209670
    or simply reply to this email.

    Subject: RE: Perl SQL output as CSV
    Replied by: Martin Sloan on 13-05-2013 03:53:18 PM
    Nice catch, Christopher!  I thought I saw that line again below but it wasn't there. 
    Just going from the code syntax we've been using, this is working against my system:
    my $axl_sql = "select name from device";

    my $data = SOAP:ata->name("sql" => $axl_sql);
    my $res = $cm->executeSQLQuery($data);
    unless ($res->fault) {
        my( $reply ) = $res->paramsall();
        $name = $reply->{row};
        if (ref($name) eq 'HASH') {
            push(@devList,$name->{name});
        } else {
            foreach(@$name) {
                push (@devList,$_->{name});
            }
        }
    }
    else {
        print join ', ',
        $res->faultcode,
        $res->faultstring;
    }
    foreach(@devList) {
    print "The current device name is: $_\n";
    }


    @Michael, you can change the foreach loop to execute the sql update statements, like:
    foreach(@devList) {
    $CUCM->executeSQLUpdate(
          SOAPata->name('sql' => "update device set description='$neueDescription' where name='$_'")
          );
    }

    Subject: RE: Perl SQL output as CSV
    Replied by: Michael Schmidt on 14-05-2013 12:30:54 AM
    Hi Martin / Christopher,
     
    the Perl now looks like this but I get back this error:
    syntax error at line 42, near "SOAP:"
    Execution of SQL_Update_Device1.pl aborted due to compilation errors.

    Line 42 = my $data = SOAPata->name("sql" => $axl_sql);
     
    ###Beginn###################################################################################################################################
    #!/usr/bin/perl
    #Variablen welche noch angepasst werden muessen############################################################################################
    $cucm_ip = 'CUCM-IP';    
    $user_axl = 'AXL-User';          
    $password_axl = 'AXL-Pass';
    $pfad_datei=$pfad."input.txt";
    ############################################################################################################################################
    $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
    use DBI;
    use SOAP::Lite;
    BEGIN
    {
      sub SOAP::Transport::HTTP::Client::get_basic_credentials
      {
        return
        ($user_axl => $password_axl)
      }
    }
    my $CUCM = SOAP::Lite
      ->uri("http://www.cisco.com/AXL/API/1.0")
      ->proxy("https://$cucm_ip/axl/");
    if (-e $pfad_datei)
    {
      print "File vorhanden\n";
      print ON "File vorhanden\n";
      open(IN,"$pfad_datei");
      while (<IN>)
      {
        print "==\n";
        $dn=""; 
        $neueDescription="";
        $line=$_;
        chomp($line);
        @values=split(/\;/,$line,2);
        $dn=(shift @values);
        $neueDescription=(shift @values);     
    ############################################################################################################################################
    my $axl_sql = "select d.name from device as d,devicenumplanmap,numplan where d.pkid=devicenumplanmap.fkdevice and devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'";

    my $data = SOAPata->name("sql" => $axl_sql);
    my $res = $cm->executeSQLQuery($data);
    unless ($res->fault) {
        my( $reply ) = $res->paramsall();
        $name = $reply->{row};
        if (ref($name) eq 'HASH') {
            push(@devList,$name->{name});
        } else {
            foreach(@$name) {
                push (@devList,$_->{name});
            }
        }
    }
    else {
        print join ', ',
        $res->faultcode,
        $res->faultstring;
    }
    foreach(@devList) {
    print "The current device name is: $_\n";
    }




    foreach (@devList) {
    $CUCM->executeSQLUpdate(
          SOAP:ata->name('sql' => "update device set description='$neueDescription' where name='$_'")
          );
    }
    ############################################################################################################################################
      }
    }
    else
    {
      print "File nicht gefunden\n";
    }
    ###Ende#####################################################################################################################################
     
     
     
    BR
    Michael

    Subject: Re: New Message from Michael Schmidt in AXL Developer - Administration XML
    Replied by: Christopher Lamer on 14-05-2013 07:58:22 AM
    Do you have SOAP:ata  or SOAPata?  I think you are missing the second
    ":";

    Christopher Lamer
    Global Information Services
    Enterprise Voice Services



    From:   Cisco Developer Community Forums <cdicuser@developer.cisco.com>
    To:     "cdicuser@developer.cisco.com" <cdicuser@developer.cisco.com>
    Date:   05/14/2013 12:35 AM
    Subject:        New Message from Michael Schmidt in AXL Developer -
    Administration XML Questions: RE: Perl SQL output as CSV



    Michael Schmidt has created a new message in the forum "Administration XML
    Questions": --------------------------------------------------------------
    Hi Martin / Christopher,

    the Perl now looks like this but I get back this error:
    syntax error at line 42, near "SOAP:"
    Execution of SQL_Update_Device1.pl aborted due to compilation errors.

    Line 42 = my $data = SOAPata->name("sql" => $axl_sql);

    ###Beginn###################################################################################################################################
    #!/usr/bin/perl
    #Variablen welche noch angepasst werden
    muessen############################################################################################
    $cucm_ip = 'CUCM-IP';    
    $user_axl = 'AXL-User';          
    $password_axl = 'AXL-Pass';
    $pfad_datei=$pfad."input.txt";
    ############################################################################################################################################
    $ENV{PERL_NET_HTTPS_SSL_SOCKET_CLASS} = "Net::SSL";
    $ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
    use DBI;
    use SOAP::Lite;
    BEGIN
    {
      sub SOAP::Transport::HTTP::Client::get_basic_credentials
      {
        return
        ($user_axl => $password_axl)
      }
    }
    my $CUCM = SOAP::Lite
      ->uri("http://www.cisco.com/AXL/API/1.0")
      ->proxy("https://$cucm_ip/axl/");
    if (-e $pfad_datei)
    {
      print "File vorhanden\n";
      print ON "File vorhanden\n";
      open(IN,"$pfad_datei");
      while (<IN>)
      {
        print "==\n";
        $dn=""; 
        $neueDescription="";
        $line=$_;
        chomp($line);
        @values=split(/\;/,$line,2);
        $dn=(shift @values);
        $neueDescription=(shift @values);     
    ############################################################################################################################################
    my $axl_sql = "select d.name from device as d,devicenumplanmap,numplan
    where d.pkid=devicenumplanmap.fkdevice and
    devicenumplanmap.fknumplan=numplan.pkid and numplan.dnorpattern='$dn'";

    my $data = SOAPata->name("sql" => $axl_sql);
    my $res = $cm->executeSQLQuery($data);
    unless ($res->fault) {
        my( $reply ) = $res->paramsall();
        $name = $reply->{row};
        if (ref($name) eq 'HASH') {
            push(@devList,$name->{name});
        } else {
            foreach(@$name) {
                push (@devList,$_->{name});
            }
        }
    }
    else {
        print join ', ',
        $res->faultcode,
        $res->faultstring;
    }
    foreach(@devList) {
    print "The current device name is: $_\n";
    }




    foreach (@devList) {
    $CUCM->executeSQLUpdate(
          SOAP:ata->name('sql' => "update device set
    description='$neueDescription' where name='$_'")
          );
    }
    ############################################################################################################################################
      }
    }
    else
    {
      print "File nicht gefunden\n";
    }
    ###Ende#####################################################################################################################################



    BR
    Michael
    --
    To respond to this post, please click the following link:
    http://developer.cisco.com/web/axl-developer/forums/-/message_boards/view_message/15220188
    or simply reply to this email.