0

I have a jqgrid that calls a perl cgi to populate the grid. The cgi is using DBD::Oracle to get the data. The grid is not displaying the data.

Debugging the script I have found there is a conflict when the statement is prepared. When I skip the prepare and just send the data it works fine; when I change from Oracle to PostgreSQL it works just fine.

Anyone ever experience this? I know the CGI is working with the Oracle connection because it runs and prints to the screen when I run it interactively. When the CGI is called from the grid it does not. When the CGI is called with the Pg connection and prepare, the data loads to the grid - perfect

The CGI:

 #!/usr/bin/perl
    use CGI;
    use DBI;
    use Connect::Oracle;
    use Connect::PG;

    $stat = new CGI("");
    print $stat->header;
    $count = $stat->url_param('count');

    #connecting to either db works fine
    my $ORdbh = DBI->connect(Oracle->User, {PrintError=>1,RaiseError=>1}); 
    # my $ORdbh = DBI->connect(PG->User, {PrintError=>1,RaiseError=>0});

    $select = qq/select * from db.table/;  

    # preparing with Oracle connection works fine, but nothing returned to grid. 
    # Not even the hardcoded $rows below! 
    # Preparing with PG connection works also but $rows returns to grid

    my $select_batch_status = $ORdbh->prepare($select);
    #$select_batch_status->execute();
    #$select_batch_status->bind_columns(\$COLLECTID, \$SYSTEM);

    ....removed fetch()....irrelevant

    #The JSON is fine

    $rows = qq/["COLLECTID","SYSTEM"]/;

    $data = qq/{"page":"1","total": 1, "records": "$row_count", "rows": [/;
    $data .= $rows;
    $data .= qq/]}/;

    print "$data";
    exit;

I'm concluding there is a conflict between jqgrid and DBD::Oracle but I don't no how to debug any lower. The grid works great with Pg but I want to use Oracle. On Chrome Developers tools I don't see any warnings or errors, and the cgi is not sending any data

The grid:

<script type="text/javascript">
    var counter=0;
    jQuery(function () {
        jQuery("#list3").jqGrid({
            url:'./collect.cgi?count=' + counter,
            datatype: "json",
            ajaxGridOptions: { contentType: 'application/json; charset=utf-8' },
            colNames: ['COLLECT ID', 'SYSTEM'],
            colModel: [
                {name: 'collectid', index: 'collectid', width: 100},
                {name: 'system', index: 'system', width: 50},
            ],
            rowNum: 20,
            rowList: [15, 30, 45],
            pager: '#pager3',
            sortname: 'system',
            sortable: true,
            loadonce: true,
            viewrecords: true,
            sortorder: "asc",
            rowTotal: 500,
            jsonReader: {
                cell: "",
                id: "0"
            },
            gridview: true,
            loadComplete: function() {
            $(document).ready(function() {
                    setTimeout (function() {
                            counter++;
                            $("#list3").jqGrid().setGridParam({
                                    url: './collect.cgi?count=' + counter,
                                    datatype: 'json',
                                    loadonce: true
                            }).trigger("reloadGrid",[{current:true}]);
                    }, 10000);
            });
            },
            loadError: function(xhr,st,err) {
                    $("#jsonmapMessage").html("Type: " + st + "; Response: " + xhr.status + " " + xhr.statusText);
            },
            loadtext: "updating...",
            caption: "COLLECTION MONITOR CONTROL",
            width: 'auto',
            height: '500'
        });

    $("#list3").jqGrid('navGrid','#pager3',{edit:true,add:true,del:true,refresh:true});

    });

</script>
Mike
  • 59
  • 1
  • 1
  • 7

1 Answers1

0

I was able to revisit this recently, and after some digging and web log review it turns out that the cgi program was not able to load all the libraries needed for DBD::Oracle. To make those libraries available I had to update the LD_LIBRARY_PATH env variable to point to the proper libraries. This change is required at the webserver level where the cgi programs get their environment. Adding LD_LIBRARY_PATH to the script had no affect. On my webserver: Oracle iPlanet, I needed to update the cgi section of server.xml config file, and restart the webserver (making the change from the admin console didn't stick)

Mike
  • 59
  • 1
  • 1
  • 7