Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread INSERT
Tue, Feb 26 2008 7:54 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

If I want to insert values into the first 2 columns of a table, but I don't know the column names is it possible WHEN the table has more than two columns? If so how?

Roy Lambert
Wed, Feb 27 2008 6:26 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< If I want to insert values into the first 2 columns of a table, but I
don't know the column names is it possible WHEN the table has more than two
columns? If so how? >>

In an SQL statement or in a script with SQL/PSM ?   If the former, then it's
possible, but you'll most likely have to build the SQL dynamically in code,
using the Information schema to find out what the first two columns are and
then building the INSERT statement accordingly with only the first two
column names specified:

http://www.elevatesoft.com/scripts/manual.dll?action=mantopic&id=edb1sql&category=11&topic=172

--
Tim Young
Elevate Software
www.elevatesoft.com

Wed, Feb 27 2008 6:59 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Tim


Thanks - pretty much the conclusion I'd come to. I'm doing it in code for now cos I don't know how to set a column to force data entry to upper case.

Roy Lambert
Wed, Feb 27 2008 7:15 AMPermanent Link

"Ole Willy Tuv"
Tim,

<< In an SQL statement or in a script with SQL/PSM ?   If the former, then
it's possible, but you'll most likely have to build the SQL dynamically in
code, using the Information schema to find out what the first two columns
are and then building the INSERT statement accordingly with only the first
two column names specified: >>

It would be nice to have an ORDINAL_POSITION column in the "TableColumns"
system table, holding the 1-based index of the columns within the table
definition.

Example query:

select name
from information.tablecolumns
where
 upper(tablename) = 'MYTABLE'
 and ordinal_position between 1 and 2

Ole Willy Tuv
Thu, Feb 28 2008 7:05 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Ole,

<< It would be nice to have an ORDINAL_POSITION column in the "TableColumns"
system table, holding the 1-based index of the columns within the table
definition. >>

I've bounced around the idea a few times.   For now, the ordinal position is
the row position, so if you use this:

select name
from information.tablecolumns
where upper(tablename) = 'MYTABLE'

then the first two rows are guaranteed to be the first two rows in the
table, in ordinal order.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image