Help needed with variable - trying to get data from Oracle using linked svr

Sorry if I posted this in the wrong forum - I just didn't know where to post it.
I'm trying to write a simple stored procedure to get data from an oracle database via a linked server in SQL Enterprise manager. I have no idea how to pass a variable to oracle.
Here's how I would get the variable in SQL:
declare @maxkey INTEGER
select @maxkey= MAX(keyfield) from [server].Data_Warehouse.dbo.mytable
select * from [server].Data_Warehouse.dbo.mydetailtable where keyfield=@maxkey
the select statement I need to do in oracle would use that variable like this:
select * from OPENQUERY(OracleLinkedServer,'select
* from ORACLEDB.TABLE where keyfield > @maxkey')
and I get this message: OLE DB provider "OraOLEDB.Oracle" for linked server "OracleLinkedServer" returned message "ORA-00936: missing expression".
I realize that I can't pass the @maxkey variable to oracle - so how do I accomplish this?

Please refer the example in this link which deals with Oracle date format.
You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

Similar Messages

  • How to get data from Oracle using Native SQL in SAP.. Problem with date

    Hi Masters.
    I'm trying to get data from an Oracle DB. I was able to connect to Oracle using tcode DBCO. The connetion works fine
    I wrote this code and it works fine without the statement of where date > '01-09-2010'
    But i need that statement on the select. I read a lot about this issue, but no answer.
    My code is (this code is in SAP ECC 6.0)
    DATA: BEGIN OF datos OCCURS 0,
          id_numeric(10),
          component_name(40),
          comuna(10),
          record_id(10),
          status,
          sampled_date(10),
          END OF datos.
    DATA: c TYPE cursor.
    EXEC SQL.
      connect to 'LIM' as 'MYDB'
    ENDEXEC.
    EXEC SQL.
      SET CONNECTION 'MYDB'
    ENDEXEC.
    EXEC SQL PERFORMING loop_output.
      SELECT ID_NUMERIC, COMPONENT_NAME, COMUNA, RECORD_ID, STATUS, SAMPLED_DATE
      into :datos from lims.SAMP_TEST_RESULT
      where     date > '01-09-2010'
    ENDEXEC.
    EXEC SQL.
      disconnect 'MYDB'
    ENDEXEC.
    How can i get the data from that date?? If i delete the where statemet, the program works well, it takes 30 mins and show all the data, I just need the data from that date.
    Any help
    Regards

    Please refer the example in this link which deals with Oracle date format.
    You can finnd a command DECODE which is used for date formats. If you have a look at whole theory then you will get an idea.
    Link:[Bulk insert SQL command to transfer data from SAP to Oracle|http://sap.ittoolbox.com/groups/technical-functional/sap-dev/bulk-insert-sql-command-to-transfer-data-from-sap-to-oracle-cl_sql_connection-3780804]

  • How to get data from Oracle to SAP

    Hi All,
           I want to get data from Oracle to my internal table in SAP,
    I worked on puting  the data from SAP to Oracle, it's working fine...
    Can anybody suggest the code for accessing from Oracle with 4 primary keys in oracle.
    regards
    manish

    hi
    good
    there is two things in sap open sql and native .if you ll use the open sql than you can access any database.
    thanks
    mrutyun

  • JSON - get data from Oracle table

    Hi all,
    I hope it is correct thread...
    My need is to get data from oracle table using JSON and show output at html table. I'm very new to JSON (got some experience in PL/SQL and basic html knowledge). Could someone direct me to manual or give me simple example?

    JSON is a way to format data, not a way to fetch data. Call it an alternative to XML.
    Are you perhaps talking about doing an ajax request to fetch data?

  • Get date from Oracle when local time zone is different from Oracle time zon

    Hi!
    Local machine time zone= +2
    Oracle time zone= +1
    I set date to Oracle using java.sql.Date.
    From application I save date at 00:30 clock and send e.g. 28.06.2002, but in Oracle date is save as 27.06.2002 01:00 (hour=01 , I suppose that is because java.sql.Date hasn't time the Oracle set it time = time zone=+1) And when I get date from Oracle I get incorrect date. In SQL I don't use date masks. Maybe solution is to use java.sql.Timestamp object (when save date to Oracle) instead of java.sql.Date?
    But if I save date at e.g. 01:00 clock and send e.g. 28:06.2002 in Oracle, date is save as 28.06.2002 01:00 and when I read from Oracle I get correct date.
    Thank you.

    Hi!
    Local machine time zone= +2
    Oracle time zone= +1
    I set date to Oracle using java.sql.Date.
    From application I save date at 00:30 clock and send
    e.g. 28.06.2002, but in Oracle date is save as
    27.06.2002 01:00 (hour=01 , I suppose that is because
    java.sql.Date hasn't time the Oracle set it time =
    time zone=+1) Presumably you are using setTimestamp() to store the value. If you are explicitly using a varchar (string) then you will have to correct the timezone your self.
    And when I get date from Oracle I get
    incorrect date. In SQL I don't use date masks. Maybe
    solution is to use java.sql.Timestamp object (when
    save date to Oracle) instead of java.sql.Date?The method setDate/getDate store a 'date' which is not the same as a 'date and time' for which setTimestamp/getTimestamp are used.
    But if I save date at e.g. 01:00 clock and send e.g.
    28:06.2002 in Oracle, date is save as 28.06.2002
    01:00 and when I read from Oracle I get correct date.
    Thank you.

  • 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

  • Help , How to get data from database using recordset with UI API

    I want to get a data from database
    when I want to create recordset i notice that UI API didn't has record set
    so I created recordset using DI API (SAPbobscom.recordset and SAPbobscom.company)
    ======================================================
    Dim oCompanyUI As SAPbouiCOM.Company <<UI API
    Dim oRecSet As New SAPbobsCOM.Recordset << DI API
    Dim oCompanyDI As New SAPbobsCOM.Company << DI API
    '=====================================================
    oCompanyDI.Connect
    Set oRecSet = oCompanyDI.GetBusinessObject(BoRecordset)
    oRecSet.DoQuery ("SELECT T0.CardCode, T0.CardName FROM OCRD T0")
    SBO_Application.MessageBox oRecSet.Fields.Item(1).Value
    ======================================================
    but I got an error it said "you are not connected to company"
    I'm really don't have an idea about how to get a data from using UI API (exp I want to get a date or costumer code)
    can someone help me please, I really need it
    Thanks

    you need a single sign on
            Dim oDICompany As SAPbobsCOM.Company
            Dim sCookie As String
            Dim sConnStr As String
            Dim ret As Integer
            oDICompany = New SAPbobsCOM.Company
            sCookie = oDICompany.GetContextCookie
            sConnStr = SBO_Application.Company.GetConnectionContext(sCookie)
            If oDICompany.Connected Then
                oDICompany.Disconnect()
            End If
            ret = oDICompany.SetSboLoginContext(sConnStr)
            If Not ret = 0 Then
                SBO_Application.MessageBox("set Login Context failed!")
                Exit Sub
            End If
            ret = oDICompany.Connect()
            If Not ret = 0 Then
                SBO_Application.MessageBox("Company Connect failed!")
            End If

  • Newbie: Trying to get data  from Code Behind file to HTML file.

    Greetings,
    I am trying to use the opener link adaptive tag to open a specific page. I have the Object ID, and classID as variables in my class in my class file, but I do not know how to get that data into the opener link which is on the html page.
    Should I be using session variables? If so how, I am a newbie.
    Does anyone know how?
    Thanks.

    Kinda depends on your flavor/need/preference. I've done it...
    * Using session variables and just writing to the page in script blocks. Not preferred in .NET-land, but definitely more of the fast/traditional ASP style. Use sparingly and with caution. Be really careful about VS.NET totally destroying your tags. It seems to love doing that (as an aside - HUGE thank-yous to the BEA engineers who altered the tags to consistenly use lower case. Really. I can't thank you enough. :) )
    * Using label controls and then just populating the label with the formatted adaptive tag (this can work well)
    * One of our guys did a really simple/elegant server control that takes arguments for the objectid, classid, etc. Nice for creating things repeatedly server-side and gets you by the HTML, quotes, etc. all over the place. Nice as it also consolidates the tag in a single place you can alter once.
    For session variables, you'd just do something like...
    <%
    '//in your code-behind
    Session("myClassID") = 18
    Session("myObjectID") = 12345
    %>
    <!-- in your aspx file -->
    <pt:standard.openerlink xmlns:pt='http://www.plumtree.com/xmlschemas/ptui/' pt:objectid='<%=Session("myObjectID")%>' pt:classid='<%=Session("myClassID")%>' pt:mode='2' target='myWindow' onclick=window.top.open('','myWindow','height=800,width=700,status=no,toolbar=no,menubar=no, location=no');>Adaptive Tags Made This Easy - Click to Open My Awesome Document</pt:standard.openerlink>
    That help?
    Personal style, I would try to avoid using session, etc. directly on your ASPX file. I'd go with writing out the HTML through labels, data lists, etc. in your code-behind.
    Thanks,
    Eric

  • Help needed with populating a drop-down list from an Access Database

    Topic
    data drop-down list
    Jason Murthy - 11:39am Feb 14, 2005 Pacific
    Hello,
    I am trying to use the data drop-down list from the custom library. I enter the name of my data connection and the other 2 variables in quotes when they are initialized, just like the example says to, but it still doesn't work. Anyone have any thoughts?
    Thanks,
    Jason
    Reply To This Discussion | Back to Topic List | Bookmark | Change Subscription
    To start a NEW discussion click on the Back to Topic List link and select Add Topic.
    If you are in an archive forum please go up to the main topic list (archives are read only).
    Messages 11 messages. Displaying 10 through 11.
    First Previous Next Last Show All Messages
    Denzil White - 5:46am Jul 28, 05 PST (#10 of 11)
    Oh and before you say anything more I have also tried changing it from Javascript to the FormCalc, and no diff, maybe I am more stupid than I realised, heh,heh
    Post Reply | Bookmark
    Henk Pisuisse - 12:06am Aug 9, 05 PST (#11 of 11)
    I am having trouble (sleepless nights) with populating a drop-down list from an Access Database. The result is: I only get the first record from the data connection. So the connection works but I cannot go through the other records. Maybe there is an other way to do this.
    I am trying to selectively fill a form with data from an MS-access database.
    I hope someone can help me.
    [email protected]
    The Netherlands (small country in Europe)

    If you email the access DB and the form to [email protected], I will try to take a look at it for you.

  • Download to Excel - I need to put button to get data from iView to excel

    Can anyone help me by telling an easy way to download the contents of iViews to Excel. As the fields are in different Nodes and components I am not able to get all the fields in standard application. Is there any easy approach to download the data from iview itself? Please help me on this.

    Hi Simon,
    Thanks a lot for the solution.
    But the problem I have is : I have put a button on Excel to download, on click of button the RFC is triggered and data will be pulled for download. But I need the data from iview with out database intraction as it has been already fetched to display in iView so the data must be stored some in portal. As far as I have analysed I found that fields are from different Components so when I go for all fields it is almost like complete customization which is not recommended, I need a data pool where the data is available so that I can download all at a strech. Is it possible to download the iview as such.

  • Can a Page with a web part, getting data from a form Library view, be exported to EXCEL?

    Certain data in a form Library is limited to a selected group of people (say Director's Group).
    I have created a Director's view in the Form library.
    Then created a Director's page with a web part connecting that Director's view to get the desired data. 
    Then I have hidden the view, since form library can have contribute permission to all the users.
    Permissions to that Director's page is given to only Director's Group. 
    However, Director's Group would like to export the data to MS EXCEL.  Is it possible?
    If not, any workaround using OOB functionalities?
    Thank you,
    SRA
    SRAEngineer

    Hi SRA, if I understand your needs correctly, the following links provide the answer:
    https://nazishqasim.wordpress.com/exporting-sharepoint-filtered-list-data-to-excelcsv-using-data-view-web-part-jquery-and-net/
    http://danssharepointblog.blogspot.com/2013/10/how-to-create-export-to-excel-button.html
    cameron rautmann

  • Help Me... How to get Data from CSV File...?

    Hi Everyone..!
    This is yajiv and am working in CS3 Photoshop platform. I know about Java Script. Is it possible to get the data from CSV files. Actually our client use to send us the CSV files which contains a lot of swatch name and reference files in one particular image name.
    Actually how we work on that CSV file is, first we copy file name to search that CSV file. then get the result to paste into layer name. This process continue till the end of swatch.
    Thank in Advance
    -yajiv

    > Is it possible to get the data from CSV files.
    Have you tried searching this forum?

  • Return Data from Oracle using a web service in AXIS - please help

    Hi Forum,
    I am very new to web services and Java tech. and recently I have been assigned to work with technology and I am struggling to learn it and need your help and assistance.
    I am trying to return some data from a an oracle database but I have to do that using a web service and I am using AXIS. For example below is a simple program that returns two columns for the demo EMP table
    import java.sql.*;
    class emp {
    public static void main(String args[])
    throws ClassNotFoundException, SQLException {
    Class.forName("oracle.jdbc.driver.OracleDriver");
    // or you can use:
    // DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
    Connection conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","scott", "tiger");
    Statement stmt = conn.createStatement( );
    ResultSet rset = stmt.executeQuery("select * from emp");
    while(rset.next( )) {
    System.out.println(rset.getString(1));
    System.out.println(rset.getString(2));
    rset.close( );
    stmt.close( );
    conn.close( );
    } but I do not know how to convert this into a web service.
    Please help.
    Thanks in advance.
    Regards,
    Ravi

    The following code returns Document. I will be calling the below function to convert my Resultset to document. In my JWS file i simply call a method with parameters. can a web service method in .jws file return Document type. It shows error will doing so. Please help me.
    public static Document toDocument(ResultSet rs) throws ParserConfigurationException, SQLException
              Document res_doc = null;
              DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
              DocumentBuilder builder = factory.newDocumentBuilder();
              Document doc = builder.newDocument();
              Element results = doc.createElement("Results");
              doc.appendChild(results);
              ResultSetMetaData rsmd = rs.getMetaData();
              int colCount = rsmd.getColumnCount();
              while (rs.next())
              Element row = doc.createElement("Row");
              results.appendChild(row);
              for (int i = 1; i <= colCount; i++)
              String columnName = rsmd.getColumnName(i);
              Object value = rs.getObject(i);
              Element node = doc.createElement(columnName);
              node.appendChild(doc.createTextNode(value.toString()));
              row.appendChild(node);
              return res_doc;
         }

  • Trying to get data from a bluetooth device using labview. Can anyone help?

    I am currently working on a project to monitor pulse rate and need send the reading via bluetooth. My laptop is bluetooth enabled and is using a toshiba stack. I am new to LabView and need some help with this.
    Message Edited by Iceberg D4 on 05-05-2009 10:58 AM

    You can definitely do this using LabVIEW. Search for labview bluetooth on NIs website to look for articles and documentation with regards to this. One thing I noticed and would like to point out:
    On Windows XP - LabVIEW works with Bluetooth devices that use the Microsoft Bluetooth
    driver included with Windows XP Service Pack 2 and later. Refer to the
    Microsoft Web site for Bluetooth devices that are supported by the
    Microsoft Bluetooth driver. Most Bluetooth devices come packaged with a
    proprietary Bluetooth driver. To use the device with LabVIEW, the
    Bluetooth adapter must be using the Microsoft Bluetooth driver. A
    Microsoft Bluetooth driver for Windows XP SP1 was also available. Refer
    to Microsoft Knowledge Base Article 323183: Availability of Windows XP Service Pack 1 Support for Bluetooth Wireless Devices for more information about Bluetooth-compatible operating systems.
    Have a look at the following:
    http://zone.ni.com/devzone/cda/tut/p/id/3260
    http://zone.ni.com/reference/en-XX/help/371361E-01/lvcomm/bluetooth_vis/
    Adnan Zafar
    Certified LabVIEW Architect
    Coleman Technologies

  • Help needed with SQL to split huge data into two excel or text files.

    Hi,
    I have a table which has around 1850000 records. I want to split the data into two sets and import the data in .txt or execl file.
    How can i break upthe records using rownum or any thing
    select * from tablename where rownum<940000 fetched some records
    but
    when i gave select * from tablename where rownum>940000 it was not fetching records.
    Guideme

    when i gave select * from tablename where rownum>940000 it was not fetching records.try this
    select * from (select tablename.*, rownum rn from tablename) where rn >940000

Maybe you are looking for