Retreiving data from external DB using cursors (Native SQL)

Hi experts,
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.
Basically the synonym its zfisicc_c_dblink, and Iu2019m running the for the following code:
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.
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.
Database error text........: "ORA-00932: inconsistent datatypes: expected %s
got %s"
Can anyone help me on this error? What Iu2019m doing wrong when fetching the data ?
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?
**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 <= 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.
On the FETCH c_1 INTO wa; 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?
Thanks in advance,
Best Regards
João Martins
Edited by: Rob Burbank on May 7, 2010 10:25 AM

Hi Joao,
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.
In the following link you can see (in your case in the SELECT section) the type conversions used for each type combination.
Some combinations lead to an oracle error (specified in the "Result" column), like in your case (error 932).
http://help.sap.com/saphelp_470/helpdata/EN/a3/74caa1d9c411d1950e0000e8353423/content.htm
Regarding your second question: You can use the PERFORMING addition in the EXEC SQL statement.
You can see an example in the following link:
http://help.sap.com/saphelp_470/helpdata/EN/fc/eb3b8b358411d1829f0000e829fbfe/content.htm
Hope it helps.
Regards,
Ana Luisa.

Similar Messages

  • Retreiving data from 2 tables using a sender JDBC Channel

    Hi all,
    We got anew requirement where we have to select data from 2 tables and update fields in 2 tables at the sametime.
    I have a few queries regarding this.
    Can we retrieve data from 2 tables using select query in sender JDBC channel?
    If yes, how we can achieve this?
    Can we use inner/outer joins in the select query?
    Can we update field of 2 tables using the Update query in Sender JDBC channel?
    Your help is greatly rewarded.
    With Regards
    Sudha.

    Hi,
    Even i have the same requirement where data has to be read from 2 tables and later update the falg once done .
    SELECT query :
    SELECT t1.KUNNR,t1.SETT_KEY,t1.QUART_START,t1.QUART_END,t2.PAY_METH,t2.MAT_NDC,t2.AMOUNT   FROM TSAP_REBATE_MEDI t1  INNER JOIN  TSAP_REBATE_LINE t2  ON  t1.KUNNR=t2.KUNNR AND t1.SETT_KEY=t2.SETT_KEY  WHERE  t1.PROCESSING_STATUS = 'N' AND t2.PROCESSING_STATUS = 'N'
    This is working fine.
    Can somebody help me with update query with this. where flag PROCESSING_STATUS has to be updated with 'P'.
    I tried a lot but couldnt get the answer
    Br,
    Manoj

  • How to retreive data from alv when using CL_GUI_ALV_GRID

    Hi All,
      I am using two subscreens to display 2 ALV grids in a screen using the OOPs concept and the class CL_GUI_ALV_GRID. I would like to download data from these two alv grids into an excel after any changes, i.e sort, filter or summation. I was able to capture data for sort and filter. The logic to capture summation and subtotals is becoming very complex. I need to simplify for better. I need help to see if there is any method which captures the changed data on the screen so that i can just call the method and retrieve the data to push into an internal table before downlaoding to excel.
    Your help is greatly appreciated.
    Thanks in advance.
    Roopa

    Step 1, define the method in class grid_hdr:
    METHODS:handle_data_changed CHANGING e_valid TYPE c.
    Step 2, process the method:
      METHOD  handle_data_changed.
        CALL METHOD zgrid->check_changed_data
          IMPORTING
            e_valid = e_valid.
      ENDMETHOD.                    "handle_data_changed
    Step 3, use the method in PAI:
      DATA l_valid TYPE c.
      CALL METHOD grid_hdr->handle_data_changed
        CHANGING
          e_valid = l_valid.
      IF l_valid = 'X'.
      ENDIF.
    Also you can search  BCALV_EDIT_* in your system.
    Edited by: SAM XIAO on Nov 17, 2009 8:03 AM

  • Error while retreiving data from oracle using EJB.

    HII All,
    I m getting this error while trying to retreive data from oracle DB using EJB.
    An error has occurred. Maybe the request is not accepted by the server:
    Exception in method empName.
    HTTP/1.1 500 Internal Server Error
    Connection: close
    Server: SAP J2EE Engine/6.40
    Content-Type: text/xml; charset=UTF-8
    Set-Cookie: <value is hidden>
    Date: Mon, 24 Jul 2006 10:50:11 GMT
    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>SOAP-ENV:Client</faultcode><faultstring>Exception in method empName.</faultstring><detail><ns1:com.sap.engine.services.ejb.exceptions.BaseEJBException xmlns:ns1='http://sap-j2ee-engine/client-runtime-error'>Exception in method empName.</ns1:com.sap.engine.services.ejb.exceptions.BaseEJBException></detail></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
    Thanks in advance
    Devendra Phate.

    Hi Devendra,
    this error message does not tell me much. Pleas either start debugging or watch your logs for more detailed messages.
    Regards,
    Benny

  • After a Lion clean install, how do I retrieve my data from external back-up? Following Apple advice for use of Migration Assistant did not work creating similar issues leading to clean install.

    After a Lion clean install, how do I retrieve my data from external hard drive?
    Following Apple advice I used Migration Assistant which crashed new system twice which is why I had to clean install Lion in the first place.
    Is there a sure way of doing it?
    I have only a few programs that I will have to install myself and that should not be a problem.
    I just want my data, music and photos back where I can use them.

    Time machine backups. I went to migration assistant a few hours ago and limited my selection to "users", no need for applications, settings and other files.  Stuff started moving over at a fast pace but has now seemed to stall.
    I will let it run overnight as there are lots of songs and photos as well as a few movies.
    If that does not work, then I will go into TM and try restore. I have restored some things in the past such a mail files and it has worked well. 
    The Apple fellow at the store told me to go right into TM, he may have had a point. I'll get it eventually.

  • How to retreive data from a maintainence view?

    Hi all,
    I have used select query to retreive data from a maintainence view. But it gave me a syntactical error that XYZ is not in abap dictionary , it's a database / projection view?
    So can't we get data from a view using select query?
    Please share if u have answers.
    Thanks & regards,
    Chandru

    Hi,
    Maintenance view will be created for database tables only.
    Just display the maintainence from SE11 and click Tables tab in the screen
    Here you can find the list of tables used to created for Maintainence view.
    YOu can use these tables to write SELECT.
    If you give us the maintainence table, we will help you.
    Thanks,
    Ramakrishna

  • Retreive data from wa structure into fields.

    Hi friends,
                I am having a query regarding classical report.I want to retreive data for vendor billwise realisation report.I am getting few fields into my list screen(fields from bsis table).Remaining fields i want to retreive from table bseg(augdt,augbl....)with the condition that the belnr of both the tables should be same and Account type = 'k'(vendors).
    I tried it using select queries for the bsis and bseg..but data is retreived only from one table bsis and not from bseg.so for data from bseg i used workarea(wa).data is retreived for only single doc no. and not for other documents.
       If any problem in understanding this pls give me the mail id i will send in detail.
    Thanks and regards,     
    Anand.

    Hi Anand,
    You should not use Workarea, if you are exepecting N number of records. Please use internal table.
    SELECT * FROM BSIS
        into table i_bsis
         where ....
    if not i_bsis[] is initial.
    sort i_bsis by belnr.
    SELECT * FROM BSEG
    into table i_bseg
    for all entries in i_bsis
    where belnr = i_bsis-belnr.
    endif.
    Best regards,
    Prashant

  • Recover data from external hard drive that was Windows format and connected on a Macbook Pro. Did I lose everything? What happened?

    Hi there this is my first question here!
    I connected my external hard drive originally formatted on PC on my new Macbook. The first time I connected it I could see all my files but today I connected it and after I couldn't see any file nor even on my pc appears as NO NAME with a different name and nothing on it. I think was reformatted, any help to recover all my data?
    It's really important stuff for me

    If the Apple Store couldn't get files off of the drive, it is unlikely that you will be able to. If you have backups, those would be the best way to go. You could also try booting up the computer and holding down T to boot into Target Disk Mode. Plug the broken computer into another one with FireWire and see if it works to recover data from external hard drive. If you can see it, try booting up the broken computer while holding down Option. Choose Recovery HD from the menu, then choose to Reinstall OS X.
    It is unlikely that this will work, because I'm pretty sure that the Apple Store would have tried this. You could try using expensive software to get files off the drive, but it would be risky and the results might not be any good.
    https://discussions.apple.com/docs/DOC-4273

  • Hi,disc wiped ,OSX10.9 back on ,how do I restore my data from external hard drive ?Any help welcome .

    Hi,disc wiped ,OSX10.9 back on ,how do I restore my data from external hard drive ?Any help welcome .

    There's Setup Assistant and Migration Assistant. The cleanest way to do it is Setup Assistant, but you only get that option once when you fire up a fresh install of OSX. If you're past that, you could reinstall OSX by booting with Command-R, or you could use Migration Assistant.
    Setup/Migration Assistant instructions:
    http://support.apple.com/kb/HT5872

  • Transferred backed-up data from external hard disk to new hard drive on my MacBook Pro which seemed to be successful. I now find that some (or maybe all) old emails have been resent. Can anyone tell me what has happened?

    Transferred backed-up data from external hard disk to new hard drive on my MacBook Pro which seemed to be successful. I now find that some (or maybe all) old emails have been resent. Can anyone tell me what has happened?

    Greetings,
    I've never seen this issue, and I handle many iPads, of all versions. WiFi issues are generally local to the WiFi router - they are not all of the same quality, range, immunity to interference, etc. You have distance, building construction, and the biggie - interference.
    At home, I use Apple routers, and have no issues with any of my WiFi enabled devices, computers, mobile devices, etc - even the lowly PeeCees. I have locations where I have Juniper Networks, as well as Aruba, and a few Netgears - all of them work as they should.
    The cheaper routers, Linksys, D-Link, Seimens home units, and many other no name devices have caused issues of various kinds, and even connectivity.
    I have no idea what Starbucks uses, but I always have a good connection, and I go there nearly every morning and get some work done, as well as play.
    You could try changing channels, 2.4 to 5 Gigs, changing locations of the router. I have had to do all of these at one time or another over the many years that I have been a Network Engineer.
    Good Luck - Cheers,
    M.

  • Getting data from external system

    Hi,
    What other methods that are used to get data from external system to BW? I know that DB Connect is one of the methods. Also, falt files is one of them.
    Thanks,
    RT

    Hi,
    Is there a BAPI that I can look at and start programming to get data from Informatica?
    Right now we are using CSV files. Would anyone have sample code for the doing this using BAPI? Appreciate any.
    Is there any How to paper to do this?
    Thanks,
    RT
    Message was edited by: Rob  Thomas
    Message was edited by: Rob  Thomas

  • Querying data from External Source from FORMS

    I have a form that is built based on Oracle tables.
    But I need to get data from external Data source from within Forms and use it fro validation.
    I need to execute a Select statement via ODBC from within Forms procedures. This is going to a SQL Server DB to get some information.
    Any thoughts?
    Thanks

    Hi
    What version of forms do you use? If you use forms 6i, take a look at the EXEC_SQL package. You can access oracle databases and ODBC databases (using OCA) independently of the main database connection -- well, I never tried but that is what the documentation says.
    I am not sure about version 9i... the package is there, but I could not find anything in the help about it (what is not a good sign...)
    hth
    Luis Cabral

  • Load data from external table

    Hi ,
    How to load data from external table to transaction table using SQLLDR ?

    You use an external table to load the data it is described in the link to the manual I provided.
    Here is an example.
    Re: Using DML order to import a .xls file
    You would not be using SQLLDR though as external tables replace that functionality.

  • Error while selecting date from external table

    Hello all,
    I am getting the follwing error while selecting data from external table. Any idea why?
    SQL> CREATE TABLE SE2_EXT (SE_REF_NO VARCHAR2(255),
      2        SE_CUST_ID NUMBER(38),
      3        SE_TRAN_AMT_LCY FLOAT(126),
      4        SE_REVERSAL_MARKER VARCHAR2(255))
      5  ORGANIZATION EXTERNAL (
      6    TYPE ORACLE_LOADER
      7    DEFAULT DIRECTORY ext_tables
      8    ACCESS PARAMETERS (
      9      RECORDS DELIMITED BY NEWLINE
    10      FIELDS TERMINATED BY ','
    11      MISSING FIELD VALUES ARE NULL
    12      (
    13        country_code      CHAR(5),
    14        country_name      CHAR(50),
    15        country_language  CHAR(50)
    16      )
    17    )
    18    LOCATION ('SE2.csv')
    19  )
    20  PARALLEL 5
    21  REJECT LIMIT UNLIMITED;
    Table created.
    SQL> select * from se2_ext;
    SQL> select count(*) from se2_ext;
    select count(*) from se2_ext
    ERROR at line 1:
    ORA-29913: error in executing ODCIEXTTABLEOPEN callout
    ORA-29400: data cartridge error
    KUP-04043: table column not found in external source: SE_REF_NO
    ORA-06512: at "SYS.ORACLE_LOADER", line 19

    It would appear that you external table definition and the external data file data do not match up. Post a few input records so someone can duplicate the problem and determine the fix.
    HTH -- Mark D Powell --

  • Not able to extract performance data from .ETL file using xperf commands. getting error "Events were lost in this trace. Data may be unreliable ..."

    Not able to extract  performance data from .ETL file using xperf commands.
    Xperf Commands:
    xperf –i C:\TempFolder\Test.etl -o C:\TempFolder\BootData.csv  –a process
    Getting following error after executing above command:
    "33288636 Events were lost
    in this trace. 
    Data may be unreliable
    This is usually caused
    by insufficient disk bandwidth for ETW lo
    gging.
    Please try increasing the minimum
    and maximum number of buffers
    and/or
                    the buffer size. 
    Doubling these values would be a good first at
    tempt.
    Please note, though, that
    this action increases the amount of me
    mory
                    reserved
    for ETW buffers, increasing memory pressure on your sce
    nario.
    See "xperf -help start"
    for the associated command line options."
    I changed page size file but its does not work for me.
    Any one have idea, how to solve this problem and extract ETL file data.

    I want to mention one point here. I have total 4 machines out of these 3 machines above
    commands working properly. Only one machine has this problem.<o:p></o:p>
    Hi,
    I consider that you can try to use xperf to collect the trace etl file and see if it can be extracted on this computer:
    Refer to following articles:
    start
    http://msdn.microsoft.com/en-us/library/windows/hardware/hh162977.aspx
    Using Xperf to take a Trace (updated)
    http://blogs.msdn.com/b/pigscanfly/archive/2008/02/16/using-xperf-to-take-a-trace.aspx
    Kate Li
    TechNet Community Support

