@@ -3459,6 +3459,38 @@ pub enum Statement {
34593459 ///
34603460 /// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
34613461 SetSessionParam ( SetSessionParamKind ) ,
3462+ /// RaiseError (MSSQL)
3463+ /// RAISERROR ( { msg_id | msg_str | @local_variable }
3464+ /// { , severity , state }
3465+ /// [ , argument [ , ...n ] ] )
3466+ /// [ WITH option [ , ...n ] ]
3467+ /// See <https://learn.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql?view=sql-server-ver16>
3468+ RaisError {
3469+ message : Box < Expr > ,
3470+ severity : Box < Expr > ,
3471+ state : Box < Expr > ,
3472+ arguments : Vec < Expr > ,
3473+ options : Vec < RaisErrorOption > ,
3474+ } ,
3475+ }
3476+
3477+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
3478+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
3479+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
3480+ pub enum RaisErrorOption {
3481+ Log ,
3482+ NoWait ,
3483+ SetError ,
3484+ }
3485+
3486+ impl fmt:: Display for RaisErrorOption {
3487+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
3488+ match self {
3489+ RaisErrorOption :: Log => write ! ( f, "LOG" ) ,
3490+ RaisErrorOption :: NoWait => write ! ( f, "NOWAIT" ) ,
3491+ RaisErrorOption :: SetError => write ! ( f, "SETERROR" ) ,
3492+ }
3493+ }
34623494}
34633495
34643496impl fmt:: Display for Statement {
@@ -5044,6 +5076,24 @@ impl fmt::Display for Statement {
50445076 Statement :: RenameTable ( rename_tables) => {
50455077 write ! ( f, "RENAME TABLE {}" , display_comma_separated( rename_tables) )
50465078 }
5079+ Statement :: RaisError {
5080+ message,
5081+ severity,
5082+ state,
5083+ arguments,
5084+ options,
5085+ } => {
5086+ write ! ( f, "RAISERROR({message}, {severity}, {state}" ) ?;
5087+ if !arguments. is_empty ( ) {
5088+ write ! ( f, ", {}" , display_comma_separated( arguments) ) ?;
5089+ }
5090+ write ! ( f, ")" ) ?;
5091+ if !options. is_empty ( ) {
5092+ write ! ( f, " WITH {}" , display_comma_separated( options) ) ?;
5093+ }
5094+ Ok ( ( ) )
5095+ }
5096+
50475097 Statement :: List ( command) => write ! ( f, "LIST {command}" ) ,
50485098 Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
50495099 Statement :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
0 commit comments