If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Unanswered: Set Column type not null-- Giving error.

Hello,
I have a table with 1000 records,I just added a varchar column and refreshed data in that column.Now I am trying add a not null constraint to that column so that I can make it part of the unique key but it is throwing an error:

Here is the syntax for the column:
ALTER TABLE TABLENAME ALTER COLUMN COLUMNNAME SET NOT NULL;
----------------------
Error:
DB21034E The command was processed as an SQL statement because it was not a
valid Command Line Processor command. During SQL processing it returned:
SQL0104N An unexpected token "NOT" was found following "R COLUMN SRC_TYP
SET". Expected tokens may include: "DEFAULT". SQLSTATE=42601

A syntax error in the SQL statement or the input command string for the
SYSPROC.ADMIN_CMD procedure was detected at the specified token
following the text "<text>". The "<text>" field indicates the 20
characters of the SQL statement or the input command string for the
SYSPROC.ADMIN_CMD procedure that preceded the token that is not valid.

As an aid, a partial list of valid tokens is provided in the SQLERRM
field of the SQLCA as "<token-list>". This list assumes the statement is
correct to that point.

ok ...but my actual requirement is to add this new column that I added today to an existing Unique constraint.
For that purpose, I have dropped the existing Unique constraint and tried to recreate with this new column as part of it..But I am getting error saying that I cannot add a column to a unique if it is not defined not null.

Anyways ...This is what I did...REnamed the table,Then dropped all foriegn Key Constraints,Created new table with that name and reloaded data back into the table
and put back the FK constraints. Tough though,any other solution.

Anyways ...This is what I did...REnamed the table,Then dropped all foriegn Key Constraints,Created new table with that name and reloaded data back into the table
and put back the FK constraints. Tough though,any other solution.

You could/should consider moving to a newer version. V8 is out of support for several years now.