Call Oracle function from Stored Procedure

Hi,
I have function Which returning one number. I want to use that number in a procedure. How to call the Oracle Function from the Procedure
Create procedure
AS
Begin
Check number;
Select Function1 into check from dual;
It is giving error.
Can anyone provide me example for this.
Thanks in advance

Put the Check Number; before begin
SQL> create or replace procedure abc as
  2 begin
3 val number;
  4  select abcd into val from dual;
  5  dbms_output.put_line(val);
  6  end;
  7  /
Warning: Procedure created with compilation errors.
Elapsed: 00:00:00.00
SQL> show error
Errors for PROCEDURE ABC:
LINE/COL ERROR
3/5      PLS-00103: Encountered the symbol "NUMBER" when expecting one of
         the following:
         := . ( @ % ;
         The symbol ":=" was substituted for "NUMBER" to continue.
SQL> create or replace procedure abc as
  2 val number;
3 begin
  4  select abcd into val from dual;
  5  dbms_output.put_line(val);
  6  end;
  7  /
Procedure created.
Elapsed: 00:00:00.00
SQL> exec abc;
100.22
PL/SQL procedure successfully completed.
Elapsed: 00:00:00.00
SQL>

Similar Messages

  • Calling Oracle Reports from stored procedures

    Hi ,
    Can anybody tell me whether this is possible and if so, how it can be done. Thanks for your help.
    Regards,
    Deepa

    Oracle Forms allows you to easily integrate Oracle Reports into your
    applications. However, on the Macintosh, it is not possible to use
    the normal Oracle Reports runtime to generate ASCII text files. In
    order to allow ASCII text files to be generated with Oracle Reports
    on the Macintosh, the Reports<TEXT> Runtime applications was
    developed. This version of the runtime only allows you to generate
    text files and should not be used for other purposes.
    While the Reports<TEXT> Runtime application has been provided, there
    is no built in integration with Forms. This bulletin explains a
    method which you can use integrate these two applications with little
    effort. In order to use this method, you will need the following
    items installed on your computer:
    * Oracle Forms 4.0
    * Oracle Reports 2.0
    * Oracle Command 1.0
    * AppleScript 1.1. This is available as part of the Macintosh
    Operating System version 7.5 as well as with certain 3rd party
    applications.
    Because the only way to use the Reports<TEXT> Runtime application is
    through Oracle Command, we will be using Oracle Command to run the
    Reports<TEXT> Runtime application. However, we need some way to
    communicate with Oracle Command which report we would like to run and
    what parameters we would like to pass in to Reports. To accomplish
    this goal, an AppleScript application will be used. Forms can use
    AppleEvents (Apple's method for inter-application communication) to
    communicate with this AppleScript application which can then create
    an Oracle Command script file to run. So, the summary of events
    which will take place are as follows:
    1. Forms dynamically creates a command line to run the
    Reports<TEXT> Runtime application.
    2. Using AppleEvents, Forms communicates this command line to the
    AppleScript application which writes out an Oracle Command
    script file.
    3. The AppleScript application communicates with Oracle Command and
    tells it to run the script which it just created.
    4. Oracle Command runs the script which invokes the Reports<TEXT>
    Runtime application.
    1. Creating the AppleScript Application
    The core of this solution is the AppleScript Application. While it
    is not necessary for you to be familiar with AppleScript, it will
    help tremendously in your understanding of how everything works.
    Here we provide you with an AppleScript which provides the
    functionality we need to implement our procedure.
    Note: This AppleScript is designed to work with the Macintosh
    Operating System version 7.5. It should work with earlier
    versions of the Operating System, but no guarantees are
    made. Furthermore, there are known problems with the version
    of AppleScript provided with version 7.1.2 of the Operating
    System which will cause your machine to crash when this
    script is executed. These problems with AppleScript were
    corrected for the version 7.5 release of the Operating System.
    -- This AppleScript Application is responsible for being a
    -- "go-between" between Oracle Forms and Oracle Command. It is
    -- responsible for both dynamically creating Oracle Command script
    -- files and disposing of these files.
    -- NOTE: This AppleScript Application was written for the Macintosh
    -- Operating System version 7.5. It has not been tested
    -- on any other version of the Macintosh Operating
    -- System.
    -- Author
    -- ======
    -- Doug Bitting
    -- Oracle Worldwide Technical Support
    -- Apple Desktop Products Group
    -- Date: 21-MAR-95
    -- The syntax "on <<...>> args" is how you setup an AppleScript to
    -- accept AppleEvents.
    -- Be careful, the << and >> characters are option-\ and option-|
    -- respectively. They are not two less-than signs and two
    -- greater-than signs.
    on <<event R20Trunt>> cmdScript
    -- First, let's construct a, hopefully, unique file name
    set dt to ((current date) as string)
    set hr to (word 5 of dt)
    set mn to (word 6 of dt)
    set sec to (word 7 of dt)
    set fName to (hr * 3600 + mn * 60 + sec as string)
    -- For this example, we will put all dynamically constructed
    -- script files onto the desktop.
    set tFold to (path to desktop)
    set fName to (tFold & "tmp." & fName as string)
    -- set up a mnemonic for the Return character
    set cr to (ASCII character 13)
    try
    -- open our Oracle Command script file
    -- The sequence <opt-l> at the end of the following line
    -- should be type in as an option-l (that is, a lowercase L).
    set fRef to (open for access file fName with write <opt-l>
    permission)
    -- Now, write the Oracle Command command line which was
    -- passed to us via AppleEvents.
    -- The sequence <opt-l> at the end of the following line
    -- should be type in as an option-l (that is, a lowercase L).
    write (cmdScript & cr) starting at <opt-l>
    ((get eof fRef) + 1) to fRef
    -- Now we have to also ask Oracle Command to let us know
    -- when it is finished with the script file we are
    -- creating. Basically, we are asking Oracle Command to
    -- use AppleEvents to let us know when to throw away the
    -- file we are creating
    -- The sequence <opt-l> at the end of the following lines
    -- should be type in as an option-l (that is, a lowercase L).
    write ("host SENDAE aplt R20T remv ---- t \"" & fName <opt-l>
    & "\";" as string) starting at <opt-l>
    ((get eof fRef) + 1) to fRef
    -- close the Oracle Command script file
    close access fRef
    -- Now that we have setup the temporary file,
    -- tell Oracle Command to execute it.
    tell application "Oracle Command 1.0"
    runscript fName
    end tell
    -- You can put some error handling here if you'd like.
    end try
    end <<event R20Trunt>>
    -- This is the AppleEvent handler to clean up when we are done. It
    -- simply throws the temp file into the trash can.
    -- Be careful, the << and >> characters are option-\ and option-|
    -- respectively. They are not two less-than signs and two
    -- greater-than signs.
    on <<event R20Tremv>> fName
    tell application "Finder"
    move (fName as alias) to (path to trash)
    end tell
    end <<event R20Tremv>>
    2. Setting Up Forms
    It is useful to setup a PL/SQL Program Unit to hide the details
    behind running the Text Runtime. Here is a suggested PL/SQL Program
    Unit for you to use:
    -- The following procedure is used to hide some of the details in
    -- using the AppleScript Application. It accepts 4 arguments:
    -- * The report name
    -- * The name of the output file
    -- * The parameters you would like to pass in. These need to be
    -- formatted just as if you were calling reports from a
    -- command line.
    -- * A connect string for Reports<TEXT> Runtime to connect with.
    procedure run_text_report (
    rName in char,
    oName in char,
    params in char,
    cString in char) is
    cLine varchar2(1000);
    begin
    cLine := 'execute r20text module='&#0124; &#0124;rname;
    cLine := cLine &#0124; &#0124; ' userid='&#0124; &#0124;cString;
    cLine := cLine &#0124; &#0124; ' paramform=no batch=yes';
    cLine := cLine &#0124; &#0124; ' destype=file desname='&#0124; &#0124;oname;
    cLine := cLine &#0124; &#0124; ' desformat=dflt.prt '&#0124; &#0124;params&#0124; &#0124;';';
    host('SENDAE aplt R20T runt ---- t "'&#0124; &#0124;cLine&#0124; &#0124;'"');
    -- NOTE: in the above host() command, the series of quotes at the
    -- end reads as follows: double-quote, single-quote, vertical
    -- bar, vertical bar, the word cLine, vertical bar, vertical
    -- bar, single-quote, double-quote, single-quote.
    end;
    Here is an example of how I can use the above procedure. In a
    WHEN-BUTTON-PRESSED trigger, I might have:
    declare
    reportName varchar2(16);
    outputName varchar2(64);
    paramVals varchar2(64);
    connectStr varchar2(16);
    begin
    -- We want to run the report named "myreport". The output from this
    -- report should go into a file named "output.txt" located in the
    -- "Reports" directory on my hard drive. This report accepts two
    -- parameters: p_start_date and p_end_date. The connect string for
    -- the database I am using is simply "scott/tiger"
    -- Setup some variables to hold all the information I want to pass
    -- in to run_text_report(). This information is put into variables
    -- for readability.
    reportName := 'myreport';
    outputName := 'HD:Reports:output.txt';
    paramVals := 'p_start_date=''01-MAR-95'' p_end_date=''31-MAR-95''';
    connectStr := 'scott/tiger';
    -- Run the report
    run_text_report(reportName, outputName, paramVals, connectStr);
    end;
    3. Putting the pieces together
    In order for this solution to function, you need to make sure that
    both your AppleScript application and Oracle Command are running when
    you make a call to run_text_report(). It is possible for you to
    launch Oracle Command from within Oracle Forms with the following
    line of code:
    host('LAUNCHID oBTL');
    If you place the above line of code in a WHEN-NEW-FORM trigger, you
    can assure that Oracle Command will be running when your form is
    launched.
    It is also possible for you to have Oracle Forms launch your
    AppleScript application. However, in order for you to do this, you
    need to be very familiar with the Macintosh Operating System, how to
    change the creator type of a file, and know what effects that change
    can produce. If you do not know how to change the creator type of
    your AppleScript application or are not comfortable doing so, you
    should simply document that your users need to make sure to launch
    your AppleScript application before trying to use your Form.
    However, if you know how to change the creator type of your
    AppleScript application and are comfortable doing so, here are the
    steps you will need to take to have Oracle Forms launch your
    AppleScript application for you:
    * Change the creator type of your AppleScript application to
    something unique.
    * Modify the run_text_report() procedure. You need to change the
    four character sequence "aplt" found in the host() command to the
    new creator type of your AppleScript application.
    * Add the line host('LAUNCHID <your new creator type>'); to your
    WHEN-NEW-FORM trigger or to whichever trigger you placed the
    host('LAUNCHID oBTL'); statement.
    There is one significant difference between RUN_PRODUCT and this
    solution. With RUN_PRODUCT, you have the option of specifying
    whether or not the call should be synchronous or asynchronous.
    However, the call to run_text_report() will always be asynchronous.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Deepa Pai:
    Hi ,
    Can anybody tell me whether this is possible and if so, how it can be done. Thanks for your help.
    Regards,
    Deepa <HR></BLOCKQUOTE>
    null

  • 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

  • How can I call a function from a procedure

    I have a function named: f_calc_value which return the variable v_result. This function is part of a package.
    How can I call this function from a new procedure I am creating?
    Thanks

    or refer this theread....calling function from procedure

  • Calling DTS package from Stored Procedure

    I am getting error calling DTS package from CF.
    So i want to call DTS package from SQL Server Stored
    Procedure.
    DTS package create text file. So no need of input or output
    parameter.
    What is the syntax?.
    thanks for ur help.

    Ted Kruger explains how this can be done in his blog post
    Run SSIS Package from Stored Procedure
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog

  • 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

  • Calling ORACLE Functions from within CF Builder report

    Hi, I have an ORACLE function that I would like to call from within my CF REPORT.
    I know there is a section in the report builder where you can write coldfusion code to perform tasks, but I would rather simply call the ORACLE function for each detail row in the report
    I do not want to call this function from within my main ORACLE query that I use for the report, so please don't suggest that.
    Thanks so much.
    -Jim

    6.0.5 is not certified against 10g database, so I suggest to upgrade to 6.0.8.26 (6i patch 17) first to see if the problem is gone.

  • How to call 'C' programs from stored procedures?

    Hi
    Did anybody tried to call 'C' programs
    from oracle stored procedures?
    If anybody knows, can you please send
    how to configure the listener.ora and
    tnsnames.ora. If its possible post all the
    information from the begining with examples.
    thanks....

    Oracle JDBC did not support return a result set, if you are using Oracle 9i, you can use pipeline function, then using the TABLE() function the get the row.
    Good Luck.
    Welcome to http://www.anysql.net/en/

  • Calling Java Methods from Stored Procedures

    Can I call Java Methods from Oracle Stored Procedures? I have a Java framework that logs events and would like to reuse it for logging events that occur in stored procedures.
    null

    You need to publish java class methods to plsql.
    Attached below is some information.
    Although both PL/SQL modules and Java classes are stored in the database
    and are managed by many of the same mechanisms, each of them resides in
    its own namespace. Therefore, Java methods are not accessible from SQL
    and PL/SQL by default. In order to expose Java methods to the SQL and
    PL/SQL engines, first publish that Java method to the SQL namespace using
    a 'Call Spec'.
    Note: A 'Call Spec' does not create an additional layer of
    execution so there is no performance penalty incurred.
    A 'Call Spec' is simply a syntactical mechanism used to
    make a method known in the SQL namespace.
    The SQL name established by the 'Call Spec' can be top-level or packaged.
    The syntax differs only slightly and is consistent with that used for
    PL/SQL procedures and packages. For more information on the exact
    syntax, see the references listed in 'Related Topics'.
    In general, a top-level procedure 'Call Spec' takes the form:
    CREATE OR REPLACE PROCEDURE procname ( pname mode ptype, ... )
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... )';
    Where: procname is the SQL name you wish to publish
    pname is the name for a parameter to procname
    mode is the parameter mode (i.e. IN, OUT, IN OUT)
    ptype is a valid SQL type (e.g. NUMBER, CHAR, etc.)
    javaname is the fully qualified name of the Java method
    javatype is a Java type for the corresponding parameter
    Likewise, a top-level function 'Call Spec' takes the form:
    CREATE OR REPLACE FUNCTION fname ( pname mode ptype, ... ) RETURN rtype
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... ) return javatype';
    Where: fname is the SQL name you wish to publish
    rtype is the SQL return type of the function
    Note: Within the NAME clause, everything within quotes is case
    sensitive. For example, if the keyword 'return' is in all
    CAPS, this Call Spec will not compile.
    Other optional parts of this syntax have been omitted here for simplicity.
    Additional examples in subsequent sections illustrate some of these options.
    eg
    CREATE PROCEDURE MyProc (rowcnt IN NUMBER, numrows OUT NUMBER)
    AS LANGUAGE JAVA NAME 'MyClass.MyMethod(int, int[])';
    There are several important things to note here:
    1.) The 'Call Spec' for a JSP must be created in the same schema as the
    corresponding Java class that implements that method.
    2.) IN parameters are passed by value. This is the only parameter mode
    available in Java. OUT parameters, therefore, must be passed as single
    element arrays in order to emulate pass by reference.
    3.) Parameter names do not need to match, but the number and types of
    the parameters must match (with just one exception - see item 5 below).
    Oracle 8i supports conversions between an assortment of SQL and Java.
    See the references listed in 'Related Topics' for additional information.
    4.) Primitive types (e.g. int, float, etc.) are not required to be fully
    qualified with any package name. However, standard Java object types
    (e.g. String, Integer, etc.) as well as any user defined object types
    (e.g. like those generated by JPublisher) must be prefixed with a
    corresponding package name (e.g. java.lang) if applicable.
    5.) The 'main' method which takes a single String[] parameter can be
    mapped to any PL/SQL procedure or function which takes some number
    of VARCHAR2 or CHAR type IN parameters. For example, the java method:
    public static void main ( String[] args ) { ... }
    can be mapped to each of the following:
    PROCEDURE MyProc2 ( arg1 IN CHAR ) ...
    PROCEDURE MyProc3 ( arg1 IN CHAR, arg2 IN VARCHAR2 ) ...
    PROCEDURE MyProc4 ( arg1 IN VARCHAR2, arg2 IN VARCHAR2 ) ...
    and so forth. Parameters map to the corresponding element of the String
    array (e.g. arg1 -> args[0], arg2 -> args[1], etc.).
    null

  • Calling oracle function from access

    does anyone know if it s possible to call a oracle pl/sql function from access ?
    thx in advance
    Andre

    As long as you do not need a return value from the procedure, you can call it from Access.
    Create a QueryDef object as a sql pass through query. Make sure that you set the ReturnsRecords property of the QueryDef to false. Set the SQL property of the QueryDef to the correct syntax to execute your procedure, then call the Execute method of the QueryDef object.

  • Calling shell script from stored procedure.

    Hi Everybody,
    Could anyone tell me how to call a shell script from a stored procedure.
    Thanks,
    Vasu

    You would need to write a Java stored procedure that calls out to the underlying operating system. Tom Kyte has an example of this here
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:952229840241
    Make sure that you're very aware of the security implications here, however. Your commands will run as the Oracle user on the host operating system, which makes it possible that a coding error and/or an attacker could do something like delete or corrupt Oracle data files, so you'll probably want to harden the code substantially.
    Justin

  • Can we able to call .bat file from Stored procedure?

    My actual requirement is to import an csv file(where it contains a table) into oracle Database from the front end screen when the csv file location is given.
    Where in the screen (designed by dotnet) a browse option will be present and I will give the csv file location and this will be passed into stored procedure as an input parameter.
    Now I need a stored Procedure that can Import my csv file table data into Oracle database10g.
    I shoudnot use the import option present in the physical Oracle Database.
    Can any one please provide me the stored Procedure?

    NGK246 wrote:
    My actual requirement is to import an csv file(where it contains a table) into oracle Database from the front end screen when the csv file location is given.
    Where in the screen (designed by dotnet) a browse option will be present and I will give the csv file location and this will be passed into stored procedure as an input parameter.
    Now I need a stored Procedure that can Import my csv file table data into Oracle database10g.You do not seem to understand the basic concept of client-server. If you supply a file location for the server code, and that location is not on the server, how do you expect the server to access that file in that location?
    You cannot expect the server to hacks its way across the network, crack open a remote file system somewhere, and steal that file from that location.
    As the client has access to that location and file, the client needs to read that file and supply that file's content to the server. This is how the server receives a file from a client. With Oracle. With FTP. With SCP. With SFTP. With HTTP. With SMTP and file attachments to e-mails. Etc.
    This is not specific to Oracle. This is a fundamental concept. So the problem here is your ignorance of client-server and not a problem with Oracle and not a problem with PL/SQL.
    I shoudnot use the import option present in the physical Oracle Database.Not sure what this mean, but the basic statement that "+we should not use feature 123 or feature ABC of Oracle+", is invariable an utterly idiotic statement to make. Kind of like buying a car and then making the statement that groceries may not be put into the truck as the car's trunk should not be used.
    Can any one please provide me the stored Procedure?Very arrogant of you to assume that others will spend their free time writing code for you - with you copying-and-pasting that code and providing it to your employers, as your work...

  • Oracle function in stored procedure to retreive particular table name

    Hi,
    I need to delete a table 'xxsys_dram_flatproperties' from database given model name as 'dram-model'.
    the model name can be any thing.corresponding table name will be[i] 'xxsys_<modelname>_flatproperties'.
    I wrote stored procedure .I am able to retrieve all the tables in the database using user_tables.Is there any funtion in oracle like
    if table name contains letters that are there in model name.
    Pleasehelp.

    Suppose all your tables created in the schema 'temp'
    and you are absolutly sure you want to drop only tables which have for example '_model3_' in its name (nothing else should have same part in your schema)
    then try a simple solution:
    CREATE TABLE temp.xx_model3_01 (col1 NUMBER)
    CREATE TABLE temp.xx_model3_02 (col1 NUMBER)
    SELECT table_name from all_tables where OWNER = 'TEMP' and table_name LIKE '%_MODEL3_%'
    TABLE_NAME                   
    XX_MODEL3_01                 
    XX_MODEL3_02
    DECLARE
       CURSOR c1
       IS
          (SELECT table_name
             FROM all_tables
            WHERE owner = 'TEMP' AND table_name LIKE '%_MODEL3_%');
    BEGIN
       FOR rec IN c1
       LOOP
          EXECUTE IMMEDIATE 'DROP TABLE ' || rec.table_name;
       END LOOP;
    END;

  • 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.

Maybe you are looking for

  • I'm getting a segmentation fault on the laptop

    I'm getting a segmentation fault when trying to upgrade system (pacman -Syu). This happened after my battery went empy (this is a laptop). Here goes the output of `pacman -Syu --debug': debug: config: attempting to read file /etc/pacman.conf debug: c

  • Pictures in iPhoto do not show up after being moved to external hard drive.

    I moved an iPhoto library to an external hard drive.  When I created this library I did not tick on "Copy items to the iPhoto library" when importing.  I wanted to keep the pictures in the folders neatly.  These folders were moved to the external har

  • Attachement document to PO

    HI In order to create a document attachement in PO, with the DMS function, i've the possibilité to create an attachement document to a contract, but i have only the possibilty to display document attachement in PO, is there in authorization object or

  • Technical issue

    i have torch 9810..it is touch plus type...but my type keypad has stopped working and my touch keypad is also giving problems...so i cannot type msgs and even the light fluctuates continuously...what should i do?

  • Oracle Dataguard - Logs apply issue

    Hi, Due to some issue our archives logs are not applying from production to standy. we had our standby at London. i dont see any error messages. not sure what is happening, i had case open with oracle support. we need to shutdown all our production a