Odd errors: ORA 1036, 1722 [message #93632] |
Tue, 03 September 2002 01:44 |
Alan Powell
Messages: 2 Registered: September 2002
|
Junior Member |
|
|
Using ProC (on HP-UP 11 with Oracle 8.1.7.4.0), the following code snippet gives me problems:
//----- snippet [[compressed for space purposes]]
int Ftn (sql_context context)
{
EXEC SQL BEGIN DECLARE SECTION;
char* db_file_id;
char* db_record_id;
int db_length;
struct sqlca sqlca;
EXEC SQL END DECLARE SECTION;
EXEC SQL CONTEXT USE :context;
db_file_id = "IFORMAT";
db_record_id = "HDR";
EXEC SQL WHENEVER SQLERROR DO ErrorFtn ("ERROR");
EXEC SQL WHENEVER SQLWARNING DO WarningFtn ("WARN");
EXEC SQL
SELECT length INTO :db_length FROM file_record
WHERE fk_fit_id = :db_file_id
AND fk_icr_type = :db_record_id;
if (sqlca.sqlcode ....)
//----- End snippet
Using it as above gives ORA-01036 (illegal variable name/number). Replacing the variables in the WHERE clause with hardcoded values (i.e. fk_fit_id = 'IFORMAT' AND fk_icr_type = 'HDR') gives ORA-01722 (invalid number).
The offending table is defined as
CREATE TABLE FILE_RECORD (
FK_ICR_TYPE VARCHAR2 (3) NOT NULL,
FK_FIT_ID VARCHAR2 (10) NOT NULL,
LENGTH NUMBER (9),
TEXT_VALIDATION CHAR (1),
DESCRIPTION VARCHAR2 (80),
--- constraints, etc. left out.
)
More bizarrely, i can select numeric fields from other tables using very similar code.
What on earth is happening?
BTW, i'm a newbie at ProC so be gentle <<grin>]]
Thanks
|
|
|
Re: Odd errors: ORA 1036, 1722 [message #93633 is a reply to message #93632] |
Tue, 03 September 2002 04:04 |
Alan Powell
Messages: 2 Registered: September 2002
|
Junior Member |
|
|
BTW, i was advised to use a local contect variable:
EXEC SQL BEGIN DECLARE SECTION;
sql_context ctx = context; // Added.
EXEC SQL END DECLARE SECTION;
EXEC SQL CONTEXT :ctx; // Changed.
Made no difference.
|
|
|
|