I have noticed that when I pass a (valid) CREATE FUNCTION statement to TSqlParser my listener receives a call to EnterCreate_or_alter_procedure()
I am using the latest versions of TSqlLexer.g4 & TSqlParser.g4.
My output also shows
Exception thrown: 'Antlr4.Runtime.InputMismatchException' in Antlr4.Runtime.dll
line 1:7 mismatched input 'FUNCTION' expecting {'OR', 'PROC', 'PROCEDURE'}
What could be causing this?
I found the issue.
It was a copy-paste error from a previous project in which I was only interested in Stored Procedures, hence, I was passing a StoredProcedure context to the walker, not batch().
Related
In my SSIS Script Component Task (NOT the Script task, which can be added to a Control Flow, but the Script Component Task, which is added within Data Flows), I added some error handling in the catch part of a try, catch block:
// No connection was created. Exit gracefully
bool cancelOnError = false;
ComponentMetaData.FireError(ErrorCode: 10, SubComponent: "SubComponent",
Description: "Couldn't set up the connection. This could be because an invalid host was
provided, or due to a firewall blocking the connection.", HelpFile: "", HelpContext: 0,
pbCancel: out cancelOnError);
This all works fine, with the script task catching the error I raise in my code. I can also see the error in the logs:
Error: 0xA at DFT Extract, SubComponent: Couldn't set up the connection.
This could be because an invalid host was provided, or due to a firewall
blocking the connection.
However, the icon on on the task is green, and a subsequent task I defined to process results gets fired (there is nothing to process, though, as this particular error occurs prior to processing any data):
The Data Flow correctly shows a red cross icon. Is there any way I can change the icon on the Script Component, or a better way for me to (elegantly) simulate a showstopping error?
I found this page on Microsoft, showing the difference between Script Task and Script Components, which also states:
The Script component runs as a part of the Data Flow task and does not
report results using either of these properties.
That doesn't have me very hopeful, but I am hoping someone might have a work around. I primarily think that showing the green icon is somewhat misleading when we trap an error.
Why not just changing the cancelonerror value to true
bool cancelOnError = true;
Or you can use Throw exception method
throw new Exception("Couldn't set up the connection. This could be because an invalid host was
provided, or due to a firewall blocking the connection.");
Workaround
If your goal is to ignore rows that was not processed correctly, the best way is to add a Column to the OutputBuffer (of type DT_BOOL), and set this column value to False if there is an error , else it's value must be True.
And add a conditional split after the script component to filter rows based on this Column. With a similar expression:
[FlagColumn] == True
I have an Access database was created, it's working perfectly. After successfully splitting the database to back and front end I shared the _be file in shared drive and front end file in my local, I tried to run the front end and I am getting error when macro is executing:
I even put the back and front end in my local machine but still I am getting the error, I tried to remove the macros but still getting errors since I am not the one developed this application.
Dim fdb As Database
Dim utab As Table, otab As Table
DBEngine.SystemDB = "System.mdw"
Set fdb = CurrentDb()
Set utab = fdb.OpenTable("Users")
Set otab = fdb.OpenTable("Organization")
After tracing the function findorg() I found this error
Item not found in the collection
For this line
Set utab = fdb.OpenTable("Users")
I tried to change the code to be
Set utab = fdb.Rescordsets("Users")
But still I am getting the same error.
Note that I am using back and front end, I have all my tables linked.
"Users" table is not linked in the database in which you are running this code. Link it again and check, check for all tables that should also be linked.
i was able to solve the issue by using DAO 3.6 object library, as i found that the current database application is using DAO 2.5, so i recompiled the application and fixed all errors. also i managed to rename the functions that's been called by macro, i found that in macro when i write calling function as findorg() will not work, but in function name i specify "findorg" between double quote, which run successfully.
I am new to ADF. Please help. Pasting a snippet of my code:-
I am unable to print a new line message with \n.
<af:message id="errMessage" message="#{backingBeanScope.ta_del_entUiBean.errorMessage}" messageType="error"
visible="#{backingBeanScope.ta_del_entUiBean.error}"/>
public String getErrorMessage()
{
return message;
}
message contains a String this way, say : The following error have occurred. \n 1. Null ponter exception. \n 2. ODBC Exception \n. 3. JDBC Exception
The output is .
The following error have occurred. 1. Null ponter exception. 2. ODBC Exception . 3. JDBC Exception
How do I make it appear as
The following error have occurred.
1. Null ponter exception.
2. ODBC Exception
3. JDBC Exception
Thanks a lot for the help. The Java Platform version is 1.7.0_51 and the `Jdev` version is 12.1.3.0
I had the same issue. But our client was using IE browser. It works well in IE browser.
The problem with the af:message or af:messages components is that they firstly get rendered on the page, and after that, the content will be attached. That's why when you insert a text containing special characters like "\n" or "\r" they will be printed as they are (actually, they are know only to the compiler who knows how to parse them, but remember, you are using an ADF faces component, not the standard output like in the case of System.out.println() ).
With this in mind, it should be clear that you have to instruct the browser how to print the content. How? Easy, just by inserting HTML tags inside your message body. In your case, the message String should be:
<html><body>
The following error have occurred.<br/>
1. Null ponter exception.<br/>
2. ODBC Exception<br/>
3. JDBC Exception<br/>
</body></html>
Or you can enclose the lines within a paragraph tag instead ( < p > ).
I am new to stored procedures and am just curious how things are done. What I would like to know is how to display a message if a user tries to execute a procedure that he has no rights on ?
From what I can fathom, SQL Server itself takes care of the message. I tried this way (inside a stored procedure) :
BEGIN
try
DELETE from MYTABLE
END TRY
BEGIN CATCH
SELECT ERROR_MESSAGE() AS ErrorMessage;
END CATCH;
and it makes no difference weather I write this or not. The error is the same. Didnt figure out how to write your own message though ...
If a user tries to execute a stored procedure or user-defined function (UDF) that they have not been granted permissions to, either explicitly or implicitly through one or more role memberships, then SQL Server will handle the exception and error message. You cannot set a message within that code as by definition the user is not allowed to execute it to get any error message or error handling that would be inside of it.
If you want a custom message, you need to catch the SQL Exception from the app side (there should be an error code that you can test for indicating "Permission Denied") and then just return your custom message.
There is fix message or say default message display when you try to access unauthorized object.
There is so many security feature comes, like user, role, schema etc. If anything mismatch, you get the error "Could not find stored procedure 'guest.get_procedureName'."
suppose I was created a procedure with default schema(dbo) the name procedure1.
exec dbo.procedure1 para1value,'para2value', null,para4value etc.
exec guest.procedure1 para1value,'para2value', null,para4value etc.
Now if everything fine, first one give me data to sql side and C# side.
But the second will give me the above error.
Nothing to handle in the sqlserver side for this type of security, As above your code, try catch is same work as C#, but ideally, it only need when you explicitly want the message from sql return to show directly to ui i.e. custom logic error message, while you run the sp or when mismatch the data etc.
For the c# point of view, you can get this message in catch, so you can do like.
public method
{
try
{
.....
}
catch(Exception ex)
{
if (ex.Message.Contains("Could not find"))
//give any your custom message or throw ex
}
}
try
DoTheThing();
except
on E:Exception
ShowMessage("Something Went Wrong! : " + E.Message);
end;
This shows a custom message (of sorts) and it also gives you a means to examine the contents of the error via 'E'.
You can also handle more specific exceptions
except
on E:ESomeSpecificException
// ----
end;
--
As others have pointed out - there is no point in trying to catch the error inside the stored proc - the user doesnt have access to it ... by definition
I've created an C# class that contains 2 static method and I successfully created an Assembly in SQL 2005. When I try to create a table-valued function from that Assembly I get the following error:
Msg 6509, Level 16, State 36, Procedure , Line 2
An error occurred while gathering metadata from assembly '' with HRESULT 0x80004005.
We have other CLR functions that are that are with in the same dll and seem to work fine. I tried to emulate what the other functions are doing, but I can't seem to get this function to work.
All the documentation online doesn't seem to help
I had the same problem. I changed the return value in the C# method to IEnumerable insted of DataTable and WALLLLLA.
no problem.
GOOD LUCK
tsadok