question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not showing Output from script, no error is being raised

See original GitHub issue

System 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:closed
  • Created 3 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
uslsscommented, Jun 8, 2020

as a workaround you could open Output manually(Ctrl+shift+O or using button in SQL Editor)

0reactions
jacky-lamcommented, Jun 10, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found