<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Retreiving data from external DB using cursors (Native SQL) in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888828#M1479734</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try FETCH NEXT CURSOR c1 INTO TABLE TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are the both table fields from the same type?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 07 May 2010 12:54:44 GMT</pubDate>
    <dc:creator>former_member358980</dc:creator>
    <dc:date>2010-05-07T12:54:44Z</dc:date>
    <item>
      <title>Retreiving data from external DB using cursors (Native SQL)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888826#M1479732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi experts, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iu2019m trying to use some functionality based on the Native SQL on an Oracle Server. Iu2019m facing some difficulties using cursors and fetching data from the external database.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Basically the synonym its zfisicc_c_dblink, and Iu2019m running the for the following code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
TRY.
      OPEN CURSOR WITH HOLD c1 FOR SELECT *
                            FROM  zfisicc_c_dblink
                            WHERE estado_sif = 'I'.
 
    CATCH cx_sql_exception INTO sqlerr_ref.
      PERFORM handle_sql_exception USING sqlerr_ref.
  ENDTRY.
 
DO.
*  "Move the data from the Cursor into the target area.
    FETCH NEXT CURSOR c1 APPENDING TABLE tab.
    IF sy-subrc  0.
      EXIT.
    ENDIF.
 
  ENDDO.
  CLOSE CURSOR c1.

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The cursor C1 it's cursor type and the table tab it's ZFISICC_C_DBLINK type, but every time i run it it's giving me the ORA-932 error.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;
Database error text........: "ORA-00932: inconsistent datatypes: expected %s 
got %s" 
&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me on this error? What Iu2019m doing wrong when fetching the data ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another doubt that Iu2019ve it's when using pl/Sql procedure. Can anyone tell how I can retrieve data from the external database with the following code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
**Select Directo com Cursor
 
  EXEC SQL.
    CONNECT TO :gv_db_name AS 'dblink_con'
  ENDEXEC.
 
  IF sy-subrc NE 0.
    WRITE: 'Não foi possível fazer a ligação à DBCON: ', gv_db_name.
 
  ELSE.
**
    EXEC SQL.
 
      DECLARE CURSOR c_1 IS SELECT tipo_operacao FROM movimento_contribuicao
             WHERE ROWNUM &amp;lt;= 10000;
 
          wa movimento_contribuicao.tipo_operacao%type;
BEGIN
       OPEN c_1;
     LOOP
        FETCH c_1 INTO wa; "Not able to return data to SAP system
         EXIT WHEN c_1%NOTFOUND;
      END LOOP;
  END;
 
    ENDEXEC.
      EXEC SQL.
      DISCONNECT 'dblink_con'
    ENDEXEC.
  ENDIF.
 
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On the &lt;STRONG&gt;FETCH c_1 INTO wa;&lt;/STRONG&gt; code Iu2019m moving the data to an Oracle variable, wa movimento_contribuicao.tipo_operacao%type;, and not to an program variable. Can anyone explain me this how this is +possible using this PL/SQL procedure?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance, &lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;João Martins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Rob Burbank on May 7, 2010 10:25 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 06 May 2010 14:39:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888826#M1479732</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-06T14:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Retreiving data from external DB using cursors (Native SQL)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888827#M1479733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can anyone help me on this subject?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 May 2010 10:01:45 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888827#M1479733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-07T10:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Retreiving data from external DB using cursors (Native SQL)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888828#M1479734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Joao,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try FETCH NEXT CURSOR c1 INTO TABLE TAB.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Are the both table fields from the same type?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 May 2010 12:54:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888828#M1479734</guid>
      <dc:creator>former_member358980</dc:creator>
      <dc:date>2010-05-07T12:54:44Z</dc:date>
    </item>
    <item>
      <title>Re: Retreiving data from external DB using cursors (Native SQL)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888829#M1479735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Joao, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your first question: It looks like there's a conversion problem (with one or more columns) from your Oracle table to your ABAP internal table.&lt;/P&gt;&lt;P&gt;In the following link you can see (in your case in the SELECT section) the type conversions used for each type combination. &lt;/P&gt;&lt;P&gt;Some combinations lead to an oracle error (specified in the "Result" column), like in your case (error 932).&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_470/helpdata/EN/a3/74caa1d9c411d1950e0000e8353423/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_470/helpdata/EN/a3/74caa1d9c411d1950e0000e8353423/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regarding your second question: You can use the PERFORMING addition in the EXEC SQL statement.&lt;/P&gt;&lt;P&gt;You can see an example in the following link:&lt;/P&gt;&lt;P&gt;&lt;A href="http://help.sap.com/saphelp_470/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm" target="test_blank"&gt;http://help.sap.com/saphelp_470/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope it helps.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ana Luisa.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 May 2010 14:17:35 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888829#M1479735</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-07T14:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Retreiving data from external DB using cursors (Native SQL)</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888830#M1479736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ana, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for your reply but isn´t the oracle server syntax diferent from SQL server??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;They haven´t got syntax error, only problems trying to send the data to an SAP internal table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Joao Martins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: joao martins on May 10, 2010 4:41 PM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 07 May 2010 15:24:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/retreiving-data-from-external-db-using-cursors-native-sql/m-p/6888830#M1479736</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2010-05-07T15:24:54Z</dc:date>
    </item>
  </channel>
</rss>

