@@ -3441,6 +3441,38 @@ pub enum Statement {
3441
3441
///
3442
3442
/// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
3443
3443
SetSessionParam ( SetSessionParamKind ) ,
3444
+ /// RaiseError (MSSQL)
3445
+ /// RAISERROR ( { msg_id | msg_str | @local_variable }
3446
+ /// { , severity , state }
3447
+ /// [ , argument [ , ...n ] ] )
3448
+ /// [ WITH option [ , ...n ] ]
3449
+ /// See <https://learn.microsoft.com/en-us/sql/t-sql/language-elements/raiserror-transact-sql?view=sql-server-ver16>
3450
+ RaisError {
3451
+ message : Box < Expr > ,
3452
+ severity : Box < Expr > ,
3453
+ state : Box < Expr > ,
3454
+ arguments : Vec < Expr > ,
3455
+ options : Vec < RaisErrorOption > ,
3456
+ } ,
3457
+ }
3458
+
3459
+ #[ derive( Debug , Clone , PartialEq , PartialOrd , Eq , Ord , Hash ) ]
3460
+ #[ cfg_attr( feature = "serde" , derive( Serialize , Deserialize ) ) ]
3461
+ #[ cfg_attr( feature = "visitor" , derive( Visit , VisitMut ) ) ]
3462
+ pub enum RaisErrorOption {
3463
+ Log ,
3464
+ NoWait ,
3465
+ SetError ,
3466
+ }
3467
+
3468
+ impl fmt:: Display for RaisErrorOption {
3469
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
3470
+ match self {
3471
+ RaisErrorOption :: Log => write ! ( f, "LOG" ) ,
3472
+ RaisErrorOption :: NoWait => write ! ( f, "NOWAIT" ) ,
3473
+ RaisErrorOption :: SetError => write ! ( f, "SETERROR" ) ,
3474
+ }
3475
+ }
3444
3476
}
3445
3477
3446
3478
impl fmt:: Display for Statement {
@@ -5026,6 +5058,24 @@ impl fmt::Display for Statement {
5026
5058
Statement :: RenameTable ( rename_tables) => {
5027
5059
write ! ( f, "RENAME TABLE {}" , display_comma_separated( rename_tables) )
5028
5060
}
5061
+ Statement :: RaisError {
5062
+ message,
5063
+ severity,
5064
+ state,
5065
+ arguments,
5066
+ options,
5067
+ } => {
5068
+ write ! ( f, "RAISERROR({message}, {severity}, {state}" ) ?;
5069
+ if !arguments. is_empty ( ) {
5070
+ write ! ( f, ", {}" , display_comma_separated( arguments) ) ?;
5071
+ }
5072
+ write ! ( f, ")" ) ?;
5073
+ if !options. is_empty ( ) {
5074
+ write ! ( f, " WITH {}" , display_comma_separated( options) ) ?;
5075
+ }
5076
+ Ok ( ( ) )
5077
+ }
5078
+
5029
5079
Statement :: List ( command) => write ! ( f, "LIST {command}" ) ,
5030
5080
Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
5031
5081
Statement :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
0 commit comments