我是Postgresql的新手。任何人都可以更正此查询。
原文链接:https://www.f2er.com/postgresql/193025.htmlBEGIN TRANSACTION; BEGIN; CREATE TABLE "Logs"."Events" ( EventId BIGSERIAL NOT NULL PRIMARY KEY,PrimaryKeyId bigint NOT NULL,EventDateTime date NOT NULL DEFAULT(now()),Action varchar(12) NOT NULL,UserId integer NOT NULL REFERENCES "Office"."Users"(UserId),PrincipalUserId varchar(50) NOT NULL DEFAULT(user) ); CREATE TABLE "Logs"."EventDetails" ( EventDetailId BIGSERIAL NOT NULL PRIMARY KEY,EventId bigint NOT NULL REFERENCES "Logs"."Events"(EventId),Resource varchar(64) NOT NULL,OldVal varchar(4000) NOT NULL,NewVal varchar(4000) NOT NULL ); COMMIT TRANSACTION; RAISE NOTICE 'Task completed sucessfully.' EXCEPTION; ROLLBACK TRANSACTION; RAISE ERROR @ErrorMessage,@LineNumber,@ErrorState --how to catch errors and display them???? END;
问题: