Hi,
i use sqlalchemy to create a postgresql database. Within this database i
need a trigger. I found a recipe to declare triggers using DDL:
(this is declared inside class Absence)
trigger_ddl = DDL("""
CREATE OR REPLACE FUNCTION validate_absence() RETURNS trigger
AS $validate_absence$
DECLARE
t0 INTERVAL := CAST('0 second' AS INTERVAL);
BEGIN
--- nothing bad happend
RETURN NEW;
END;
$validate_absence$ LANGUAGE plpgsql;
CREATE TRIGGER validate_absence BEFORE INSERT OR UPDATE
ON fehlzeit
FOR EACH ROW EXECUTE PROCEDURE validate_fehlzeit();
""")
Then, i use the following line to create the trigger
event.listen(Absence.__table__,
'after_create',
absence.trigger_ddl)
Of course, this trigger does not do anything useful because i deleted
every action to find the error. As soon, as i change this to
trigger_ddl = DDL("""
CREATE OR REPLACE FUNCTION validate_absence() RETURNS trigger
AS $validate_absence$
DECLARE
t0 INTERVAL := CAST('0 second' AS INTERVAL);
tt timetable%ROWTYPE --- <=== new line inserted
BEGIN
--- nothing bad happend
RETURN NEW;
END;
$validate_absence$ LANGUAGE plpgsql;
CREATE TRIGGER validate_absence BEFORE INSERT OR UPDATE
ON fehlzeit
FOR EACH ROW EXECUTE PROCEDURE validate_fehlzeit();
""")
the script throws an errormessage:
ValueError: unsupported format character 'R' (0x52) at index 205
I think, the %-sign is responsible for this error. Since i need the
%-sign at a later stage in this trigger to do a modulo operation, i need
to how how to insert a %-sign into a trigger.
Thank you for any hint
Wolfgang
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.