You should be able to get the column names from row 0. The trouble with
that is that you don't know the data types for the columns. You need to
know the data types, or be able to figure it out from the data, so that
you know which bits of data to wrap in quotes in the insert statement.

Another way would be to get the column names and data types from the
system tables. It's been a while since I used Oracle, but I believe
sys$columns has the information you need. Select the columns for your
table and build an insert statement accordingly.

Another option might be to chance the sessionID in your array, write it
out to a comma delimited file and use the oracle import command to
re-insert it into the table.

Dave Shelley

-----Original Message-----
From: MJPinckard [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, July 27, 2005 8:46 PM
To: Witango
Subject: Witango-Talk: duplicating a row in Oracle

I'm trying to add an option for users to clone their user session.

I have a table with ~500 columns (yeah I know, but that's how it's 
structured, legacy code...ugh).

I want to duplicate this row, changing only the primary key 
(session_id). Since it is not inconceivable that the column structure 
might change someday, I'd like to make the code as generic as possible 
(not coding each column into an update or insert action).

Using directDBMS, I can easily extract all the existing data using the 
following code.

    select * from Input where session_id=someNumber

But this gives me data only (no column names) and in any event I can't 
figure out how to get the data into another row. I've tried a variety of

different ways (using both INSERT and creating a row in another action 
then performing an UPDATE) but can't get anything to work.

Has anyone any suggestions about how I might accomplish this? I'm about 
to give in and manually code all 500 columns into an insert action... 
but surely there has got to be an easier way...

Mac OS X server
Witango 5.0.9 (I think)
Oracle db using Oracle OCI drivers.

Thanks for any assistance.

Cheers,

Maggie Pinckard
Principal Research Associate
Lawrence Berkeley National Laboratory
________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to