Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 View and non null columns

Author  Topic 

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2006-10-16 : 11:03:34
Hi,

I have the following view...

SELECT     dbo.tbl_StarSign_PredictionSet.StarSignPredictionSetID, MAX(dbo.tbl_StarSign_PredictionSet.Date) AS Date, 
MAX(CASE WHEN StarSignID = 1 THEN PredictionText ELSE NULL END) AS Aries, MAX(CASE WHEN StarSignID = 2 THEN PredictionText ELSE NULL
END) AS Taurus, MAX(CASE WHEN StarSignID = 3 THEN PredictionText ELSE NULL END) AS Gemini,
MAX(CASE WHEN StarSignID = 4 THEN PredictionText ELSE NULL END) AS Cancer, MAX(CASE WHEN StarSignID = 5 THEN PredictionText ELSE NULL
END) AS Leo, MAX(CASE WHEN StarSignID = 6 THEN PredictionText ELSE NULL END) AS Virgo,
MAX(CASE WHEN StarSignID = 7 THEN PredictionText ELSE NULL END) AS Libra, MAX(CASE WHEN StarSignID = 8 THEN PredictionText ELSE NULL
END) AS Scorpio, MAX(CASE WHEN StarSignID = 9 THEN PredictionText ELSE NULL END) AS Sagittarius,
MAX(CASE WHEN StarSignID = 10 THEN PredictionText ELSE NULL END) AS Capricorn,
MAX(CASE WHEN StarSignID = 11 THEN PredictionText ELSE NULL END) AS Aquarius,
MAX(CASE WHEN StarSignID = 12 THEN PredictionText ELSE NULL END) AS Pisces
FROM dbo.tbl_StarSign_Prediction INNER JOIN
dbo.tbl_StarSign_PredictionSet ON
dbo.tbl_StarSign_Prediction.StarSignPredictionSetID = dbo.tbl_StarSign_PredictionSet.StarSignPredictionSetID
GROUP BY dbo.tbl_StarSign_PredictionSet.StarSignPredictionSetID


The object viewer says that all of the columns allow null except the first. When I do an insert with my local SQL server, the rows get inserted fine using triggers.

With my live server the insert trigger doesn't seem to be even firing as its reporting an error of....

quote:
The column 'StarSignPredictionSetID' in table 'newbury.dbo.vw_StarSign_Prediction' cannot be null..


Either I need to set the column as allow null like the other columns or else I need to stop the server from throwing the exception.

Cheers, XF.

nr
SQLTeam MVY

12543 Posts

Posted - 2006-10-16 : 11:24:18
Is it an after trigger or an instead of trigger?
If an after then it won't help - don't know why it's working on the dev system.

Try seeing if the trigger is enabled.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2006-10-16 : 11:44:31
Its an instead of trigger. I think it must be enabled because if I remove it completely then the error is...

quote:
View or function 'newbury.dbo.vw_StarSign_Prediction' is not updatable because it contains aggregates..


Is there something more technical you mean by enabled?
Go to Top of Page

X-Factor
Constraint Violating Yak Guru

392 Posts

Posted - 2006-10-16 : 11:52:17
Another thing is that I can insert rows fine using Management Studio if I do enter a value for StarSignPredictionSetID. The value is ignored of course by the trigger because the value is autogenerated in a base table.

So it seems the live server is being a bit more picky about inserting into views. My UIMapper isn't designed to send bogus values to the database.
Go to Top of Page
   

- Advertisement -