Call Oracle function using PI

Can we call a Oracle function using PI? If yes then what should be the structure i.e. shoule that be built like a select ? or SQL_DML or ? Stored Procudure ?
Sample structure with example will help

Sure, is possible. You can use an JDBC Adapter (receiver or sender type).
Take a look here:
JDBC ADAPTER
http://help.sap.com/saphelp_nw04/helpdata/en/22/b4d13b633f7748b4d34f3191529946/content.htm
JDBC RECEIVER
http://help.sap.com/saphelp_nw04/helpdata/en/64/ce4e886334ec4ea7c2712e11cc567c/content.htm
JDBC MESSAGE FORMAT
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
The option to use is an your chose, in according to your requirement.
Usually, I use a StoredProcedure, except for very simple requirements.

Similar Messages

  • Calling Oracle Function Using OledbProvider

    I am trying to call DBMS_DATAPUMP.ATTACH function from C#.Net code , But i am getting error like "wrong number of arguments"
    below mentioned is my code , please help me
    OleDbConnection objCon = OpenConnection("schemausername","schmepassword","hostname");                    
                        OleDbCommand objCmd = new OleDbCommand();
                        objCmd.Connection = objCon;
                        objCmd.CommandText = "DBMS_DATAPUMP.ATTACH";
                        objCmd.CommandType = CommandType.StoredProcedure;
                        objCmd.Parameters.Clear();
                        OleDbParameter JOBNAME = new OleDbParameter("job_name",OleDbType.VarChar,256);
                        JOBNAME.Direction = ParameterDirection.Input;
                        JOBNAME.Value = "test";
                        objCmd.Parameters.Add(JOBNAME);
                        OleDbParameter OWNERNAME = new OleDbParameter("job_owner",OleDbType.VarChar,256);
                        OWNERNAME.Direction = ParameterDirection.Input;
                        OWNERNAME.Value = "schemausername";
                        objCmd.Parameters.Add(OWNERNAME);
                        OleDbParameter HANDLER = new OleDbParameter("RETURN_VALUE",OleDbType.Integer,50);
                        HANDLER.Direction = ParameterDirection.ReturnValue;
                        objCmd.Parameters.Add(HANDLER);
                        objCmd.ExecuteNonQuery;
                        handle = (int)objCmd.Parameters["RETURN_VALUE"].Value;
    Edited by: user8743382 on Aug 27, 2009 12:06 AM

    Does it work if you add the return parameter first?
    Greg

  • Ora-06502 while calling oracle function

    I am using 9.2.0.4.0 database.
    I have vb.net application that uses oracle provider for .net to connect to database.
    I am calling Oracle function which returns varchar2 value back.
    when i execute cmd2.ExecuteNonQuery, I get ora-06502 error.
    CREATE OR REPLACE FUNCTION ZZZ_TEMP( p_val IN VARCHAR2) RETURN varchar2
    AS
    BEGIN
    RETURN 'HELLO';
    EXCEPTION WHEN OTHERS THEN
    RETURN SQLCODE||' - '||SUBSTR(SQLERRM,1,100);
    END;
    ************** vb.net code
    Dim cmd2 As New Oracle.DataAccess.Client.OracleCommand(UserSchemaName & ".ZZZ_TEMP", con)
    Dim VAL As String
    Try
    cmd2.Parameters.Add("RetVal", Oracle.DataAccess.Client.OracleDbType.Varchar2, ParameterDirection.ReturnValue)
    cmd2.Parameters.Add("p_val", Oracle.DataAccess.Client.OracleDbType.Varchar2, ParameterDirection.Input).Value = "XYZ"
    cmd2.Connection = con
    cmd2.CommandType = CommandType.StoredProcedure
    cmd2.ExecuteNonQuery()
    VAL = cmd2.Parameters("RetVal").Value
    Catch ex As Oracle.DataAccess.Client.OracleException
    MsgBox(ex.Message)
    End Try

    If I change this function to retrun number rather than Varchar2 and change my
    RetVal parameter as follow it works. I am noticing that there might be a bug when function returns varchar2
    cmd2.Parameters.Add("RetVal", Oracle.DataAccess.Client.OracleDbType.int32, ParameterDirection.ReturnValue)
    cmd2.Parameters.Add("p_Val", Oracle.DataAccess.Client.OracleDbType.int32, ParameterDirection.Input).valu ="XYZ"

  • BPEL Calling Oracle Function

    Hi
    I have a simple oracle function
    create or replace function doubleme(x in integer) return integer as
    begin
    return x*x;
    end;
    i am calling this function using DBAdapter in BPEL project. I am not able to get the return value from function. Its throwing timeout exception and when i see the process the return value is null. Please let me know if i am missing anything.

    I think you're going to have to use it as a string and use string comparison.
    ~Jer

  • JAVA Calling Oracle Function and Returning OBJECT

    HI,
    I am working as a developer in java/j2ee project.
    I am facing one issue:
    I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
    Can you please help me
    With Best Regards

    golduniya wrote:
    I need to call Oracle function from java code. Oracle User define function is residing in oracle package and returning Object which contains data.
    Can you please help meIt requires a great deal of Oracle jdbc driver specific code.
    [http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/oraint.htm#1012664]

  • Can I call a function using array index?

    I've defined an array which stores the function name, like this:
    var aresetButtonTop:Array = new Array(resetTop1,resetTop2,resetTop3,resetTop4,resetTop5);  
    Then I have a button named"btnresetTop" which when clicked will call one of the five functions stored in the above array(aresetButtonTop). The functions are called at run-time depending upon some conditions. I need to figure out how I can call those functions using the array index. I'm using the following code to call the function. The value of i has been already calculated.
    btnresetTop.addEventListener(MouseEvent.CLICK, aresetButtonTop[i]);
    After doing this I'm getting the following error when I click the button:
    TypeError: Error #2007: Parameter listener must be non-null.
        at flash.events::EventDispatcher/addEventListener()
        at gallerytest_fla::MainTimeline/thumbTopClick()
    Note: thumbTopClick() is a function inside which all these codes are written.
    I need to find out whether it is posible in AS3 to call a function name using the array index or not. If yes, could you pleas ehelp me out.

    Thanx Andrei1, you were right, i was out of range.The value of i will obviously expire outside the for loop. Now I have corrected my mistake by assigning the value of i to a variable index inside the for loop and then use the following code:
    btnresetTop.addEventListener(MouseEvent.CLICK, aresetButtonTop[index])
    It was a silly mistake but I was not able to figure it out for the last 2 hours. Thanks once again for your help

  • Calling Oracle function and Procedure using OCCI with in C++ code

    Could any body send me the sample code to create and execute Oracle function and Procedure using OCCI concept in C++?.
    Edited by: 788634 on Aug 16, 2010 4:09 AM

    Hi Vishnu,
    Yes, sure, you can create a PL/SQL procedure, function, package, package body, etc. from within an OCCI application. I would say that, generally, this is not the sort of activity a typical client application would perform unless there is some initialization/installation processes that need to happen. In any case, here is a simple demo showing how to create a stand alone procedure (in a real application I would use a package and body) that returns a ref cursor. The ref cursor is just a simple select of two columns in the hr.countries sample table. Of course, there is no error handling, object orientation, etc. in this demo - I wanted to keep the code as short and as simple as possible to illustrate the concept.
    Regards,
    Mark
    #include <occi.h>
    #include <iostream>
    using namespace std;
    using namespace oracle::occi;
    int main(void)
      // occi variables
      Environment *env;
      Connection  *con;
      Statement   *stmt;
      ResultSet   *rs;
      // database connection information
      string user = "hr";
      string passwd = "hr";
      string db = "orademo";
      // sql to create the procedure which returns a ref cursor as out parameter
      // should be run as hr sample user or in a schema that has select privilege
      // on the hr.countries table and a synonym (countries) that points to the
      // hr.countries table
      string sqlCreate =
        "create or replace procedure get_countries(p_rc out sys_refcursor) as "
        "begin"
        " open p_rc for"
        " select country_id, country_name from countries order by country_name; "
        "end;";
      // pl/sql anonymous block to call the procedure
      string sqlCall = "begin get_countries(:1); end;";
      // create a default environment for this demo
      env = Environment::createEnvironment(Environment::DEFAULT);
      cout << endl;
      // open the connection to the database
      con = env->createConnection(user, passwd, db);
      // display database version
      cout << con->getServerVersion() << endl << endl;
      // create statement object for creating procedure
      stmt = con->createStatement(sqlCreate);
      // create the procedure
      stmt->executeUpdate();
      // terminate the statement object
      con->terminateStatement(stmt);
      // now create new statement object to call procedure
      stmt = con->createStatement(sqlCall);
      // need to register the ref cursor output parameter
      stmt->registerOutParam(1, OCCICURSOR);
      // call the procedure through the anonymous block
      stmt->executeUpdate();
      // get the ref cursor as an occi resultset
      rs = stmt->getCursor(1);
      // loop through the result set
      // and write the values to the console
      while (rs->next())
        cout << rs->getString(1) << ": " << rs->getString(2) << endl;
      // close the result set after looping
      stmt->closeResultSet(rs);
      // terminate the statement object
      con->terminateStatement(stmt);
      // terminate the connection to the database
      env->terminateConnection(con);
      // terminate the environment
      Environment::terminateEnvironment(env);
      // use this as a prompt to keep the console window from
      // closing when run interactively from the IDE
      cout << endl << "ENTER to continue...";
      cin.get();
      return 0;
    }

  • Calling oracle function in OMB script

    Hi
    Can anyone please tell me how can i get the returned value of an oracle function in OMB script. or how can i get the value into OMB variable and use it.
    Basically i want to set the properties of OWB mapping via OMB script.
    Following OMB code sets the max error limit of a mapping.
    OMBALTER MAPPING 'MAP_DATA' SET PROPERTIES (MAXIMUM_NUMBER_OF_ERRORS) VALUES ('100')
    i dont want to hard code the value 100 rather i want this value to be returned from a function.
    If it is not possible then plz tell me how can i set MAXIMUM_NUMBER_OF_ERRORS property of OWB mapping via sql or pl/sql.
    Any type of clue will be highly appreciated.
    Best Regards

    Here is my bare-bones OMB SQL Library to allow you to do pure SQL calls from within OMB+. All I have ever used it for is to run queries, so I don't have a library procedure for calling a function, however if your function is SQL-callable (e.g. select my_func() from dual) then it would work. Either that or you'll want to augment this library to build a procedure that will call and return the results from a java preparedStatement. It's something I've been meaning to do, but haven't got around to it yet.
    All you should need to do is save this as it's own tcl file and then source it at the top of your own script, or embed it into your script.
    EDIT: Here is a page with some sample code on using java.sql.CallableStatement to call a Pl/SQL procedure from Java which should certainly do the trick for you in conjunction with the basic session control in my library.
    http://www.exampledepot.com/egs/java.sql/CallProcedure.html
    Cheers,
    Mike
    package require java
    #file omb_sql_library.tcl
    proc oracleConnect { serverName databaseName portNumber username password } {
       # import required classes
       java::import java.sql.Connection
       java::import java.sql.DriverManager
       java::import java.sql.ResultSet
       java::import java.sql.SQLWarning
       java::import java.sql.Statement
       java::import java.sql.CallableStatement
       java::import java.sql.ResultSetMetaData
       java::import java.sql.DatabaseMetaData
       java::import java.sql.Types
       java::import oracle.jdbc.OracleDatabaseMetaData
       # load database driver .
       java::call Class forName oracle.jdbc.OracleDriver
       # set the connection url.
       append url jdbc:oracle:thin
       append url :
       append url $username
       append url /
       append url $password
       append url "@"
       append url $serverName
       append url :
       append url $portNumber
       append url :
       append url $databaseName
       set oraConnection [ java::call DriverManager getConnection $url ]
       set oraDatabaseMetaData [ $oraConnection getMetaData ]
       set oraDatabaseVersion [ $oraDatabaseMetaData getDatabaseProductVersion ]
       puts "Connected to: $url"
       puts "$oraDatabaseVersion"
       return $oraConnection
    proc oracleDisconnect { oraConnect } {
      $oraConnect close
    proc oraJDBCType { oraType } {
      #translation of JDBC types as defined in XOPEN interface
      set rv "NUMBER"
      switch $oraType {
         "0" {set rv "NULL"}
         "1" {set rv "CHAR"}
         "2" {set rv "NUMBER"}
         "3" {set rv "DECIMAL"}
         "4" {set rv "INTEGER"}
         "5" {set rv "SMALLINT"}
         "6" {set rv "FLOAT"}
         "7" {set rv "REAL"}
         "8" {set rv "DOUBLE"}
         "12" {set rv "VARCHAR"}
         "16" {set rv "BOOLEAN"}
         "91" {set rv "DATE"}
         "92" {set rv "TIME"}
         "93" {set rv "TIMESTAMP"}
         default {set rv "OBJECT"}
      return $rv
    proc oracleQuery { oraConnect oraQuery } {
       set oraStatement [ $oraConnect createStatement ]
       set oraResults [ $oraStatement executeQuery $oraQuery ]
       # The following metadata dump is not required, but will be a helpfull sort of thing
       # if ever want to really build an abstraction layer
       set oraResultsMetaData [ $oraResults getMetaData ]
       set columnCount        [ $oraResultsMetaData getColumnCount ]
       set i 1
       #puts "ResultSet Metadata:"
       while { $i <= $columnCount} {
          set fname [ $oraResultsMetaData getColumnName $i]
          set ftype [oraJDBCType [ $oraResultsMetaData getColumnType $i]]
          #puts "Output Field $i Name: $fname Type: $ftype"
          incr i
       # end of metadata dump
       return $oraResults
    # SAMPLE CODE to run a quick query and dump the results. #
    #set oraConn [ oracleConnect myserver orcl 1555 scott tiger ]
    #set oraRs [ oracleQuery $oraConn "select name, count(*) numlines from user_source group by name" ]
    #for each row in the result set
    #while {[$oraRs next]} {
      #grab the field values
    #  set procName [$oraRs getString name]
    #  set procCount [$oraRs getInt numlines]
    #  puts "Program unit $procName comprises $procCount lines"
    #$oraRs close
    #oracleDisconnect $oraConnEdited by: zeppo on Nov 25, 2008 7:19 AM

  • How to call oracle function from ejb3

    i'm trying to call an oracle query-function from ejb3.
    The oracle function:
    create or replace FUNCTION getSecThreadCount(secId in NUMBER,avai in NUMBER)
    RETURN SYS_REFCURSOR is cur SYS_REFCURSOR;
    m_sql VARCHAR2(250);
    BEGIN
    m_sql:='select count(thrId) from thread where secId='|| secid||'
    and thrAvai='|| avai;
    open cur for m_sql;
    return cur;
    END;
    I'v tried several ways to call it,but all failed:
    1. the calling code:
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNativeQuery("{call getSecThreadCount(?,?) }");     
              query.setParameter(1, secId);
              query.setParameter(2, avai);
              return query.getSingleResult();
    but i got the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: ORA-06550: row 1, col 7:
    PLS-00221: 'GETSECTHREADCOUNT' not procedure or not defined
    ORA-06550: row 1, col 7:
    PL/SQL: Statement ignored
    2. the calling code:
    @SqlResultSetMapping(name = "getSecThreadCount_Mapping")
    @NamedNativeQuery(name = "getSecThreadCount",
    query = "{?=call getSecThreadCount(:secId,:avai)}",
    resultSetMapping = "getSecThreadCount_Mapping",
    hints = {@QueryHint(name = "org.hibernate.callable", value = "true"),
              @QueryHint(name = "org.hibernate.readOnly", value = "true")})
    public Object getSectionThreadCount(int secId,int avai){
              Query query=manager.createNamedQuery("getSecThreadCount");     
              query.setParameter("secId", secId);
              query.setParameter("avai", avai);
              return query.getSingleResult();
    but i run into the exception:
    Exception in thread "main" javax.ejb.EJBException: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query; nested exception is: javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    javax.persistence.PersistenceException: org.hibernate.exception.SQLGrammarException: could not execute query
    Caused by: java.sql.SQLException: lost in index IN or OUT parameter:: 3
    By the way, i have successfully called the function from hibernate. And i use oracle 11g, JBoss5 RC1.
    Could anyone tell me how to call the function from EJB3?
    Thanks.

    Here's a working model:
    package.procedure: (created in example schema scott)
    CREATE OR REPLACE package  body data_pkg as
      type c_refcursor is ref cursor;
      -- function that return all emps of a certain dept
      function getEmployees ( p_deptId in number
      return c_refcursor
      is
        l_refcursor c_refcursor;
      begin
         open l_refcursor
        for
              select e.empno as emp_id
              ,        e.ename as emp_name
              ,        e.job   as emp_job
              ,        e.hiredate as emp_hiredate
              from   emp e
              where  e.DEPTNO = p_deptId;
        return l_refcursor;
      end getEmployees;
    end data_pkg;
    /entity class:
    package net.app.entity;
    import java.io.Serializable;
    import java.util.Date;
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.GeneratedValue;
    import javax.persistence.GenerationType;
    import javax.persistence.Id;
    import javax.persistence.NamedNativeQuery;
    import javax.persistence.QueryHint;
    import javax.persistence.SequenceGenerator;
    import javax.persistence.Table;
    @SuppressWarnings("serial")
    @Entity
    @Table (name="emp")
    @SequenceGenerator(name = "EmployeeSequence", sequenceName = "emp_seq")
    @NamedNativeQuery( name = "getEmpsByDeptId"
                   , query = "{ ? = call data_pkg.getEmployees(?)}"
                   , resultClass = Employee.class
                   , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
                          , @QueryHint(name = "org.hibernate.readOnly", value = "true")
    public class Employee implements Serializable
        @Id
        @Column(name="emp_id")
        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EmployeeSequence")
        private int id;
        @Column(name="emp_name")
        private String name;
        @Column(name="emp_job")
        private String job;
        @Column(name="emp_hiredate")
        private Date hiredate;
        // constructor
        public Employee (){}
        // getters and setters
        public int getId()
         return id;
    etc...session bean:
    package net.app.entity;
    import java.util.ArrayList;
    import java.util.List;
    import javax.ejb.Stateless;
    import javax.persistence.EntityManager;
    import javax.persistence.PersistenceContext;
    import javax.persistence.Query;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    @Stateless
    public class ScottAdminImpl implements ScottAdmin
        @PersistenceContext
        private EntityManager entityManager;
        @SuppressWarnings("unchecked")
        public List<Employee> getEmployeesByDeptId(int deptId)
         ArrayList<Employee> empList;
         try
             Query query = entityManager.createNamedQuery("getEmpsByDeptId");
             query.setParameter(1, deptId);
             empList = (ArrayList<Employee>) query.getResultList();
             return empList;
         catch (Exception e)
             e.printStackTrace(System.out);
             return null;
    }client:
    package net.app.client;
    import java.util.List;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import net.app.entity.Employee;
    import net.app.iface.ScottAdmin;
    public class ScottClient
        public static void main(String[] args)
         try
             // create local interface
             InitialContext ctx = new InitialContext();
             ScottAdmin adminInterface = (ScottAdmin) ctx.lookup("ScottAdminImpl/remote");
             // select employees by deptno
             int deptno = 20;
             List<Employee> empList = adminInterface.getEmployeesByDeptId(deptno);
             // output
             System.out.println("Listing employees:");
             for (Employee emp : empList)
              System.out.println(emp.getId() + ": " + emp.getName() + ", " + emp.getJob() + ", " + emp.getHiredate());
         catch (NamingException e)
             e.printStackTrace(System.out);
    }Basically you just ignore the refcursor outbound parameter.
    This is a stored function, have yet to try outbound refcursor parameters in stored procedures...
    Edited by: _Locutus on Apr 2, 2009 2:37 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Call Oracle Function from ASP++++!

    I have a lot of Oracle function in packages and i would like use it in my ASP pages.
    With Oracle procedure it's all right.
    Sample like this
    set cn = Server.CreateObject("ADODB.Connection")
    connString = "Provider=MSDAORA.1;Data Source=<>;User ID=<>;Password=<>"
    cn.Open connString
    SQL = "{call test.test_asp({resultset 0, cResult})}"
    Set cmd = Server.CreateObject ("ADODB.Command")
    Set cmd.ActiveConnection = cn
    cmd.CommandText = SQL
    cmd.CommandType = 1     'adCmdText
    Set rs = Server.CreateObject ("ADODB.RecordSet")
    Set rs = cmd.Execute
    If NOT (rs.BOF and rs.EOF) Then
    Do while NOT rs.EOF
    <%=rs("dfcountry")%>
    <%=rs("dfname")%>
    rs.MoveNext
    LOOP     
    End if
    And in package TEST i have
    PROCEDURE TEST_ASP(cResult IN OUT ResultCursor)
    IS
    BEGIN
    OPEN cResult FOR
    SELECT *
    FROM tcountry;
    END TEST_ASP;"
    I Hope You help me with similar call a function!!!
    For example, this is one
    FUNCTION test_fun
    RETURN resultcursor
    IS
    vres resultcursor;
    BEGIN
    OPEN vres FOR
    SELECT *
    FROM tcountry;
    RETURN vres;
    END test_fun;

    Stored Procedures
    When executing an Oracle PL/SQL stored procedure using a command, use Oracle native syntax or the ODBC procedure call escape sequence in the command text:
    Oracle native syntax: BEGIN credit_account(123, 40); END;
    ODBC syntax: {CALL credit_account(123, 40)}
    Preparing Commands
    OraOLEDB validates and fetches the metadata only for SELECT SQL statements.
    Command Parameters
    When using Oracle ANSI SQL, parameters in the command text are preceded by a colon. In ODBC SQL, parameters are indicated by a question mark ("?").
    OraOLEDB supports input, output, and input/output parameters for PL/SQL stored procedures and stored functions. OraOLEDB supports input parameters for SQL statements.
    Joel P�rez

  • Calling Oracle Functions and Procedures in Java

    I've looked online for a blurb on using Oracle SQL functions and
    procedures in Java, but I haven't found anything. Can someone
    either give me a quick crash course on this, or point me to the
    best source of information for this?

    From the SQLJ FAQ.
    http://otn.oracle.com/tech/java/sqlj_jdbc/htdocs/faq.html#sqljplsql
    Within your SQLJ statements, you can use PL/SQL anonymous blocks
    and call PL/SQL stored procedures and stored functions, as in the
    following examples: Anonymous
    block:
    #sql {
    DECLARE
    n NUMBER;
    BEGIN
    n := 1;
    WHILE n <= 100 LOOP
    INSERT INTO emp (empno) VALUES(2000 +
    n);
    n := n + 1;
    END LOOP;
    END
    Stored procedure call (returns the maximum
    deadline as an output parameter into an output host expression):
    #sql { CALL MAX_DEADLINE(:out maxDeadline) };
    Stored function call (returns the maximum
    deadline as a function return into a result expression):
    #sql maxDeadline = { VALUES(GET_MAX_DEADLINE)
    Of course, you can also use JDBC code to achieve the same - the
    standard JDBC escape sequences for stored function and procedure
    calls are supported, using for example:
    "{? = CALL GET_MAX_DEADLINE}"
    or:
    "{call MAX_DEADLINE(?)}"
    and for the rest of the details, get that JDBC crash course...

  • Calling oracle function from Access passthrough query does not return list

    Thanks to the help I received in an earlier post I've created an oracle 10g function that returns a list after executing the sql it contains. It works in oracle, using sql developer.
    I need to have the list that it returns show up in MS Access via a passthrough query. It's not working so far. The connection string etc is ok, I'm able to use passthrough queries to run sql strings successfully. But when I try to call the function via the Access passthrough query at first nothing seems to happen (ie no list appears) and if I try to run it again, there is a odbc error 'call in progress. Current operation canceled'. There are only the three records in the table. I'm missing something, can anyone spot it?
    The passthrough query looks like this
    select * from fn_testvalues from dual
    Again that runs in oracle.
    To create the testing table and 2 functions see below.
    CREATE TABLE t_values (MyValue varchar2(10));
    Table created
    INSERT INTO t_values (
    SELECT 'Merced' c1 FROM dual UNION ALL
    SELECT 'Pixie' FROM dual UNION ALL
    SELECT '452' FROM dual);
    3 rows inserted
    CREATE OR REPLACE FUNCTION fn_isnum(p_val VARCHAR2) RETURN NUMBER IS
    n_val NUMBER;
    BEGIN
    n_val := to_number(p_val);
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END;
    Function created
    testing the table:
    SELECT val, fn_isnum(MyValue ) isnum
    FROM t_values;
    VAL ISNUM
    Merced 0
    Pixie 0
    452 1
    Now the function that is called in the passthrough query:
    create or replace function fn_testvalues
    return sys_refcursor is
    rc sys_refcursor;
    begin
    open rc for
    Select t_values.*, fn_isnum(MyValue) IsNum from t_values;
    return(rc);
    end fn_testvalues;

    lecaro wrote:
    OK. But obviously there is some oracle object that one can call via an Access pass-through query which returns rows?Just to clarify. You could fetch data in Access from an Oracle function that returns a ref cursor using VBA editor. To use a pass-through query Oracle function should be a table function or pipelined table function:
    CREATE OR REPLACE
      TYPE testvalues_obj_type
        AS OBJECT(
                  val varchar2(10),
                  isnum number
    CREATE OR REPLACE
      TYPE testvalues_tbl_type
        AS TABLE OF testvalues_obj_type
    CREATE OR REPLACE
      FUNCTION fn_testvalues
        RETURN testvalues_tbl_type
        PIPELINED
        IS
            CURSOR testvalues_cur
              IS
                SELECT  testvalues_obj_type(MyValue,fn_isnum(MyValue)) testvalues_obj
                  FROM  t_values;
        BEGIN
            FOR v_rec IN testvalues_cur LOOP
              PIPE ROW(v_rec.testvalues_obj);
            END LOOP;
            RETURN;
    END;
    /To test it in Oracle:
    SELECT  *
      FROM  TABLE(fn_testvalues)
    VAL             ISNUM
    Merced              0
    Pixie               0
    452                 1
    SQL> Now in Access pass-trough query window enter:
    SELECT  *
      FROM  TABLE(fn_testvalues);SY.

  • Calling Oracle Function in PHP

    Hi,
    I'm calling a oracle function in php, the function has 1 IN parameter and 1 OUT parameter. The OUT parameter is BOOLEAN type.How to bind php variable for BOOLEAN type?
    Thanks.
    srinath.

    I think you're going to have to use it as a string and use string comparison.
    ~Jer

  • Toplink JPA Calling Oracle Function Return sys_refcursor

    I have a function which return sys_refcursor and I am trying to call this using JPA(1.0)
    @NamedNativeQuery( name = "getEmpsByDeptId"
            , query = "{ ? = call my_pck.getEmployees(:longName)}"
            , resultClass = Employee.class
            , hints = { @QueryHint(name = "org.hibernate.callable", value = "true")
                           , @QueryHint(name = "org.hibernate.readOnly", value = "true")
    DAOImpl
    query = getEntityManager().createNamedQuery("getEmpsByDeptId");
    query.setParameter("longName", "SCOTT");
    list = (List<Employee>)query.getResultList();
    However when I execute, I am getting the following exception
    Exception [TOPLINK-6132] (Oracle TopLink Essentials - 2.1 (Build b52-fcs (09/24/2008))):
    oracle.toplink.essentials.exceptions.QueryException Exception Description:
    Query argument 2 not found in list of parameters provided during query execution.
    Query: ReadAllQuery(test.entity.Employee) at oracle.toplink.essentials.exceptions.QueryException.namedArgumentNotFoundInQueryParameters
    I have tried using
    call my_pck.getEmployees(?)}"
    and
    query.setParameter(1, "SCOTT");
    However error remains the same and how can I resolve this issue?
    I have used the same function with Hibernate using JPA2.0 and it has worked.
    Thank

    lecaro wrote:
    OK. But obviously there is some oracle object that one can call via an Access pass-through query which returns rows?Just to clarify. You could fetch data in Access from an Oracle function that returns a ref cursor using VBA editor. To use a pass-through query Oracle function should be a table function or pipelined table function:
    CREATE OR REPLACE
      TYPE testvalues_obj_type
        AS OBJECT(
                  val varchar2(10),
                  isnum number
    CREATE OR REPLACE
      TYPE testvalues_tbl_type
        AS TABLE OF testvalues_obj_type
    CREATE OR REPLACE
      FUNCTION fn_testvalues
        RETURN testvalues_tbl_type
        PIPELINED
        IS
            CURSOR testvalues_cur
              IS
                SELECT  testvalues_obj_type(MyValue,fn_isnum(MyValue)) testvalues_obj
                  FROM  t_values;
        BEGIN
            FOR v_rec IN testvalues_cur LOOP
              PIPE ROW(v_rec.testvalues_obj);
            END LOOP;
            RETURN;
    END;
    /To test it in Oracle:
    SELECT  *
      FROM  TABLE(fn_testvalues)
    VAL             ISNUM
    Merced              0
    Pixie               0
    452                 1
    SQL> Now in Access pass-trough query window enter:
    SELECT  *
      FROM  TABLE(fn_testvalues);SY.

  • Problem calling Oracle function from Access 2007 / ADO

    Hopefully, I'm posting this in the correct forum. I'm also posting on an Access forum as I'm not entirely sure where the issue lies.
    I'm calling an Oracle function from Access 2007 using an ADO Command object.
    The function takes three input parameters and has a return value and an output parameter. The output parameter is a BLOB, and the return value is varchar2 (either "T" or "N") based on the outcome of the function.
    If I pass correct values to the function, I get the following error message (errs out on the command.execute line):
    Run-time error '-2147467259 (80004005)':
    [Oracle][ODBC][Ora]ORA-06502: PL/SQL: numeric or value error
    ORA-06512: at line 1
    Here's the function:
    FUNCTION GET_ITEMREV_ATTACH(P_ORGANIZATION_ID IN NUMBER,
    P_INVENTORY_ITEM_ID IN NUMBER,
    P_REVISION IN VARCHAR2,
    X_DRAWING OUT BLOB) RETURN VARCHAR2 IS
    RESULT VARCHAR2(1);
    BEGIN
    RESULT := 'T';
    BEGIN
    SELECT L.FILE_DATA
    INTO X_DRAWING
    FROM FND_ATTACHED_DOCUMENTS AD,
    MTL_ITEM_REVISIONS_B IR,
    FND_DOCUMENTS_TL D,
    FND_LOBS L
    WHERE AD.ENTITY_NAME = 'MTL_ITEM_REVISIONS' AND
    AD.PK1_VALUE = IR.ORGANIZATION_ID AND
    AD.PK2_VALUE = IR.INVENTORY_ITEM_ID AND
    AD.PK3_VALUE = IR.REVISION_ID AND
    AD.CATEGORY_ID = 1001216 AND
    D.DOCUMENT_ID = AD.DOCUMENT_ID AND
    D.LANGUAGE = 'US' AND
    L.FILE_ID = D.MEDIA_ID AND
    IR.ORGANIZATION_ID = P_ORGANIZATION_ID AND
    IR.INVENTORY_ITEM_ID = P_INVENTORY_ITEM_ID AND
    IR.REVISION = P_REVISION;
    EXCEPTION
    WHEN OTHERS THEN
    RESULT := 'N';
    END;
    RETURN(RESULT);
    END GET_ITEMREV_ATTACH;
    Here's the VB code I'm using to call the function:
    Private Sub Command8_Click()
    Dim CMD As New ADODB.Command
    Dim conn As ADODB.Connection
    Dim Param1 As ADODB.Parameter
    Dim Param2 As ADODB.Parameter
    Dim Param3 As ADODB.Parameter
    Dim ParamBlob As ADODB.Parameter
    Dim ParamReturn As ADODB.Parameter
    Set conn = New ADODB.Connection
    With conn
    .ConnectionString = "Driver={Oracle in OraHome92};Dbq=OAPLY;UID=***;PWD=*******"
    .CursorLocation = adUseClient
    .Open
    End With
    Set CMD = New ADODB.Command
    Set CMD.ActiveConnection = conn
    CMD.CommandText = "immi_attach_pub.get_itemrev_attach"
    CMD.CommandType = adCmdStoredProc
    Set ParamReturn = CMD.CreateParameter("RESULT", adVarChar, adParamReturnValue, 1)
    CMD.Parameters.Append ParamReturn
    Set Param1 = CMD.CreateParameter("P_ORGANIZATION_ID", adInteger, adParamInput, 1, 6)
    CMD.Parameters.Append Param1
    Set Param2 = CMD.CreateParameter("P_INVENTORY_ITEM_ID", adInteger, adParamInput, 4, 5207)
    CMD.Parameters.Append Param2
    Set Param3 = CMD.CreateParameter("P_REVISION", adVarChar, adParamInput, 2, "04")
    CMD.Parameters.Append Param3
    Set ParamBlob = CMD.CreateParameter("X_DRAWING", adLongVarBinary, adParamOutput, 200000)
    CMD.Parameters.Append ParamBlob
    CMD.Execute , , adExecuteNoRecords *** this is where the error occurs
    conn.Close
    MsgBox CMD.Parameters("RESULT")
    End Sub
    I've tried using different data types for the varchar2 parameters (adVarChar, adBSTR, adChar) with no difference.
    If I pass a bogus value for Param3...."'04'"...the function returns "N" indicating that it actually executed something. But, when I pass the correct value "04", it returns the above mentioned error.
    I can execute the function in PL/SQL just fine, so I'm thinking there's something wrong with the parameters, datatype, or other definitions on the Access side.
    Does anyone have any thoughts? I'm at a dead end with this. Sorry for the long post. Thank you.

    I tried your code with 11107 ODBC/client/database (but with a NULL output blob for convenience sake) and got no errors.
    If you're using 92 ODBC/client, you may want to try upgrading to something more current, or at least getting the latest patch(9208) to see if that helps. Since it works for me I'm guessing it may be a resolved bug in that version.
    Hope it helps,
    Greg

Maybe you are looking for

  • Interactive report jquery not executed on pagination

    recently i fell into another problem when using jquery in an interactive report. in the page header i do this <script type="text/javascript"> $(document).ready( function() {    var pageID = $('#pFlowId').val();    $('.Artikelinfo').each( function(i)

  • [solved] MP3 library management question, need advice

    Let me preface this, I LOVE amarok 1.4. Not as a player, hundreds of apps can play MP3's, but its ability to organize/tag. I have a new dir of MP3s, I can open them into the playlist, tag/retag/run musicbrainz, then import them into the master direct

  • Bank account number not reflecting while creating invoice some parties

    Hi All, We are facing following issue while creating invoice's for some particular parties. Bank account number is not reflecting while creating invoice at invoice work bench from front end. Bank account details are properly attached at party site le

  • After migration from HDD to SSD, thumbnails in iPhoto are missing

    Dear Apple-community, I migrated my system a week ago. I added a SSD to the HDD which is now in an optibay. After adding the SSD I installed Lion from new on the SSD, migrated all programms etc. from the HDD and left only the user-folders on the HDD.

  • Iphone has stuck in the middle of a restore

    Help! I was trying to install the 3.1OS and it all went horribly wrong. I was required to restore, which I did, but when the phone tried to reconnect into itunes I get an error saying ' we could not complete your iTunes store request. The network con