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

Ed LaFrance interchange-users@icdevgroup.org
Fri Oct 11 18:52:01 2002


At 06:16 PM 10/11/2002 -0400, you wrote:
>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().

I had attempted an insert via $Db{table_name}->query() earlier and got a 
failure with this message in the error log:

SQL query failed for table_name: DBI tables must be updated natively.

... I saw in the list archives where others had posted that this worked for 
them, so I'm not sure what the issue is here.



>  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

Perfect! That worked, thanks Mike.

- Ed L.


===============================================================
New Media E.M.S.              Technology Solutions for Business
463 Main St., Suite D         eCommerce | Consulting | Hosting
Placerville, CA  95667        edl@newmediaems.com
(530) 622-9421                http://www.newmediaems.com
(866) 519-4680 Toll-Free      (530) 622-9426 Fax
===============================================================