[ic] Adding records to Oracle table with non-unique index?

Mike Heins interchange-users@icdevgroup.org
Fri Oct 11 18:18:00 2002


Quoting Ed LaFrance (edl@newmediaems.com):
> Hi all -
> 
> Have a client who wants me to insert a record into an oracle table which 
> has a non-unique index (key) column, purposely to allow multiple entries 
> with the same index value. It seems that every data table writing method in 
> Interchange is designed to prevent this, updating the first matching record 
> found instead of writing a new one. Anybody have any ideas on how I can 
> force IC to blindly insert the new record into the table?

You'll have to either use DBI or $db->query(). Probably the best
thing is to just use DBI.

[perl tables=the_table]

	my $dbh = $Sql{the_table};

	my $q = 'INSERT INTO the_table (field1,field2) VALUES (?,?)';
	my $sth = $dbh->prepare($q)
	    or die "Failed statement handle prepare: " . $dbh->error();
	my $value1 = $Values->{value1};
	my $value2 = $Values->{value2};
	my $rc = $sth->execute($value1, $value2);
	return $rc ? 'Success' : 'Failed';
[/perl]

-- 
Mike Heins
Perusion -- Expert Interchange Consulting    http://www.perusion.com/
phone +1.513.523.7621      <mike@perusion.com>

I have a cop friend who thinks he ought be able to give a new ticket;
"too dumb for conditions".