charithd has asked for the wisdom of the Perl Monks concerning the following question:

Hi All' I want to get oracle memory info(SHOW PARAMETER MEMORY) and I tried with this:
#!/usr/bin/perl -w use strict; use DBI; my $dbh = DBI->connect( 'DBI:Oracle:charith', 'user', 'passwd', { RaiseError => 1, PrintError => 1 } ) || die "Database connection not made: $DBI::er +rstr"; my $sth = $dbh->prepare('SHOW PARAMETER MEMORY'); $sth->execute( ); my @row; while ( @row = $sth->fetchrow_array( ) ) { print "Row: @row\n"; } warn "Data fetching terminated early by error: $DBI::errstr\n" if $DBI::err; $sth->finish(); $dbh->disconnect();
But This gives Error:
DBD::Oracle::st execute failed: ORA-00900: invalid SQL statement (DBD +ERROR: OCIStmtExecute) [for Statement "SHOW PARAMETER MEMORY"] at ./t +estBase.pl line 26.
This works fine with SELECT commands, Badly I'm new to perl:DBI please give some help.
Expected OUT: SQL> SHOW PARAMETER MEMORY NAME TYPE VALUE ------------------------------------ ----------- --------------------- +--------- hi_shared_memory_address integer 0 memory_max_target big integer 11232M memory_target big integer 11232M shared_memory_address integer 0 SQL>
Thanks

Replies are listed 'Best First'.
Re: How to use oracle SHOW commands with DBI
by runrig (Abbot) on Feb 17, 2012 at 16:32 UTC
    SHOW is a sqlplus command, not a sql command. You'll have to select from a system table like Anony Monk says above.
Re: How to use oracle SHOW commands with DBI
by oko1 (Deacon) on Feb 17, 2012 at 07:09 UTC

    Try "$dbh->do()" instead of "prepare/execute". "do()" is, according to the DBI documentation, what you're supposed to use for non-SELECT statements.

    -- 
    I hate storms, but calms undermine my spirits.
     -- Bernard Moitessier, "The Long Way"

      FWIW, SHOW is a select statement, if you do, there are no rows to retrieve

        Looks like you're right. I don't have an Oracle DB to test, but I just played around with it on a MySQL DB, and invoking 'SHOW' this way works fine:

        perl -MData::Dumper -MDBI -we'$x=DBI->connect("dbi:mysql:wp", "yeah", +"fer_sure"); print Dumper($x->selectall_arrayref("SHOW VARIABLES"))'
        -- 
        I hate storms, but calms undermine my spirits.
         -- Bernard Moitessier, "The Long Way"
Re: How to use oracle SHOW commands with DBI
by Anonymous Monk on Feb 17, 2012 at 08:55 UTC
    Try "select * from v$parameter" and add a where clause for the parameters you want.