BEGIN 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;
问题:
>如何在T-sql中打印“PRINT”等消息?
>如何提出异常信息的错误?
do $$begin create table yyy(a int); create table yyy(a int); -- this will cause an errorexception when others then raise notice 'The transaction is in an uncommittable state. ' 'Transaction was rolled back'; raise notice '% %',sqlERRM,sqlSTATE;end;$$ language 'plpgsql';
还没有找到行号
总结以上是内存溢出为你收集整理的PostgreSQL异常处理全部内容,希望文章能够帮你解决PostgreSQL异常处理所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)