Questions tagged [error-handling]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
45 views

Is “deadlock detected” really an error? Should I be suppressing them after handling them?

A while ago, I spent a nightmarish number of weeks dealing with "deadlock detected" and trying to figure out how to handle it. I ended up finally handling it in such a manner that my code is ...
1
vote
0answers
19 views

Error run pgAdmin4 Fatal Error: The pgAdmin 4 server could not be contacted

I had installed PostgreSQL 10 and everythings perfect after i install but now i have this issue. Fatal Error: The pgAdmin 4 server could not be contacted anyone know what could be the problem?
-2
votes
2answers
19 views

Best way to double check query results are right on large tables [closed]

When you write SQL query between big tables what is a good way to check that you have the correct query when the resulting table is 2000+ lines?
0
votes
3answers
130 views

BULK INSERT continue on PRIMARY KEY error

I get a CSV file with a several million records every few days. I need to insert them into our database. What I do is quite straightforward: BULK INSERT dbo.activity FROM 'C:\tmp\activity.csv' WITH ( ...
-1
votes
2answers
33 views

How do I make PostgreSQL not log specific errors?

ERROR: deadlock detected at character 13 My PG log is full of this, but the thing is, I already handle it (after years of frustrations) in my application. I detect them and repeat until they go ...
1
vote
1answer
47 views

TSQL success or failure result of EXEC dynamic SQL

Based on the following code: /* This SP takes a query and a unique temporary table name as input... The outputs is a string with the command to create the tmp table based on the query that is given ...
0
votes
1answer
68 views

TRY/CATCH only reports the last (and most useless) error

(This is SQL Server 2016 SP2-CU12.) When running this command interactively, I see the quite useful Msg 3035, Level 16, State 1. BACKUP DATABASE @DB TO DISK = @targetfile WITH DIFFERENTIAL, RETAINDAYS ...
0
votes
2answers
38 views

How to make MySQL 8 alert when integer overflow happens during INSERT … ON DUPLICATE KEY?

Let's consider we have a simple table with auto-incrementing integer ID and some unique column: CREATE TABLE `test` ( `id` int unsigned NOT NULL AUTO_INCREMENT, `value` tinyint DEFAULT NULL, ...
0
votes
2answers
33 views

How to catch all the errors happening during the execution of an SQL file containing multiple INSERT INTO statements to insert multiple rows?

I've got a sql file TW_popul.sql containing multiple INSERT statement: INSERT INTO conversion_fee (FEE_ID, FEE_AMOUNT, DISCOUNT_AMOUNT, FEE_TYPE, PAYMENT_ORDER_ID) VALUES (32353357, 8.67, 0, 'com....
3
votes
1answer
316 views

Custom error code class and numbers for Postgres stored functions

I'm writing a collection of stored functions in Postgres 11.5, and want to RAISE EXCEPTION when various pre-conditions are not met. For example, a null or empty string with a string is required, or an ...
-1
votes
1answer
178 views

Every Attempt at Error Handling Fails with GET

UPDATED (12.3.2019) I'm using MySQL 8.x and every attempt at putting any error handling that provides internal details fails on the "GET" (red highlight) stating: GET is not valid at this position ...
3
votes
1answer
115 views

Getting all undeclared variables from query

Imagine you try to run the following query: SELECT * FROM dbo.Customers c WHERE id = @id AND dateTimeCreated = @date You'll get an error message along the lines of Must declare the scalar ...
1
vote
1answer
52 views

Do a lot of error checks affect query performance and is it bad practice?

If I have a stored procedure with a handful of error checks that come before the queries are executed and throw exceptions as necessary, could this affect performance? Is it bad practice to do this? ...
0
votes
0answers
20 views

Is it possible to create an SQL transaction that rollbacks on syntax errors?

In may day-to-day job, I often have to create SQL files containing minor changes (no DDL operation usually) in order to migrate those to production databases easily. The problem is, even with syntax ...
2
votes
0answers
108 views

Catching QUOTED_IDENTIFIER Errors in Trigger without aborting transaction

Is there a way to catch a QUOTED_IDENTIFIER error without failing the transaction? I have assembled a minimal test case here. The trigger must have SET QUOTED_IDENTIFIER ON because it uses XML data ...
15
votes
1answer
19k views

Try catch equivalent in Postgres

Do we have a try catch equivalent in Postgres? I have written some user defined functions that are called by trigger. I (don't) want to ignore errors so that flow does not get interrupted.
6
votes
1answer
874 views

SQL Server - TRY/CATCH does not work in certain cases

How can I write guarded code that invokes the CATCH code block in every expected* case (without doing funky junk like wrapping everything in dynamic SQL)? For example, this does not work: Define a ...
0
votes
1answer
137 views

how to convert from raiserror to throw in the current context?

I have a function that checks is the file is present on disk in an specific location. Using that function I am checking for the latest backup, in the code below. If we don't have a backup anymore, ...
2
votes
1answer
96 views

why the processing is sometimes terminated , sometimes not

DECLARE @Error int; INSERT INTO Person.BusinessEntityContact (BusinessEntityID ,PersonID ,ContactTypeID) VALUES (0,0,1); SELECT @Error = @@ERROR; PRINT ‘The Value of @Error is ‘ + CONVERT(varchar,...
0
votes
1answer
257 views

Why is my TRY CATCH block in SQL Server immediately exiting on error completely ignoring the remaining code in the block, including my error handling?

Below is a snippet of my TRY/CATCH logic within a stored procedure with error handling (I did not include all of the DECLARE statements). This is being ran within a stored procedure, however I am ...
2
votes
1answer
124 views

Object id error in sql server

I want to know the object referenced as an associatedObjectId in a deadlock graph, so I ran the below query: SELECT OBJECT_NAME(1234560112364076) I get the following error: Arithmetic overflow ...
0
votes
0answers
103 views

Can I force a LOAD DATA LOCAL statement to abort if an error is not loaded?

I am trying to load a CSV file into a MySQL table with the load data local statement. After loading it, the statement reports Query OK, 1030 rows affected, 7314 warnings (0.03 sec) Records: 1043 ...
2
votes
1answer
123 views

Does the “don't use errors for flow control” axiom apply to postgres?

In traditional programming there is an axiom that states, "do not use errors for flow control". A general example is to throw an error then catch the error instead of using an ordinary conditional ...
1
vote
1answer
3k views

SQL Creating Error Log Table Benefits

We are conducting a datawarehouse project, moving data from Staging database to Kimball Data Warehouse. What is the purpose of creating a custom stored procedure Error Log Table? I am seeing a lot ...
0
votes
0answers
3k views

SQL Server Error 14013 - This database is not enabled for publication

I am trying to configure a database publication with T-SQL. use master exec sp_replicationdboption @dbname='anun', @optname=N'publish', @value = N'true'; It runs successfully and I see ...
2
votes
0answers
232 views

How get process that is locking Database on SQLite?

I'm developing a iOS app using SQLite. I've got a class to manage SQL's operations, basically read, write and update. In many cases I get a SQLITE_BUSY error, so I want know which process is using the ...
0
votes
1answer
398 views

Find if Stored Procedure Error

Is there a method in T-SQL to see if error occurred in Stored Procedure, without the use of @Output or try catch? We have a lot of legacy code 200+ stored procedures. I have seen @Output method and ...
1
vote
1answer
69 views

How to index of filter extended event files in Sql Server

I am collecting errors data using the error_reported event and saving the data on XEL files. The problem is that there are hundreds of thousands of errors over there and querying them can take a lot ...
0
votes
2answers
199 views

Impossible to log errors after dooming a transaction within an INSERT-EXEC statement

We have a stored procedure that does some work within a transaction, wrapped within a stored procedure that returns some result data using the INSERT-EXEC method of sharing data. After observing the ...
1
vote
1answer
191 views

Should SQL Server 2000 throw an error if update statement fails within a SP?

I'm troubleshooting an issue on SQL Server 2000 where it appears that a update statement in a stored procedure failed, and the check for @@ERROR <> 0 didn't catch it, so the transaction was ...
0
votes
2answers
54 views

how to run once a bunch of generated scripts with exception handling?

Before I restore a database, I need to save the contents of a table called dbo.ref_systemSettings if it exists. So I created a script that calls a procedure that will save the contents of this table ...
0
votes
1answer
51 views

job send email to developers upon complexion and include DBAs if it fails

I have a job that sends an email to an operator (which contains a list of emails within it) upon complexion. Some of these people that are on that list are the developers who build everything in that ...
0
votes
0answers
503 views

SSIS: Using Event Viewer to Trace Errors of A Package

Overview A package was developed due to a planned database server migration, and other teams with a dependency on legacy cross-database queries. There is a policy of not having Linked Servers, so an ...
2
votes
1answer
2k views

SQL Server TRY..CATCH resume on terminating error

I'm trying to get a master stored procedure to execute through to completion, where the master SP calls child SPs to perform modular tasks that are independent of each other (i.e. - if one fails, that ...
2
votes
4answers
527 views

SQL Server - Any way to validate insert statements for mismatching column names?

I like to be verbose in my coding, so my typical insert statement looks like this: INSERT INTO MyTable ( Column1 ,Column2 ,Column3 ,Column4 ,Column5 ,Column6 ) SELECT ...
0
votes
0answers
1k views

SQL Server - What is the RAISERROR substitution parameter for boolean/bit type?

I'd like to quickly dump some context into an error message including some boolean flags using the handy-dandy substitution parameters of RAISERROR such as CREATE PROCEDURE MyProc ( @param1 INT = ...
0
votes
1answer
755 views

SQL Server Profiler Exception tracing - Error procedure and line number omitted

Is there a trace configuration or setting that will enable the profiler to output ERROR_PROCEDURE() and ERROR_LINE() information that is always available when writing manual error handling in CATCH ...
1
vote
2answers
9k views

How to rollback a SQL Server transaction and use output param?

I am trying to set an output param in a stored procedure, but I think that when I rollback the transaction I think I'm also rolling back the assignment to @out. Is that correct? If so, how can I ...
0
votes
2answers
4k views

How to avoid primary key violation while doing inserts

I have a code which does insert into destination table from source, but at times we are ending up with deadlocks. Due to deadlock , I have to rerun this code again. while i do re-run , I end up with ...
8
votes
4answers
9k views

PostgreSQL alternative to SQL Server’s `try_cast` function

Microsoft SQL Server has what I consider a remarkably sensible function, try_cast() which returns a null if the cast is unsuccessful, rather than raising an error. This makes it possible to then use ...
3
votes
2answers
2k views

MySQL Stored Procedure not throwing error if it contains a query that succeeds

I am writing a simple MySQL Stored Procedure, and calling it from PHP using PDO. This is just simple enough to illustrate the problem I'm having. This procedure test_procedure_2, does not throw any ...
4
votes
3answers
19k views

SSPI handshake failed with error code 0x8009030c, state 14

DESCRIPTION: SSPI handshake failed with error code 0x8009030c, state 14 while establishing a connection with integrated security; the connection has been closed. Reason: AcceptSecurityContext ...
0
votes
1answer
179 views

How to find out which records are causing an exception in a select statement?

I have a select query that I use as part of an insert statement, but it raises the following exception: The conversion of a varchar data type to a datetime data type resulted in an out-of-range value ...
3
votes
0answers
228 views

Any way to catch when xp_readerrorlog fails? [duplicate]

I'm trying to query the ErrorLog files, but it sometimes fails on some of my servers. For some reason a file go missing from time to time. I do not know why. I do not think that I deleted the file :-)....
7
votes
1answer
4k views

Output parameter not set if stored procedure fails inside a TRY / CATCH

In SQL Server 2008 (but also in 2014). Let's consider a procedure that has an output parameter. This procedure may produce an error (and will in the following example). I note that the behaviour of ...
2
votes
0answers
55 views

Logging multiple error message in the TRY…CATCH when doing BACKUP DATABASE [duplicate]

When I try below: backup database not_existing_db to disk = 'E:\Backup\not_existing_db.bak' SSMS shows two error messages: Msg 911, Level 16, State 11, Line 22 Database 'not_existing_db' does not ...
0
votes
2answers
6k views

Execute pgScript in pgAdmin 4 while skipping errors

In pgAdmin3, via the SQL Editor, there is an Execute pgScript button which (unlike Execute Query) would run through the entire script, skipping errors. The SQL editor in pgAdmin4 doesn't appear have ...
1
vote
3answers
857 views

Purpose of Try/Catch without Transactions

I have come across the following code (SQL Server 2016, 2008-compatible database): CREATE PROCEDURE myProc AS BEGIN DECLARE @ERRORMESSAGE As VARCHAR(1000) BEGIN TRY DELETE FROM ...
1
vote
1answer
2k views

drop table in a begin try begin catch block - is there any loss of performance?

The code below is a dynamic sql that will give you a list of all alerts in your system. It works. There is a temp table in the code for reasons beyond this question. This question is related to the ...
3
votes
1answer
6k views

How to handle errors in a transaction in a stored procedure?

I need to catch errors in a transaction in a stored procedure and log them in a table in the catch block. After starting the transaction, a loop will attempt to insert a handful of values in the ...