Foreign Key links - "Restrict is specified" error

Ivan Smahin IvanSmahin at public.kherson.ua
Tue Dec 13 15:57:51 CST 2005


Hello Dave,

Tuesday, December 13, 2005, 3:31:13 PM, you wrote:

DA> Hi all,

DA> I¹m trying to get a Foreign Key link to work, to link together a list of
DA> Tracks and a list of Playlists (read in from iTunes).  But I¹m having some
DA> problems.  Here¹s the background.

DA> I¹m reading in the iTunes XML library.  I get the Tracks first, then the
DA> Playlists, with each of their PlaylistTracks (showing how tracks are used in
DA> a playlist).

DA> Each Track has a unique integer ID, and so does each Playlist.  I have a
DA> third table, ³vPlaylistTracks², which links Playlists and Tracks together.

DA> In the constructor of both my vTracks table and my vPlaylists I have a call
DA> to create the UniqueID:

DA>   UniqueID = New VULong("UniqueID", EVFlag.fUnique + EVFlag.fIndexed)

DA> (Both tables have a property called ³UniqueID as VULong²)
DA>   
DA> In my joining table, I have:

DA>   Name = "PlaylistTracks"
DA>   
DA>   PlaylistUniqueIDPtr = New VULong("PlaylistUniqueIDPtr", EVFlag.fIndexed +
DA> EVFlag.fNullable)
DA>   TrackUniqueIDPtr = New VULong("TrackUniqueIDPtr", EVFlag.fIndexed +
DA> EVFlag.fNullable)
DA>   

DA> In my Database constructor, I have:

DA>   VDatabase(EVStorageType.kDefault)
DA>   
DA>   vTracks = New vTracksTable
DA>   vPlaylists = New vPlaylistsTable
DA>   vPlaylistTracks = New vPlaylistTracksTable
DA>   
DA>   vPT_PlaylistUniqueIDLink =
DA> CreateForeignKeyLink("PT_PlaylistUniqueIDLink",
DA> vPlaylists.UniqueID, vPlaylistTracks.PlaylistUniqueIDPtr,
DA> EVOnDelete.kSetNull, EVOnUpdate.kCascade, false)
DA>   vPT_TrackUniqueIDLink = CreateForeignKeyLink("PT_TrackUniqueIDLink",
DA> vTracks.UniqueID, vPlaylistTracks.TrackUniqueIDPtr, EVOnDelete.kSetNull,
DA> EVOnUpdate.kCascade, false)
DA>   
DA> I can add Tracks and Playlists to their tables with no problems.  But when I
DA> try and add a PlaylistTrack to the vPlaylistTracks table, I get an error.

DA> Here¹s what I am doing:

DA>   Dim newRecID as integer
DA>   LibraryDB3.vPlaylistTracks.SetBlank(EVValueAccess.forAdd)
DA>   LibraryDB3.vPlaylistTracks.PlaylistUniqueIDPtr.Value = inPlaylistID
DA>   LibraryDB3.vPlaylistTracks.TrackUniqueIDPtr.Value = inTrackID
DA>   newRecID = LibraryDB3.vPlaylistTracks.AddRecord
DA>   
DA> The AddRecord call raises a Vexception error:

DA> ³Restrict is specified.  Dropping is un available till constraints exist.²

DA> What does this error mean?  What have I done wrong?

It should be constraint violation error with more appropriate message.
I will fix it ASAP. But it should not be risen if both keys exist.

Are you sure inPlaylistID and inTrackID presented at the keys' tables?


-- 
Best regards,
 Ivan                            mailto:IvanSmahin at public.kherson.ua



More information about the Valentina mailing list