Strange issue with stored procedure - stored-procedures

I am having a strange issue with a stored procedure where a variable ErrMsg in below just does not seem to be getting initialized. Tried debugging and it just has a value of null and the assignment operation simply doesn't seem to work??
B

Related

Use of variable SET statement in stored procedures compiles but fires exception at runtime

In a Snowflake SQL-stored procedure, I would like to SET value of a variable like the following:
DROP PROCEDURE IF EXISTS MY_DB.MY_SCHEMA.MY_SP_SQL();
CREATE PROCEDURE MY_DB.MY_SCHEMA.MY_SP_SQL()
RETURNS STRING NOT NULL
LANGUAGE SQL
AS
DECLARE
retValue VARCHAR;
BEGIN
SET retVal = '';
[...]
Everything rocks at compile time but fails at runtime with the following exception
Uncaught exception of type 'STATEMENT_ERROR' on line x at position y :
Stored procedure execution error: Unsupported statement type 'SET'.
despite documentation says this to be possible ๐Ÿคจ
Can someone gently explain to the noob of me? ๐Ÿ˜
Thanks,
Within a SQL stored procedure use LET instead of SET. The syntax for stored procedures (also known as Snowflake Scripting) is different from interactive SQL. The valid commands in SQL scripting are described in the Snowflake Scripting Reference

SPL routine is no longer valid

I have a stored procedure named
"component_allocate"
When I execute this procedure using PreparedStatement, I get the following error
[Error Code: -721, SQL State: IX000] SPL routine(AAABxg) is no longer valid.
I get the same error even when I execute the procedure directly on DbVisualizer.
I tried updating the statistics on the procedure using
update statistics for procedure component_allocate
That didn't help. Still getting the same error.
Has anyone else faced this problem in informix ? How do I resolve this?
Did you check this?
"If an index was added after the statement was prepared, you must prepare the statement again and declare the cursor again. You cannot simply reopen the cursor if it was based on a prepared statement that is no longer valid."
source:
http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.docnotes.doc/uc3/ids_perf_docnotes_10.0.html

Delphi OLE - How to avoid errors like "The requested member of the collection does not exist"?

I'm automating Word with Delphi, but some times I got an error message:
The requested member of the collection
does not exist
It seems that the Item member of the Styles collection class does not always exist and some times causes the above mentioned error. My workaround is to catch the exception and skip it, but is there anyway to detect it instead of using the try...except block? The problem with the try...except block is that when debugging the raised exception is annoying...
My code example:
var
aWordDoc: _WordDocument
i: Integer;
ovI: OleVariant;
wordStyle: Style;
begin
for i := 1 to aWordDoc.Styles.Count do
begin
ovI := i;
try
wordStyle := aWordDoc.Styles.Item(ovI);
except
Continue;//skip if any error occurred.
end;
//do something with wordStyle
end;
end
If the compiler accepts it, but it sometimes cannot happen to exist, it is probably IDispatch based latebinding. IDispatch objects can be queried. Maybe carefully working yourself up the tree querying every object for the next would work.
You would then roughly be doing what the compiler does, except that that one throws an exception if somethines doesn't exist. (and if the exception comes in from COM, maybe a slightly different code path can test more).
Sorry to have no readily made code.
I get that message when a bookmark that I'm trying to fill from Word doesn't exist so i have a process that checks first, but I'm not sure the same method would work for you.
procedure MergeData(strBookMark, strData : string);
begin
if WinWord.ActiveDocument.Bookmarks.Exists(strBookMark) = True then
WinWord.ActiveDocument.FormFields.Item(strBookMark).Result := strData;
end;
It has nothing to do with the Item function not being there. The Item function does exists, but the index you give seems to be wrong.
See this msdn article.
An invalid index seems really weird, because you are performing a for loop from 1 to Styles.Count. So if there is no Style, you should not enter the loop.
The only plausible explanation I can think of is that while you are in your loop, the Styles.Count changes and you are getting out of bounds. Are you deleting styles in your loop perhaps? Try a loop going from Styles.Count downto 1 or try a While loop, evaluating Styles.Count at every iteration.
Other things I can think of, but are very unlikely:
While assigning I to ovI, it gets converted to an OleString, so Word searches for a style named "I", instead of a Style at I
While assigning I to ovI, something in the conversion goes wrong and it gets in the range of $FFFFFFA5 - $FFFFFFFF, which are constants for Builtin styles.
try checking if it is null or not with a IF statement

Delphi: F2084 Internal Error T2575

