#!/usr/bin/perl

use DBI;


my $dbh = DBI->connect(---your connection string---);


my $distinct_query = 'INSERT INTO t1 (f1) SELECT @x:=? FROM DUAL WHERE NOT EXISTS ( SELECT * FROM t1 WHERE f1=@x)';
my $distinct_query_handle = $dbh->prepare($distinct_query) || die("SQL ERROR: ".$dbh->errstr);
my $f1=2;
$distinct_query_handle->execute($f1) or die("SQL ERROR: ".$dbh->errstr);
