@@ -3459,6 +3459,38 @@ pub enum Statement {
3459
3459
///
3460
3460
/// See <https://learn.microsoft.com/en-us/sql/t-sql/statements/set-statements-transact-sql>
3461
3461
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
+ }
3462
3494
}
3463
3495
3464
3496
impl fmt:: Display for Statement {
@@ -5044,6 +5076,24 @@ impl fmt::Display for Statement {
5044
5076
Statement :: RenameTable ( rename_tables) => {
5045
5077
write ! ( f, "RENAME TABLE {}" , display_comma_separated( rename_tables) )
5046
5078
}
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
+
5047
5097
Statement :: List ( command) => write ! ( f, "LIST {command}" ) ,
5048
5098
Statement :: Remove ( command) => write ! ( f, "REMOVE {command}" ) ,
5049
5099
Statement :: SetSessionParam ( kind) => write ! ( f, "SET {kind}" ) ,
0 commit comments