Calling a R function from sql

Hello there, can anyone help me on the following query ?
1) I have a data view called Q_X1_V stored in a database schema, which has a column called OBS03
2) I have logged in to the schema where the above mentioned view is defined using sqldeveloper
3) I have created the following R function and executed in sql developer
begin
   sys.rqScriptDrop('xbarr-qcc');
   sys.rqScriptCreate('xbarr-qcc', 'function() {
   library(ORE)
   ore.sync(table=Q_X1_V)
  ore.attach()
dataset <- ore.pull(Q_X1_V["OBS03"])
head(dataset)
end;
It has created the function successfully.
4)  and I am trying to execute the following sql query in sql developer
select *
from table(rqEval(NULL,'select 1 "OBS03" from dual','xbarr-qcc'));
and it results in the following error
ORA-20000: RQuery error
Error in .ore.schema(schema) : attempt to apply non-function
ORA-06512: at "RQSYS.RQEVALIMPL", line 104
ORA-06512: at "RQSYS.RQEVALIMPL", line 101
20000. 00000 -  "%s"
*Cause:    The stored procedure 'raise_application_error'
           was called which causes this error to be generated.
*Action:   Correct the problem as described in the error message or contact
           the application administrator or DBA for more information.
Not sure how to trouble shoot the issue
5) Above R function mentioned in the step:3 works fine on the R command prompt
and gives me the following output
OBS03
1 10.872
2 10.818
3 10.802
4 10.622
5 10.708
6 10.658
and how do I make the sql command mentioned in step:4 work in sqldeveloper command line.
Any help is appreciated.
thanks
Pradeep

Sherry,  thanks for the reply.
1) I have logged into the database user via sqldeveloper as "ruser"
    and executed the following script for creating the R function
begin
   sys.rqScriptDrop('xbarr-qcc');
   sys.rqScriptCreate('xbarr-qcc', 'function() {
   library(ORE)
# ore.connect(user="ruser" ....   )  -- commented this out as I have already logged into the "ruser" schema of database
   ore.sync(table="Q_X1_V")    
   dataset <- ore.pull(Q_X1_V["OBS03"])  # pulling the data from the column OBS03 of the table. Q_X1_V
   dataset           #  simply return the rows
end;
2)  Now when I execute the following sql select command
select *
  from table( rqEval(
        cursor(select 1 "ore.connect" from dual),      ## -- was hoping this will help me connect with the db schema.
        'select 1 "OBS03" from dual',
        'xbarr-qcc'));
but I end up getting this error :
ORA-20000: RQuery error
Error in ore.pull(Q_X1_V["OBS03"]) :
  error in evaluating the argument 'x' in selecting a method for function 'ore.pull': Error: object 'Q_X1_V' not found
ORA-06512: at "RQSYS.RQEVALIMPL", line 104
ORA-06512: at "RQSYS.RQEVALIMPL", line 101
20000. 00000 -  "%s"
*Cause:    The stored procedure 'raise_application_error'
           was called which causes this error to be generated.
*Action:   Correct the problem as described in the error message or contact
           the application administrator or DBA for more information.
So what am I missing,
1) I don't want to use ore.connect inside my R script because that will lead to security standards violations as the login credentials will be visible to all
2) Once connected to the ruser, I should be able to run R script seemlessly with out passing in login credentials explicitly.
which I thought  the sql script in step 2, with ore.connect in params should be helpful.   but for some reason it is erroring out.
Could you pl. help.
thanks

