Not showing Output from script, no error is being raised
See original GitHub issueSystem information:
- Operating system (distribution) and version: MacOS Mojave 10.14.6
- DBeaver version: 7.1.0
- Additional extensions: none
Connection specification:
- Database name and version : MS SQL Server (SQL Server 2019 running on Linux)
- Driver name: Microsoft JDBC Driver for SQL Server
- Do you use tunnels or proxies (SSH, SOCKS, etc)? : no
Describe the problem you’re observing:
Running simple TRY-CATCH script that has an insert statement that will fail because there is a NULL value in mandatory field.
Problem:
- No error is being raised.
- The ‘Output’ tab is not being shown. It is only showing the ‘Statistic’ tab.
- Query Manager is outputting result: ‘Success’.
*I am running via ‘Execute SQL Script’, have tried ‘Execute SQL Statement’. Both returning identical results.
Steps to reproduce, if exist:
Run script below. You can try running the TRY statement after creating the table, and the result is still the same.
CREATE TABLE dbo.testTable
(
mandatoryVarField VARCHAR(200) NOT NULL,
intFieldA INT,
intFieldB INT
);
GO
print 'begin try ...'
BEGIN TRY
BEGIN TRANSACTION
print 'running transaction ...'
INSERT INTO dbo.testTable(mandatoryVarField, intFieldA, intFieldB)
values(NULL, 2, 2)
COMMIT TRANSACTION
END TRY
BEGIN CATCH
DECLARE @ErrorMessage NVARCHAR(4000)
DECLARE @ErrorSeverity INT
DECLARE @ErrorState INT
SELECT
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY(),
@ErrorState = ERROR_STATE()
RAISERROR (@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
@ErrorState -- State.
)
END CATCH;
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Python script does not work but gives no error message
Anyways, i have here a script i have been working on to randomly generate a password made up of letters, numbers and special...
Read more >Error handling with Python—ArcGIS Pro | Documentation
In the following code, a raise statement is used when an input feature class has been identified as having no features. This is...
Read more >Error handling, "try...catch" - The Modern JavaScript Tutorial
Usually, a script “dies” (immediately stops) in case of an error, printing it to console. But there's a syntax construct try...catch that allows ......
Read more >User input and error handling - Various writings
The program is stored in the file c2f_cml_except1.py. If the command-line argument is missing, the indexing sys.argv[1] , which has an invalid index...
Read more >Python Exceptions: An Introduction - Real Python
Exceptions versus Syntax Errors; Raising an Exception; The AssertionError ... If file.log does not exist, this block of code will output the following:....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
as a workaround you could open Output manually(Ctrl+shift+O or using button in SQL Editor)
Error resolved. I had to put this at the start of my transaction:
SET NOCOUNT ON
Reading similar problem here: https://stackoverflow.com/questions/12989302/java-is-not-catching-ms-sql-stored-procedure-raise-error