Skip to Main Content

Data Science & Machine Learning

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

calling a R function from sql

User763151-OracleMar 10 2014 — edited Mar 12 2014

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

This post has been answered by Sherry Lamonica-Oracle on Mar 10 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 9 2014
Added on Mar 10 2014
4 comments
2,619 views