cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Invalid statement after ALTER TABLE to fix column not found in event

Breck_Carter
Participant
5,048

...and the answer is, from Bruce's comment on his original answer: "@Breck: there is currently no mechanism for automatically recompiling events. You can, of course, put the logic for the event in a procedure which the event calls. – Bruce Hay"


Here's the scenario in 11.0.1.2276: An updated stored procedure event failed at runtime with "column not found" because of a FOR loop which referred to the new name of a column in an existing table when, in fact, the table still had the old column name. An ALTER TABLE was run to fix the column name, and the stored procedure event was re-executed, only to fail with "Invalid statement" (see below). The stored procedure event was recompiled and that got rid of the "Invalid statement" error.

If this is expected behavior, the Help should be updated to mention the possibility that a stored procedure an event should be recompiled:

http://dcx.sybase.com/index.html#1101en/saerrors_en11/errm130.html

Invalid statement 
Error constant SQLE_INVALID_STATEMENT 
ODBC 2 State ERROR 
ODBC 3 State ERROR 
Severity 16 
SQLCODE –130 
SQLSTATE 07W02 
Sybase error code 13628

Probable cause 
The statement identifier generated by a PREPARE passed to the database 
for a further operation is invalid.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

The most likely cause for the problem described here is that the procedure was still being used by at least one connection when the ALTER TABLE was performed. For example, if the procedure returns a result set and the application cursor had not been closed, then the procedure would still be in use. Once all references to the procedure have completed, the next call will cause the procedure to be "recompiled" automatically.

VolkerBarth
Contributor
0 Kudos

W.r.t. my first comment on the question: So my assumption (ALTER TABLE triggers an automatic recompile of all procedures/functions - at least those not currently used) is generally right?

Breck_Carter
Participant
0 Kudos

@Bruce: Arrgh! Not only was the procedure not running at the time of the ALTER TABLE, it isn't even a procedure... it is an event! I have fixed the question.

Former Member

@Volker: procedures not currently in use are recompiled immediately when an ALTER TABLE occurs. Those that are in use will be recompiled when they are no longer in use by any connection, and a new call is made.

Former Member

@Breck: there is currently no mechanism for automatically recompiling events. You can, of course, put the logic for the event in a procedure which the event calls.

Answers (0)