473,890 Members | 1,195 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Ignore Error in SP

Is there a way to make a SP ignore an error?

e.g. I'm looping through each database on a server, checking of a table
exists then selecting a value from that table. Now I have a database put
onto the server where the table exists but all column names are
different, my SP is not interested in this database so when it errors
with invalid column name I want it to move onto the next databse and not
display any error message.
Jul 20 '05 #1
2 3374

"Trev@Work" <no.email@pleas e> wrote in message
news:41******** *************** @news.easynet.c o.uk...
Is there a way to make a SP ignore an error?

e.g. I'm looping through each database on a server, checking of a table
exists then selecting a value from that table. Now I have a database put
onto the server where the table exists but all column names are different,
my SP is not interested in this database so when it errors with invalid
column name I want it to move onto the next databse and not display any
error message.


No - you can't trap errors in MSSQL, you must pass them to the client:

http://www.sommarskog.se/error-handling-II.html

Without more information on what you're trying to do, it's hard to say what
the best solution is, but one option is to test if the column you're
interested in exists:

IF EXISTS (
SELECT *
FROM INFORMATION_SCH EMA.COLUMNS
WHERE TABLE_NAME = '???'
AND COLUMN_NAME = '???'
)
BEGIN
-- DO SOMETHING WITH THE TABLE
END
ELSE
BEGIN
-- MOVE TO NEXT DATABASE
END

Simon
Jul 20 '05 #2
Simon Hayes wrote:
"Trev@Work" <no.email@pleas e> wrote in message
news:41******** *************** @news.easynet.c o.uk...
Is there a way to make a SP ignore an error?

e.g. I'm looping through each database on a server, checking of a table
exists then selecting a value from that table. Now I have a database put
onto the server where the table exists but all column names are different,
my SP is not interested in this database so when it errors with invalid
column name I want it to move onto the next databse and not display any
error message.

No - you can't trap errors in MSSQL, you must pass them to the client:

http://www.sommarskog.se/error-handling-II.html

Without more information on what you're trying to do, it's hard to say what
the best solution is, but one option is to test if the column you're
interested in exists:

IF EXISTS (
SELECT *
FROM INFORMATION_SCH EMA.COLUMNS
WHERE TABLE_NAME = '???'
AND COLUMN_NAME = '???'
)
BEGIN
-- DO SOMETHING WITH THE TABLE
END
ELSE
BEGIN
-- MOVE TO NEXT DATABASE
END


I'm actually identifying the database as belonging to a particular
application, we have a simple profiles table that will have a signature,
e.g.

select [value] from zstblProfile where [key] = 'AppSignature'

This is so I can loop all databases and display a list of databases to
the front end's login screen (only dbs applicable to the FE app).

The exist code above will help, thanks.

Unless there's an easier way to stamp a database?
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
34905
by: Thomas Bartkus | last post by:
The meaning of REPLACE INTO is clear to me. IF the new record presents new key values, then it is inserted as a new record. IF the new record has key values that match a pre-existing record, then the key violation is ignored and the new record *replaces* the pre-existing record. But what about INSERT IGNORE? Is this a synonym for REPLACE INTO - i.e. it does precisely the same thing?
5
12248
by: Chris Mantoulidis | last post by:
Let's say I have this: std::string s1; std::cin >> s1; This will read s1 from cin until it finds a space (or a newline, whichever comes first). Okay this works. But when I want to continue reading it reads what's left over in the cin, and well that's logical.
1
2705
by: windandwaves | last post by:
Are you allowed to use the following syntax in Mysql 4.0.17-nt : INSERT DELAYED IGNORE INTO `mytable` ( `ID` , `A` , `B` ) VALUES ("'.session_id().'", "2", ROUND(NOW()/10000) ); I am particularly interested in the delayed ignore. I want to make sure that no matter what, the instruction is carried out and that, due to indexes, the data is not allowed to go in, that we do not get an error. TIA
23
4117
by: FrancisC | last post by:
#include <stdio.h> int file_copy( char *oldname, char *newname ); int main() { char source, destination; printf("\nEnter source file: ");
4
2052
by: Jackson Miller | last post by:
I notice that postgres does not support IGNORE. I am currently migrating an app from a MySQL datastore to Postgres, and I would really like to use IGNORE. I am curious if there is a recommended work-araound. Thanks, -Jackson
5
8695
by: ma740988 | last post by:
Consider the source: # include <iostream> # include <string> # include <fstream> # include <vector> # include <sstream> using namespace std;
6
2742
by: sandy | last post by:
I seem to ALWAYS need to use cin.ignore in my programs (console apps using Dev C++ for a University course). The problem is that if I don't ignore ENOUGH characters then it's like not having the cin.ignore. If I ignore too many that's just as bad. There has got to be some way to just say 'if there is anything in the input stream or buffer get rid of it' so I can start fresh so to speak. What is it? (It has just GOT to exist...)
2
2694
by: Sanjaylml | last post by:
I have made a form, in which following two Run Time Errors occured, which ultimately, after clicking Debug button, goes to coding of the form: 1) Runtime error 6 "Overflow", if no data exists. 2) Runtime error 2501 "The SendObject action was cancelled". How can I ignore Runtime error. Is their any way to ignore such type of erros. Shall be grateful if anyone help me in this regard. Thanks in advance
1
3431
by: Nimral | last post by:
Hi folks, is there a smart way to develop efficiently that helps me in the following situation: a sub calls a subsub, which calls a subsubsub, and so on. Within a subsubsub an error occurs which I handle, either using on error goto / err.number, or a try... catch block. I display a msgbox (abort,retry,ignore). Implementing retry and ignore is fairly easy using a loop structure. But how about "abort"?
4
5973
by: shodan | last post by:
Hi board, I'm using excel vba to drive my access database. Now I encountered the following problem: I have an update qry to update a table which has an index field. Because of this, I always get the error message that it won't let me update the table. I'm aware of the duplicates, but if I run the update query manually, I can ignore the error and it will only update my table with the first row and just drops the duplciates. This is exactly...
0
9820
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11227
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10812
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10462
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5848
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6041
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4676
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4270
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.