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

Hi Monks, I have problem in calling Oracle stored procedure here. the script is
#!/usr/bin/perl use strict; use DBI; my $dbh = DBI->connect( "dbi:Oracle:host= ;sid= ;port= ","user","password",{RaiseError => +1,AutoCommit => 0}) || die "Database connection not made: $DBI::errst +r"; eval { my $func = $dbh->prepare(q{ BEGIN drop_user_table(parameter1_in => :parameter1); END; }); $func->bind_param(":parameter1", 'mumtest') ; #positional placeholder +s are handy! $func->execute; $func->finish; $dbh->commit; }; if( $@ ) { warn "Execution of stored procedure failed: $DBI::errstr\n"; $dbh->rollback; } $dbh->disconnect;
and the procedure is
create or replace procedure drop_user_table (in_table IN varchar2) aut +hid current_user IS -- Declare the variables for counting tables and setting the execute s +tatement. tbl_exists integer; my_stmt varchar2(100); BEGIN -- Make a count to see if table exists select count(*) into tbl_exists from all_tables where table_name = in_table and owner = user; -- If table exeists, then set the statement to drop it and execute the + statement. if tbl_exists = 1 then my_stmt := 'drop table ' || in_table; EXECUTE IMMEDIATE my_stmt; end if; END;
and while running the script I am getting this error
DBD::Oracle::st execute failed: ORA-06550: line 4, column 5: PLS-00306: wrong number or types of arguments in call to 'DROP_USER_TA +BLE' ORA-06550: line 4, column 5: PL/SQL: Statement ignored (DBD ERROR: error possibly near <*> indicato +r at char 23 in ' BEGIN <*>drop_user_table(parameter1_in => :p +arameter1); END; ') [for Statement " BEGIN drop_user_table(parameter1_in => :para +meter1); END; " with ParamValues: :parameter1='mumtest'] at ora.pl line 20. Execution of stored procedure failed: ORA-06550: line 4, column 5: PLS-00306: wrong number or types of arguments in call to 'DROP_USER_TA +BLE' ORA-06550: line 4, column 5: PL/SQL: Statement ignored (DBD ERROR: error possibly near <*> indicato +r at char 23 in ' BEGIN <*>drop_user_table(parameter1_in => :p +arameter1); END; ')
Can anybody help me here?

Replies are listed 'Best First'.
Re: Error while calling Oracle stored procedure
by olus (Curate) on Jul 01, 2008 at 13:27 UTC

    Try drop_user_table(in_table => :parameter1);. The procedure is expecting the var in_table but you are assigning a value to parameter1_in that it does not recognize.

      Hey olus.. thanks for the solution .. it worked hav a nice time
Re: Error while calling Oracle stored procedure
by Corion (Patriarch) on Jul 01, 2008 at 07:55 UTC

    Are you sure that the following is valid Oracle SQL syntax?

    drop_user_table(parameter1_in => :parameter1);

    Especially the fat comma => strikes me as weird. But maybe Oracle has learned important things from Perl.