Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Native SQL..

Former Member
0 Kudos
818

Hello,

I am getting the below error while executing Native SQL statements.

Runtime Errors DBIF_DSQL2_SQL_ERROR

Except. CX_SY_NATIVE_SQL_ERROR

Short text

An SQL error occurred when executing Native SQL.

What happened?

The error 903 occurred in the current database connection "XXXXX".

******************************************************************************************************

Below is the code which we are working on..

EXEC SQL.

connect to :'XXXXX'----


>>Logical Connection name.

ENDEXEC.

EXEC SQL.

OPEN s_cursor FOR SELECT (S_S_IF-T_FIELDS)

FROM SAP_BW_FP_EXTRACT_VIEW.----


>>Oracle table/view name

ENDEXEC.

EXEC SQL.

FETCH NEXT s_cursor----


>>Getting Error at this line.

INTO :wa_et_data-FACT_TYPE_CODE,

:wa_et_data-FISCAL_YEAR_PERI,

:wa_et_data-PROD_FPC_ID,

:wa_et_data-GEO_ID,

:wa_et_data-LEGAL_ENT_ID,

:wa_et_data-PROFT_CTR_ID,

:wa_et_data-COMP_VOL_STAT_UN

ENDEXEC.

EXEC SQL.

CLOSE S_CURSOR.

ENDEXEC.

Any ideas where I am making a mistake, is it a syntax issue, or is it a Authorization issue, or something else..Please help..

Your Inputs will be appreciated....

2 REPLIES 2

SuhaSaha
Advisor
Advisor
0 Kudos
126

Hello,

Oracle 903 error means:

A table or cluster name is invalid or does not exist.

source: [http://www.oracleerrorcodes.com/tag/ora-903/]

BR,

Suhas

Former Member
0 Kudos
126

Ishdeep,

Firstly, you should paste the code straight from your program without modifying it. That way, we can see what exactly the syntax error is. Also, use code tags and help us.

I think the problem is in your code at this line:


FROM SAP_BW_FP_EXTRACT_VIEW.

You should not use period (full stop) after the SQL statement when using native SQL.

Secondly, you should ALWAYS check the return code (using IF SY-SUBRC NE 0); you would have caught the problem yourself.


EXEC SQL.
  OPEN s_cursor FOR SELECT (S_S_IF-T_FIELDS) 
  FROM SAP_BW_FP_EXTRACT_VIEW.
ENDEXEC.

IF sy-subrc NE 0.
  WRITE: / 'Something is wrong.'.
  EXIT.
ENDIF.

Finally, I don't think you can supply a list of fields dynamically in native SQL. Double check that.


OPEN s_cursor FOR SELECT (S_S_IF-T_FIELDS)

Edited by: Sudhi Karkada on Feb 25, 2011 9:51 PM