[Tutor] Syntax Question
John Fouhy
john at fouhy.net
Wed Feb 8 22:34:00 CET 2006
On 09/02/06, Rich Shepard <rshepard at appl-ecosys.com> wrote:
> self.cur.execute("CREATE TRIGGER fki_comp_cat BEFORE INSERT ON component
> FOR EACH ROW BEGIN SELECT RAISE(ROLLBACK, 'insert on table "category"
> violates foreign key constraint "fk_comp_cat"') WHERE NEW.comp_cat IS NOT
> NULL AND (SELECT cat_name FROM category WHERE cat_name = NEW.comp_cat) IS
> NULL END")
> ^
> SyntaxError: invalid syntax
At a guess, the error here is that the double-quote before CREATE is
matching the double quote before 'category', finishing the string
there.
A triple-quoted string should work for you because lone single or
double quotes in a triple-quoted string are passed literally.
Otherwise, you need to escape them --- ie: 'insert on table
\"category\" ...'.
HTH!
--
John.
More information about the Tutor
mailing list