Maybe you are looking for

  • SELECT on XML DB Table works for Schema owner, not for Schema user

    Hi, We are working on Oracle 10.2.0.3 under HP-UX. We get ORA-01031: Insufficient Privileges when trying to execute Query on Oracle XMLDB Table by Schema User Here are detailed steps: 1) We have 2 users: CDROWNER (Schema Owner) CDRJAVA (Schema User)

  • When i click on the CreativecloudSetup my screen starts flashing.

    Hello, I am a new CC user and i just downloaded it but only to find out when i click on it my screen starts flashing and doesn't even open! If anyone could help that would be great! ~Bill

  • Problem with executing some WebApplication Templates

    Hi forum, i have like 7 WebApplication Templates i built myself and they show the same error, I checked them out, but it doesn't seem to be an error in the variables. If i run the queries attach to them they work just fine. I'll put the error here: S

  • Short dump - reading from roll back segment

    Hi All, I am getting this short dump for few loads.The error is : "(FUNCTION)", or declared in the procedure's RAISING clause.                         To prevent the exception, note the following:                                        Database error

  • Publishing iWeb site with FTP

    My registered domain is www.peuterspeelzaalrisdam.nl/ When I upload with FTP iWeb is adding 'file' to my domain, so www.peuterspeelzaalrisdam.nl/file So nobody will find the site because of this added 'file' What can I do to change that???? Anybody s