Do anybody know what this error means?
It comes and goes in one of my units. Adding a space or a lineshift will sometime solve it, sometime not...
I'm using Delphi 2007.
Here is a Delphi internal error guide that will perhaps help you. Internal error often can be resolved by deleting DCU files, restarting the IDE or not using a tool that speeds up Delphi start (like DelphiSpeedUp).
But in most cases, this is some weird bug in the Delphi compiler and if you know to work around it and this won't be to costy, do this and be happy. I once had the console version dcc32 crashing (IDE compiled fine) when I increased a variable with Inc and using addition instead of Inc solved the problem...
Best thing to do is report this to CodeGear. It really helps if you can find a way to consistently cause the bug on purpose, so they can track it down more easily.
One simple way to get an internal error is to use cut&paste to create a new routine. I moved all code within an IF block to a new procedure and got internal error T2335 at the End of the new proc (in Delphi 7).
The error was caused by the line "If (Something) then Break;". The problem was, this code was no longer within a loop, so there was nothing to break from. Changing 'Break' to 'Exit' fixed the problem.
So look for Break and Continue statements.
All internal errors are things that shouldn't have happened, but did. Check QC and if it isn't there report it. If you can provide a way to reproduce it that will make it more likely they can fix it.
Usually for internal erros I do a full build or restart Delphi.
I've had this problem too, and i've tested many solutions, but non of them helped me.
then i've found this cause of error:
in error occurring function, i had an Inc() func that was trying to inc a String Variable!!
so i've fixed that bug and everything turned to normal :)
I had another case today (D2010), everything perfectly legal syntax since good ol' Turbo Pascal days:
type
TValueRec = record
selector : (int,str,unk);
intVal : Integer;
strVal : WideString;
unkVal : IUnknown;
end;
Using this record in a method of a generics-based class brought me an "F2084 internal error: AV0661CFEF-R0000000C-0" somewhere in the middle of another unit.
Changing it this way did the trick for me:
type
TValueRecSelector = (int,str,unk);
TValueRec = record
selector : TValueRecSelector;
intVal : Integer;
strVal : WideString;
unkVal : IUnknown;
end;
However, very annoying that such things produce such errors at completely unrelated places in the code.
I got this error in one instance:
procedure TDMData.SetValue(AValue: Word);
var
prevValue: Word;
method: TMethod;
begin
if FValue = AValue then
Exit;
prevValue := FValue;
FValue := AValue;
for method in FValueChangeEvent.Notifications do
TDMDataValueChangeNotification(method)(Self, AValue, prevValue);
end; // <--- Fatal: F2084 Internal Error: T2575
Both the GetNotifications Notifications property and the GetEnumerator method of the record returned by GetNotifications had an inline directive. Only by removing the inline from GetEnumerator the problem went away.
Note: similar functions were not causing this internal error!

AV When using a Procedure from one Component called by another

Im not sure if i have explaned this the best i can but, here we go...
I have 2 Custom components on a form, Which are link together at design time through the IDE. Whenever i call a procedure from on of the Component i get the Access violation,
Access violation at address 0049A614
in module 'Project2.exe'. Read of
address 00000034.
This is a small section of my code
TMyClient = class(TClientSocket)
{...}
end;
and...
TPresence = class(TComponent)
private
ftheClient: TMyClient
public
procedure SetStatus(status: string);
published
property UserName : string read fUserName write fUserName;
property theClient: TMyClient read ftheClient write ftheClient;
end;
procedure TPresence.SetStatus(status: string);
begin
try
***** if theClient = nil then
Exception.Create('theClient is Nil');
except
on e:Exception do
MessageDlg(e.classname+', '+e.message, mtWarning, [mbOK], 0);
end;
{...}
end;
0049A614 is at the *****, and the IDE stops here.
I Have also tried to do the assign at run time with
Presence1.theClient := MyClient1;
with no luck
using procedures from Presence1 or MyClient1 that do not rely on each other work fine.
Delphi 7
Follow Up:
from mghie comments, i rethought about it.
I removed the TPresence Component from the form (which caused some strange IDE errors, that might have had something to do with it) and created it design time, assigning everything that was needed. Now it works, but putting the TPresence Component back on the from brings the error back.
Thankyou for your help guys, i should be able to work this one out now, if i can't ill reopen another question :)
You seem to be thinking that the exception is raised because the client field of Presence1 is not set - if you do however get the exception "Read of address 00000034" it means that the Self pointer in the SetStatus() call is nil. That would indicate that you call SetStatus() on an unassigned TPresence reference. It is not really possible to tell the reason for that from the snippet you posted, but it should get you started debugging.
I would still advise you to write a proper setter method for all component references in your own custom components - first because you have a better hook when debugging such problems (you can set a breakpoint there), and second because you should always call TComponent.FreeNotification() on such linked components to be able to track their destruction and set the internal reference to nil.
We probably need more of your code. It is possible you are not correctly creating an instance of TPresence which would give you the error you are experiencing. Try to give us a simple as possible code snippet that causes your error.

Resources