SELECT RAISE(FAIL,'album has songs cannot be deleted')");

On Jul 29, 5:43 am, manigault <manig...@gmail.com> wrote:
> Hi all, i have simple relation between songs and albums one to many.
> I created the album table like this
> CREATE TABLE albums
> (id INTEGER PRIMARY KEY ASC,
> name TEXT,
> additional TEXT)
>
> My song table is like this
> StringBuilder sqlQuery = new StringBuilder();
> CREATE TABLE songs
> (id INTEGER PRIMARY KEY ASC,
> album_fk INTEGER NOT NULL,
> title TEXT,
> url TEXT,
> duration BIGINT NOT NULL)
>
> and i have trigger to check when i wan't to delete an album if there
> are songs in it
> CREATE TRIGGER trigger_on_delete
> BEFORE DELETE ON albums
> FOR EACH ROW BEGIN
> SELECT RAISE(FAIL,'album has songs cannot be deleted')");
> WHERE (SELECT album_fk FROM songs WHERE album_fk = OLD.id) IN NOT
> NULL;)
> END
>
> and everything is ok and its working fine. But sometimes i got this
> error
> Exception: android.database.sqlite.SQLiteConstraintException: error
> code 19: constraint failed
> Stack Trace :
> android.database.sqlite.SQLiteStatement.native_execute(Native Method)
> android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:
> 66)
> when i am trying to delete an album. I know what #define
> SQLITE_CONSTRAINT  19   /* Abort due to constraint violation */ stands
> for but i can't what constraints can be violated when deleting an
> album.
> I can't reproduce this so i can't debug it to find out what's the
> problem any ideas what could go wrong and cause such error. I've tried
> playing with string encoding but i think that's not the problem.

-- 
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.

NEW! Try asking and tagging your question on Stack Overflow at
http://stackoverflow.com/questions/tagged/android

To unsubscribe from this group, send email to
android-beginners+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en

Reply via email to