Similar Messages

  • Call external function from SQL query

    Hi,
    I am new to PL/SQL programming.I don't think this is possible but please let me know if there is a way to achieve this. I have a function written in VB.net and I would want to call from the query.
    create table temp as select id, callvbfunction(note_text) from temp2
    Here callvbfunction is the vb.net function.I need to pass note_text field value to the function.
    Thanks..

    Yes it is possible.
    No idea how to specifically call a .Net function (from Oracle) as I do not do Windows (except for playing games ;-) ). But external procedures (extproc) and Java stored procs can be wrapped by PL/SQL wrapper functions and used in SQL statements.

  • Problem with JCA calling to DB function from Service Bus

    Hi there
    I have managed to use JCA from the Service Bus on several tables, on some diferent Oracle databases and it worked OK.
    Now, I try to use it with a DB function that I have defined. Calling to this function from any DB software returns good values.
    But calling this function using JCA (adapter created with jDeveloper) on OSB gives me the correct answer except that instead of the data there are question marks, like +<param>???</param>+
    The database encoding is ISO-8859 (by using "SELECT * FROM NLS_DATABASE_PARAMETERS") .
    This encoding is the same as was on different databases that worked ok with other adapters, just not calling a DB function, but a custom SQL.
    I would appreciate if anyone might know what can solve this ..
    Thanks

    Where are you checking the content of the XML?
    It seems that platform's default encoding is not able to identify those characters and hence dispalying those as "???". Sometimes you get some invalid characters (like null), in the XML file and when platform's default encoding could not identify those characters then they get displayed like "?". Please check the content of the XML to verify it does not contain any invalid XML characters (sometims null). You may try to log the XML in database and in OSB to see it's content.
    Regards,
    Anuj

  • Calling Procedure or Function from Interative Report

    Hi All -
    Is it possible to call a procedure/function from "Region Source" of Interact Report page.
    Basically the report I want to show would be little difficult if I use SQL alone. So wanted to check is there is a way I can call a SQL procedure/function from Apex Interactive Report Page.
    Please share your expertise.
    Thanks,
    -Seenu

    Hi,
    These links might help
    http://www.oracleapplicationexpress.com/tutorials/71-oracle-apex-interactive-report-based-on-plsql-function
    http://sungur.wordpress.com/2009/10/11/apex-interactive-reports-with-dynamic-sql/
    Br,Jari

  • How can I call a plsql function from an attribute?

    I have an attribute defined in an element. I want execute a PLSQL function from the attribute, and display the returne value with an HTML template.
    I've defined the attribute's type like PLSQL, and I've put the called of the function in the value of the attribute, but it doesn't work. The only value I obtain is an URL (I think that is the URL of the function or someting like this).
    How can I call to my function from the attribute and display the returnes value in the page?
    Thanks.

    Thanks, but it doesn't work. I have an attribute called ID_BOL and I want to associate a sequence to that attribute. I've created a function, with the sequence. This function return de value of the sequence. I want taht the attribute takes the value of the sequenece dinamically.
    I've tried it, creating the type attribute like PLSQL, and calling the function from the attribute, but it doesn't work.
    How can I return the sequence value to my attribute?
    Thanks.

  • How to call a Javascript function from backing bean without any event

    Hi,
    Someone knows how to call a Javascript function from backing bean without any event ?
    thanks

    Please review the following thread:
    ADF Faces call javascript
    Luis.

  • Help needed in calling a javascript function from a jsp

    Hey guys,
    I need help.
    In my jsp I have a field called date. When i get date field from the database, it is a concatination of date and time field, so I wrote a small javascript function to strip just the date part from this date and time value.
    The javascript function is
    function formatDate(fieldName)
              var timer=fieldName;
              timer = timer.substring(5,7)+"/"+timer.substring(8,10)+"/"+timer.substring(0,4);
              return timer;
    Now I want to call this javascript function from the input tag in jsp where I am displaying the value of date. Check below
    This is one way I tried to do:
    <input size="13" name="startDate" maxLength="255" value=<script>formatDate("<%=startDate%>")</script> onChange="checkDate(this)">
    I even tried this:
    <input size="13" name="startDate" maxLength="255" value="'formatDate(<%=startDate%>)'" onChange="checkDate(this)">
    But it dosen't work
    Please help. I am struggling on this for days.
    Thanks,
    Ruby

    Hey all you developers out there , Pleaseeee help me with this one.

  • IP - Is it possible to call exit planning function from ABAP Report..

    Hi All,
    Greetings.
    Is it possible to call exit planning function from ABAP Report (t-code SE38) ? Or I mean is not limited only to be called from ABAP Report, perhaps from BSP / Web-Dynpro / Function Module.
    If somebody here has been doing it before, I'm keen to ask to kindly share it. Particularly how to call and transfer data to that exit function.
    Or if somebody has done in BPS, appreciate if it can be shared too .
    Thanks a lot and have a good day,
    Best regards,
    Daniel N.

    Hi.
    You can achive this as suggested by Mattias in your previous post.
    Lets say you have next data structure:
    CostCenter | Amount | PercentForDistibution |
    Create input ready query in this format. Restrict cost center by variable type range.
    Create WAD with analysis item.
    When you run web page you enter range of cost centers (lets say you will enter 101004 to 101010).
    I assume you have data only for 101004 in your cube (lets say 1000).
    You will see only one record in your webpage.
    CostCenter | Amount | PercentForDistibution |
    101004       | 1000     | NOTHING
    When you create WAD in analysis item properties set "NUMBER_OF_NEW_LINES" to lets say 1 (so in WAD you will see always one blank line for entering new data).
    Just add 6 new records:
    CostCenter | Amount   | PercentForDistibution |
    101005       | NOTHING| 10
    101006       | NOTHING| 30
    101007       | NOTHING| 20
    101008       | NOTHING| 25
    101009       | NOTHING| 5
    101010       | NOTHING| 10
    Then run planning FOX function like this:
    FOREACH Z_COST_CENTER.
    IF {Amount, Z_COST_CENTER} <> 0
    Z_AMNT_TO_DISTRIBUTE = {Amount, Z_COST_CENTER}.
    ENDIF.
    ENDFOR.
    FOREACH Z_COST_CENTER.
    IF {PercentForDistibution Z_COST_CENTER} <> 0.
    {Amount, Z_COST_CENTER} = Z_AMNT_TO_DISTRIBUTE * {PercentForDistibution Z_COST_CENTER}.
    ENDIF.
    ENDFOR.
    It is not perfect FOX, but as an idead, it should work.
    Regards.

  • How to call java script function from JSP ?

    how to call java script function from JSP ?

    i have function created by java script lets say x and i want to call this function from jsp scriplet tag which is at the same page ..thanks

  • Calling a java function from xquery

    Hello,
    I'm pretty new to ODSI and xquery, so forgive me if what I'm asking is too trivial, but I need to find a way to call a java function from inside xquery. I know xquery can do this through external functions, but can't find any example on how the query prolog declaration should be, nor how the function should look like. Could someone enlighten me?
    Thanks,
    Pedro Ivo

    You can do this 2 ways that I know of (Mike probably has more ideas too)
    1. Register an inversion function:
    [How to use an inversion function|http://download.oracle.com/docs/cd/E13167_01/aldsp/docs32/dsp32wiki/Using%20Inverse%20Functions%20to%20Improve%20Query%20Performance.html]
    2. Create a physical data service based on a java function. I have used this approach for both custom JDBC database operations and straight Java processing, with pretty good results.
    Good luck,
    Jeff
    Edited by: jhoffmanme on Apr 14, 2010 9:57 AM

  • Can I call a C function from Java (using JNI) ??

    hello,
    I need to call one C function from remote device and get its return value(o/p) (for my application it is device SSID ) and display in the client PC.
    Is it possible in java without using SNMP connction?.
    please give me idea about it.
    I need this information as soon as possible.
    Thank you.

    see JNI...
    basically declare a native method in your java class, then run javah on the class thus generating a *.h file. Then implement the c/c++ function. Compile the c/c++ part as a shared library, and make sure its accessible from your LD_LIBRARY_PATH env variable.
    Go through the steps in the JNI docs, and things shoulde be fine... hopefully ;)

  • How to call a php function from java...

    helllo fellow java developers!
    Im trying to figure out how I can call a php function from my java code.
    I know it sounds a bit unintiutive, seeing how java is a rich programming language, BUT java simply cannot do the task that the php script can do. It simply acts differently.
    So I am trying to call a php function, that returns a string object, and capture that string object....
    is this possible?
    something like....
    String strMyString = phpFunction( strVariable )
    ???????/ any ideaS?

    idea #1 - come up with a better plan that doesn't involve invoking php from java.
    Give one example of something php can do that java can't.
    idea #2 - forget java, and just write it in php.
    Involving multiple frameworks/languages/runtime environments is a recipe for an overcomplicated solution that will be impossible to maintain.
    I'd say keep it simple and stupid, and stick with one language.
    If you're still hooked on the idea, maybe try [this link|http://www.infoq.com/news/2007/10/php-java-stack]

  • Calling a JavaScript function from an JApplet...

    Can anyone help? Is it possible to call a JavaScript function from within a JApplet? If so, what is the syntax? I've seen reference to the Netscape package but I've been led to believe it doesn't always work within Internet Explorer 6 which is the target browser.
    If the above is not possible can anyone tell me if and how it is possible to load images from outside the init() method of a JApplet? This would allow me to work around the problem.
    Thanks in advance - Jim.

    Call javascript you use the JSObject
    Please note the MAYSCRIPT int the html file.
    html file:
         <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
                  height="0" width="0" >
            <param name="code" value="someApplet.class" />
            <!--[if !IE]> Mozilla/Netscape and its brethren -->
            <object classid="java:someApplet.class"
                    height="0" width="0"
                    mayscript=true>
            </object>
            <!-- <![endif]-->
          </object>
    <LABEL id="lblOutputText">This text is the HTML text </LABEL>java class:
    // new class for jsObject!!!! compile this: javac -classpath "C:\Program Files\Java\jre1.5.0\lib\plugin.jar" someApplet.java
    // since jaws.jar does not exsist anymore
    // in 1.4.0 to compile: javac -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
    // for msjvm use the -source 1.3 -target 1.1 option so the command looks like this:
    // javac -source 1.3 -target 1.1 -classpath "C:\j2sdk1.4.0_03\jre\lib\jaws.jar" someApplet.java
    import netscape.javascript.*;
    public class someApplet extends java.applet.Applet {
        JSObject win;
        public void init() {
             try{
                 win = JSObject.getWindow(this);
    // you need win.eval("window.close();"); // to close the window. if the current window is not a popup
    // opened by a parent with window.open than the user will get a waring, your next question probably will
    // be "can I stop this warning" and the answer is simple: NO
                 JSObject textBoxLabel = (JSObject) win.eval("document.getElementById('lblOutputText')");
                 textBoxLabel.setMember("innerHTML", "<center><h1>Some text</h1></center>");
            }catch(Exception e){
                 e.printStackTrace();
    }

  • Is it possible to call a JavaScript function from a dialog?

    Hi there,
    At the moment I have created a dialog, that consists of three text fields that a user fills out, and then clicks next.
    What I am attempting to do, is pass the result of these three textboxes to a JavaScript function I have laying in a file in Web Resources. I've done some research, and I can't find anything.
    So my question is - is it possible to call a JavaScript function from a dialog?
    Thanks for your time.

    Hi,
         It is not possible unfortunately. We can start dialog from script but not the other way unfortunately. However, you can always write server side code for this and it will surely execute. So instead of javascript, write plug-in.
    Hope this helps.
     Minal Dahiya
     blog : http://minaldahiya.blogspot.com.au/
     If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

  • How to call a javascript function from XSL

    I'd a requirement to take an action each time a page loads
    I called the javascript function from addLoadEvent() available in javascript.
    But my reviewer commented that it should be called using XSL as we are using XSLT,
    What is preferred?
    To pass function name to the already available function or somehow call it from xsl ? if second is preferred option then,
    how to call a function through XSLT, if it is to be called aftr the page loads?

    Thank u..
    but i'd seen that link wen i searched in google..
    Is it possible without using any 3rd party JARs and all?
    and more importantly plz tell me what should be preferred way to call a javascript function?
    Do it using addLoadEvent() or Windows.Load etc
    OR
    Call it thru Xsl? (I donno how to do dis)
    Thanks in Advance..
    Edited by: ranjjose on Jun 3, 2008 8:21 AM

Maybe you are looking for

  • Keynote and Square simultaneously?

    Can I use the iPad to run a Keynote presentation AND run other aps at the same time?  Specifically, I want to use my iPad to run a keynote presentation and ALSO use Square to run credit card charges without disrupting the slide show.   Possible?

  • Are you obsessed with video? If so, I want to hear your story.

    As a storyteller, I'm always on the hunt for people who have a compelling story to tell. During the course of the year, I talk to hundreds of reporters and bloggers who are looking for folks who are passionate about technology. In this case, the tech

  • Size of the select value window in the portal for a query

    Hi, When I try to restrict the key figures structure in the portal (to select some key figures and hide others), the description of some key figures is truncated. It happens when the description of the key figure has been defined on several lines in

  • Microsoft Apps Update

    I still have not received the Mircosoft Apps. I'm on Orange UK 059C9F6. Is this available OTA? Anyone on Orange got this update?

  • Savepoint issue

    create table test (num NUMBER); insert into test values(1); insert into test values(9); savepoint a; insert into test values(7); update test set num=100 where num=9; savepoint b; delete from test where num=1; commit; delete from test where num=1;I am