Search code examples
oracleperldbd

How to use a user created function in n perl DBD::Oracle


I have created a function in oracle 11g r2, I would like to call that function while inserting a record.

Following is my code block.

my $SQL="insert into sample values ( :sno, :amount , :func )";
my $sth =$dbh-> prepare($SQL);
$sth->bind_param(":amount" , $amount );
$sth->bind_param(":sno" , $i);

$sth->bind_param(":func" , my_func($amount)); 
$sth-> execute();
# I want the third parameter to be output of the function my_func.

Solution

  • my $SQL = "insert into sample values (?, ?, my_func(?))";
    my $sth = $dbh->prepare($SQL);
    
    $sth->execute($i, $amount, $amount);