Why don't runtime contexts work on 11g in a program compiled for 10g?
I've got a multi-threaded C application that was compiled using Oracle 10g (pro*c and libraries.) The program uses one database connection per thread. We're moving to 开发者_StackOverflow中文版11g and in testing against 11g, anything that uses a context other than the global context generates an SQL-02134: Invalid runtime context
when connecting to the database. Using the global context works fine. Is this a known incompatibility in the transition from 10g to 11g, or am I doing something wrong? I will eventually recompile everything against 11g, but for implementation purposes, it's much easier if we can run the 10g program until all the databases are converted.
For what it's worth, the code includes what I believe to be the normal things:
EXEC SQL ENABLE THREADS;
EXEC SQL CONTEXT ALLOCATE :thread_ctx
EXEC SQL CONTEXT USE :thread_ctx
SQL-02134: Invalid runtime context
Cause: The runtime context associated with this statement has not been properly allocated.
Action: Rewrite the application to execute the EXEC SQL CONTEXT ALLOCATE statement before executing any SQL statements.
So, I would guess since you said that the code includes that statement before executing the SQL statement that the context is being cleared before you execute said sql.
Run a debugger of some kind to produce a trace file to see where exactly the issue is propagating.
Declare your context before usage
EXEC SQL begin declare section; sql_context thread_ctx; EXEC SQL end declare section;
精彩评论