Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3228

Native SQL - Error forming SQL Query "where in (12, 23)"

$
0
0

Hi

 

I am trying to execute a native sql query in a function module.

 

Below is my code snippet:

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

FUNCTION GET_CANDIDATES.

"----------------------------------------------------------------------

*"*"Local Interface:

*"  IMPORTING

*"     VALUE(resume_numbers) TYPE  OCS_STRING

*"  TABLES

*"      CANDIDATES STRUCTURE  CANDITABLE

*"----------------------------------------------------------------------

 

DATA: candidates_line TYPE ZMFCANDIDATE.

 

 

EXEC SQL.

   CONNECT TO 'Oracle_CON_Name'

ENDEXEC.

 

 

EXEC SQL.

   OPEN cursor FOR

   SELECT column1, column2, column3, column4from table_name

      where column2 in ( resume_numbers)

ENDEXEC.

 

 

DO.

   CLEAR candidates_line.

 

EXEC SQL.

   FETCH NEXT cursor INTO :candidates_line.

 

ENDEXEC.

 

IF sy-subrc <> 0.

   EXIT.

ELSE.

    APPEND candidates_line TO CANDIDATES.

  ENDIF.

 

ENDDO.

 

EXEC SQL.

   CLOSE cursor

ENDEXEC.

 

exec sql.

   DISCONNECT 'Oracle_CON_Name'

ENDEXEC.


ENDFUNCTION.

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


It is throwing exception while executing "FETCH NEXT cursor INTO :candidates_line.".


I doubt that the sql query is not being formed properly. "where column2 in ( resume_numbers)"  could be the issue.


When i have changed this to "where column2 = resume_numbers", it is working. But i need to pass multiple numbers to get multiple records of the candidates.


Any help will be great.


Thanks




Viewing all articles
Browse latest Browse all 3228

Trending Articles