Omer-Pitou
asked on
SQL Server - Bulk statements execution
Hi,
I am using SQL Server 2008R2, and noticed that every time I sent a group of statements in once for execution, and there is an error in a statement positioned in the middle, SQL Server will stop the execution (which is right), but can't return back the error message to the client.
Example
globalStmt = stmt1
globalStmt += "; " + stmt2
globalStmt += "; " + stmt3
globalStmt += "; " + stmt4
globalStmt += "; " + stmt5
try
mydatabaseObject.begintran s()
mydatabaseObject.executeSQ L(globalSt mt)
mydatabaseObject.commit()
catch (exception e)
mydatabaseObject.rollback( )
msgbox(message())
endtry
Let's say stmt2 has a syntax error, the rest of stmts won't be executed (which is right), but I am not getting back an error when it is a group of statements sent for execution.
Is there any SQL Server Command that can force this to happen, as it does when it is a single statement?
Thanks for your inputs.
I am using SQL Server 2008R2, and noticed that every time I sent a group of statements in once for execution, and there is an error in a statement positioned in the middle, SQL Server will stop the execution (which is right), but can't return back the error message to the client.
Example
globalStmt = stmt1
globalStmt += "; " + stmt2
globalStmt += "; " + stmt3
globalStmt += "; " + stmt4
globalStmt += "; " + stmt5
try
mydatabaseObject.begintran
mydatabaseObject.executeSQ
mydatabaseObject.commit()
catch (exception e)
mydatabaseObject.rollback(
msgbox(message())
endtry
Let's say stmt2 has a syntax error, the rest of stmts won't be executed (which is right), but I am not getting back an error when it is a group of statements sent for execution.
Is there any SQL Server Command that can force this to happen, as it does when it is a single statement?
Thanks for your inputs.
ASKER
I am using dBase Plus.
The type of mydatabaseObject is a database object
The type of mydatabaseObject is a database object
Then, please, change the topic. And I'm out.. :) The last time I've seen dBase was in the last millenium.
ASKER
This isn't about dbase. I can track the same error using mysql.
ASKER
The last version of dbase came out like 6 months ago. I don't which dbase you referring to.
I wanted to express that, if it's an dBase issue, that
1) the topic is wrong.
2) I don't have a clue. Cause the last time I've worked with dBase was in the 90s.
Where does MySQL comes now from??
Can you please rephrase your question and topic? SQL Server, dBase, MySQL and an incomplete C#.NET code snippet..
btw, "a database object" is not really a type, when we are talking about C#.NET here.
p.s. have you read the link about SqlException?
1) the topic is wrong.
2) I don't have a clue. Cause the last time I've worked with dBase was in the 90s.
Where does MySQL comes now from??
Can you please rephrase your question and topic? SQL Server, dBase, MySQL and an incomplete C#.NET code snippet..
btw, "a database object" is not really a type, when we are talking about C#.NET here.
p.s. have you read the link about SqlException?
ASKER
I am a little bit confused, and surprised that you refer to c#.net, while I didn't mention that in one of my message.
Anyway I have a workaround for that: I will just submit my statements individually, and from this, I can be able to track what statement is causing problems.
-> btw, "a database object" is not really a type, when we are talking about C#.NET here.
mydatabaseObject is an instance of the Class DATABASE of dBASE. So, it is an object, as It inherits attributes and methods of that class. Some of the methods are begintrans(), executeSQL(), commit(), etc... as indicated in my first message.
The reason why I mentioned MySQL is that I can sent a group of statements in once, and track which one causes problem in try statement.
Thanks.
Anyway I have a workaround for that: I will just submit my statements individually, and from this, I can be able to track what statement is causing problems.
-> btw, "a database object" is not really a type, when we are talking about C#.NET here.
mydatabaseObject is an instance of the Class DATABASE of dBASE. So, it is an object, as It inherits attributes and methods of that class. Some of the methods are begintrans(), executeSQL(), commit(), etc... as indicated in my first message.
The reason why I mentioned MySQL is that I can sent a group of statements in once, and track which one causes problem in try statement.
Thanks.
Your code looks like .net and with SQL Server this is the most common stack. Thus my mistake. So, please create a new question with topic dbase and delete my nonsense.
Your problem is only a dbase problem.
Your problem is only a dbase problem.
This doesn't looks like SQL Server code. It's similar but isn't T-SQL.
Can you share with us the tools that you are using for coding?
Can you share with us the tools that you are using for coding?
@Vitor: A new thread, properly tagged with more details in the op, makes imho more sense. Too much noise from me.
ASKER
Only the code included in stmt variables are SQL Server
And how do you pretend to run this?
ASKER
From dBase, there are methods to run sql statements
executeSQL(stmt),
executeSQL(stmt),
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Stored procedure will help to track individual statement error while executing
ASKER
Stored procedure in this case will help to track individual statement error while executing
ASKER
Stored procedure will help to track individual statement error while executing
Your code sample is also too vague. What types are involved, especially what type has mydatabaseObject?