Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Need to determine if a column exists or not
You could just include an error handler and update everybody's table - the error about duplicate column names should not stop the script from continuing, so at the end, everyone has an X column..
"news.integraonline.com" <aanderson_at_lillysoftware.com> wrote:
>I am in a situation where I need to determine is a column exists in a
>database or not.
>
>Does anyone know a way to do this.
>
>
>If you are asking the "Why would one need to do this!", that I have seen in
>response to others ?'s that are like this.
>
>I will explain.
>
>Overview: I have an application that executes scripts using the Oracle OLEDB
>provider, the application queries a database, and determines what changes
>need to be made to a customers database. It then executes a SQL script based
>on the determination made.
>
>Problem: Somewhere in the past a bad version of a script file was
>distributed to an undetermined amount of customers, this file did NOT add a
>column X to the database. So we are left with some customers that DO have
>column X and some that DON'T.
>
>We can't just drop column X for the ones that already have it, because they
>have data in the field. And creating temp tables seems like a pain.
>
>Resolution(hopefully): Find a way to do determine if the column exists... If
>it does not we need to add it.
>Example (not intended to be Oracle Syntax),
>If ColumnX.Exists Then
> Alter table TableName Add X
>End If
>
>If we can do this, everyone is happy. And we don't have some customers with,
>and some without.
>
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World! -----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =----- Received on Fri Oct 18 2002 - 10:21:13 CDT
![]() |
![]() |