Question

For the first time I am trying to create a DataSet/TableAdapter in the VS2010 DataSet Designer using a query with a join and function; NVL(). Typically I had only used single database tables by dragging them to the designer workspace from the server explorer. In this case I right-clicked and added a TableAdapter and entered the following query:

SELECT a.primary_key, NVL(a.message, b.subject) as subject
FROM TableA a, TableB b
WHERE a.primary_key = b.primary_key (+) 
AND (a.time_stamp BETWEEN :time_start AND :time_end);

The DataTable was created with the appropriate columns. The issue is that when attempting to execute the query on the TableAdapter I am given the error:

Failed to enable constraints. One or more rows contain values violating non-null, unique, or foreign-key constraints.

I don't see anything unusual in the properties of the individual columns. What am I missing?

Thanks!

Was it helpful?

Solution

most likely it's left outer join and the FROM clause is missing.

Last time these things happened to me when there were no rows returned for b, but it was too long ago, I have even forgotten the old join syntax... run the query in query analyser or ssms and tell us :)

and this query too:

select count(1) from tableB where primary_key not in (select primary_key from tableA) 

OTHER TIPS

Be sure to set the property "EnforceConstraints" on DataSet Level to "false".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top