Need help by calling the stored procedure

Hi Experts,

I created under procedure, while calling me, it throws an error.
CREATE OR REPLACE PROCEDURE spdemo (param1 OUT NUMBER)
 is
 BEGIN
 SELECT COUNT(*) INTO param1
 FROM TEST_DEMO;
 END;
Can any1 help me get the result or to call this procedure?

Thnx in advance...

Published by: 977490 on January 18, 2013 02:25

Hello

977490 wrote:
... I created under procedure, while calling me, it throws an error.

If the problem of the call, and then after the call.

Here's a possible way to call spdemo and see the results:

SET   SERVEROUTPUT   ON

DECLARE
    test_demo_cnt  NUMBER;
BEGIN
    spdemo (test_demo_cnt);

    dbms_output.put_line (test_demo_cnt || ' = value returned by spdemo');
END;
/
CREATE OR REPLACE PROCEDURE spdemo (param1 OUT NUMBER)
is
BEGIN
SELECT COUNT(*) INTO param1
FROM TEST_DEMO;
END;

I'm tempted to make a function, not a procedure.

CREATE OR REPLACE FUNCTION spdemo
RETURN NUMBER
 IS
    cnt          NUMBER;
 BEGIN
     SELECT  COUNT (*)
     INTO    cnt
     FROM    test_demo;

     RETURN  cnt;
 END;
/
SHOW ERRORS

Then you can call it in the SQL statements, as you call functions such as SYSDATE:

SELECT     spdemo
FROM     dual
;

Tags: Database

Similar Questions

  • Call the stored procedure, and bind parameters by name

    Hello

    I use the Oracle ODBC 12 c driver to pass values from one Interface to our database Oracle 11.2. The Interface software collects data from modbus protocoll and calls a stored procedure. Right now my syntax to call the stored procedure looks like this:

    CALL procedure-name ('STRING', 'Timestamp as String', numValue1);

    It works very well. Now, I have to add a default setting to my procedure. To stay flexible to make other changes, I want to call the procedure and bind the parameters by name. Release 10.2.0.1.0 ISC ODBC Notes:

    Added support for the named parameter, binding the parameters by name. ODBC Oracle driver now allows the application to specify the parameters of a stored procedure by name, in the procedure call. Named parameters are to be used in calls to stored procedures and should not be used in other SQL statements.

    So, it shouldn't be a problem to use named notation, but how do I do this in ODBC? I tried like this, but oracle returns an ora-00936 error of missing expression:

    call procedure-name (paramName1 = > 'STRING',= paramName2 > 'Timestamp as String',paramName3 = > numValue1).


    Thank you for your help.

    Finally, I was able to find the error. The syntax of the statement was very good. The problem was caused by another declaration that I edited before and the error has not attracted Attention immediately.

    Thanks for reading and looking for an answer.

  • How to call the stored procedure from javascript? (Google suggest, AJAX)

    Hi I want to set up a text field so that it behaves like [Google Suggest | http://www.google.com/webhp?complete=1 & hl = en].

    I read this post .

    Now, I installed everything according to this document. But it simply doesn't. And I don't know why.

    I think that problems can fall into the following three categories:
    1. the text field and the page invoking the appropriate javascript?
    2 - is the JavaScript call the stored procedure?
    3. the stored procedure correctly returns the result formatted?

    I'm assertive for 1 and 3, but I'm not sure 2. Because I don't know how if a stored procedure has been called? Is there a PL/SQL statement that I can query in SQL * more?

    Also, I would like to know how to debug AJAX in the APEX. It involves a lot of things.

    Finally, I used APEX 3.2 and Oracle XE. I can't find file dads.conf or marvel.conf. Is ' / apex / "the virtual directory for APEX?

    Thank you very much!

    Buffalo,

    I managed to make it work on XE with APEX 3.2!
    It took more time than expected because my XE installation was still on an earlier version of the Apex and I had put it first...

    But that's what I did:
    -in the ac.js file, I changed the path ' / apex / "and I added the ac.js file to my candidacy as a static file. So as you did.
    -J' copied my request to the XE and copied my procedure on the schema that is related to my request
    -J' gave to run anonymous rights my procedure

    Now at first, it did not work...
    Then I suddenly remembered something: If you want to run a procedure through the pl/sql gateway in the XE, XE please how it is.
    Do you this by changing the APEX_030200.wwv_flow_epg_include_mod_local function!

    This is the code for the function changed for my example:

    CREATE OR REPLACE function APEX_030200.wwv_flow_epg_include_mod_local(
        procedure_name in varchar2)
    return boolean
    is
    begin
        --return false; -- remove this statement when you modify this function
        --
        -- Administrator note: the procedure_name input parameter may be in the format:
        --
        --    procedure
        --    schema.procedure
        --    package.procedure
        --    schema.package.procedure
        --
        -- If the expected input parameter is a procedure name only, the IN list code shown below
        -- can be modified to itemize the expected procedure names. Otherwise you must parse the
        -- procedure_name parameter and replace the simple code below with code that will evaluate
        -- all of the cases listed above.
        --
        if upper(procedure_name) in (
              'MATTHIASH.INCSEARCH') then
            return TRUE;
        else
            return FALSE;
        end if;
    end wwv_flow_epg_include_mod_local;
    /
    

    After that, the AJAX function worked as expected...

    HTH
    Matthias Hoys

    Published by: mhoys on August 13, 2009 15:24

  • Creation of Adaptert DB to call the stored procedure in MS SQL server

    Hello

    I need to create a DB adapter to call a stored procedure in MS SQL Server.

    I went through the MS SQL Server database connecting wire

    He mentions that he must use a command line utility to generate the wsdl and xsd to call stored procedures in MS SQL server. Please indicate where this utility and how to use it.

    All links to tutorials are welcome.

    Thank you!!.

    Silas.

    The key is SOA_HOME\j2ee\home\connectors\DbAdapter\DBAdapter.jar.

    Make sure that the DBAdapter.jar is at this place

    in my case, it is

    e:\Oracle\product\soa\10.1.3\j2ee\home\connectors\DbAdapter\DBAdapter.jar

    see you soon
    James

  • call the stored procedure to a pop up window problem

    Hello

    I use jdev 10g. with ADF BC.

    I have a page jspx with a command button passing 2 parameters to a window popup using processScope. This window contains an entry form containing the parameters passed and 1 other inputText field. The user will enter a value for the inputText field and click the OK button. When you click this button, I need to pass the value entered by the user as well as the parms passed 2 to the AM that calls my stored procedure. The inputText field is defined as < af:inputText value = "#{bindings.workCode.inputValue}" which works very well but the parms passed show as null in the AM. "

    How can I get these 2 parameters to pass to the AM?

    Thank you!

    The following code prints null as well?

    public void Oracle_Proc (String seqNo, String yrCode, String subdivided) {}

    * System.out.println ("seqNum:" + getELValue("#{processScope.seqNum}")); *
    * System.out.println ("yearCode:" + getELValue("#{processScope.yearCode}")); *

    CallableStatement cs = this.getDBTransaction () .createCallableStatement ("{call user. Oracle_Proc(:1,:2,:3)} ", 1);
    try {}

    cs.setString (1, seqNo);
    cs.setString (2, yrCode);
    cs.setString (3, subdivided).
    DSI Execute();

    } catch (SQLException e) {}
    TODO
    e.printStackTrace ();
    }
    }

    * public String getELValue (String expr) {*}
    * FacesContext fc = FacesContext.getCurrentInstance (); *
    * ValueBinding vb = fc.getApplication () .createValueBinding (expr); *
    * return (String) vb.getValue (CF); *

    *}*

  • call the stored procedure in a column in the report

    Hi all
    I'm new to APEX. I did a search on this forum, but could not get an exact answer.
    I know how to call or execute a procedure from a button. as to create a PL/SQL anonymous bloack and partner is key.

    My question is a little different. I have a report with 11 columns. the last column shows just "delete" for all lines (I did it in my request to report as SELECT x, y, z,..., 'remove' AS delete). When I click on this cell for any line (this column can be a hyperlink or any clickable element), I would like to call a stored procedure that takes parameters as values in columns 2 and 4 for this particular line.

    for example, my report looks like somethnig like below,

    FILE_ID MEMBER_CD ACTION
    112 ABCD Remove
    WXYYZ 113 remove
    114 PQRS remove

    I want to click on the 'delete' in the first line which should call a stored procedure and pass of 112 and ABCD as parameters to the procedure.

    I now have the procedure as a process. sturggling to link this column to procedure but without success :(

    Hope realized. Please, any help is appreciated.

    Thank you

    Hello

    I work in the drudgery of google and firefox if ever the reliased, the thanks of the error to report

    exact code in URL should e

    javascript:document.getElementById('P1_RECORDID').value = '#recordid#';doSubmit('DELETE_RECORD');
    
  • Call the stored procedure to support bean w / table setting dimensional bi

    Hi all, I use jdeveloper 11g

    I have a requirement where instead of calling several times a "insert into" statement rather call a stored procedure, a table shipping two-dimensional bi as a parameter.

    The table must have size [n] [4] and [0] [0] = string and others must have numbers.

    This is because users will be inserting thousands of records at a time, remote sites, so the load of sending of a should be avoided.

    Any suggestions?

    Thank you.

    Miguel,
    If you use ADFbc (VO and EO sense), you can use batch insert for this archive.
    However, he must think about the user interface and how to transfer data from the client to the server taking the place of the insert.

    How you accumulate the data to insert into the DB?
    Are able to collect you say 1000 records a time and transfer them in a single segment on the server?
    How about data validation and exception handling while inserting into the db?

    I'm sure you can use a pl/sql procedure to do the Insert, but the questions above should always be answered.

    Timo

  • call the stored procedure in oracle toplink

    Hello
    I use jdev 10.1.3 toplink.
    call oracle stored procedure always failed ora-00900 invalid sql statement.

    Workaround I found is using below codes:
    String sql = "{RESETCURQTY (?). call} ";
    UOW UnitOfWork is getSessionFactory () .acquireUnitOfWork ();.
    uow.beginEarlyTransaction ();
    Conexion Connection = ((UnitOfWorkImpl) uow) .getAccessor () .getConnection ();
    CallableStatement call = null;
    try {}
    Call = conexion.prepareCall (sql);
    call.setString ("P_BRANCHCODE", branchCode);
    Call.Execute ();
    } catch (SQLException ex) {}
    ex.printStackTrace ();
    } {Finally
    {if(Call!=null)}
    try {}
    Call.Close ();
    }
    catch (SQLException e) {}
    e.printStackTrace ();
    }
    }
    }

    I found a few doc toplink on the use of StoredProcedureCall, none of it to success.
    / * A session = getSessionFactory () .acquireSession ();
    Call of StoredProcedureCall = new StoredProcedureCall();
    call.setProcedureName ("RESETCURQTY");
    call.addNamedArgumentValue ("P_BRANCHCODE", "TEST");
    Query ValueReadQuery = new ValueReadQuery();
    query.setCall (call);
    query.addArgument ("P_BRANCHCODE");

    Vector of parameters = new Vector();
    parameters.addElement (branchCode);
    session.executeQuery (query);

    TopLink support calls a stored procedure?

    Thank you
    Ricky

    Hello

    Looks like the database is to launch an exception because you run the query as a read request instead of as a non-selection call. Try to use a DataModifyQuery instead, or you can run the StoredProcedureCall directly using session.executeNonSelectingCall (call);

    Best regards
    Chris

  • Call the stored procedure to odi

    Hi all

    Posible calls a pl/sql stored procedure of odi?

    In ODI, create a procedure in your project, here, you can call a stored procedure name.

    This can then be slid into a package as a package step.

    geeo

  • two related issues: to call the stored procedure and passing in an array of elements using htmldb_Get

    I need to save items of ApEx generated dynamically via AJAX.  I use the APEX_ITEM API to generate the elements.  At runtime, I have no idea how much of elements are generated on the page, but I know that they're all separate and discreet 'name' attributes, i.e. f01, f02, f03, etc..  As a basic example, if I have to generate a selection list, I know that the parameter "p_idx" of the APEX_ITEM call is to say '3', so select all lists that get generated have a "name" attribute in "f03" DOM, all text elements will be "f01", etc.

    I want to record these data in the database using AJAX.  It is common to call the javascript htmldb_Get function that is standard for the use of an application process, but I am interested in the use of the rarely called upon 'internal' and queryString"options of this javascript function so that I can build the query string to the fly according to what is on the DOM when it tries to save the data they have entered into these items generated by APEX_ITEM.  Someone at - there are good examples of the use of the 'procedure' and 'queryString' the javascript htmldb_Get function parameters?

    I have found a handful of some blogs, messages, etc. online linked to this, but just for most people regurgitate the documentation.  I found this post (https://forums.oracle.com/thread/2549237), which has had a glimpse of hope to move from a table (which is something I need) as a parameter, but as someone in their right mind would check this before you go this route.

    Shane.

    ApEx 4.2.1

    Shane

    Since you mention that you are on 4.2 APEX I advise to use apex.server.process which is replacing the htmldb_Get officially undocumented documented.

    In the literature, it is that the first parameter is the ajaxidentifier but it's actually the name of the process.

    The data object would be something like

    var lData ={f01 : get_value_array('f01')}
    

    Where is get_value_array

    function get_value_array(pColumnName) {
      var l_values =[];
      apex.jQuery('[name="'+pColumnName+'"]').each(
       function(){
        var l_value;
        l_value = apex.item(this.id).getValue();
        l_values.push(l_value);
       }
      );
      return l_values
    }
    

    For an example see this demo.

    Nicolette

  • How to call the stored procedure when I press the button

    Hello

    I want to know how to call the procedure/SQL statement when I press the button using callable statement.

    can someone give me it please link who knows the steps to do this.

    Thanks in advance,
    SAN

    Hello

    read this good example http://www.baigzeeshan.com/2010/05/calling-plsql-procedure-and-function-in.html

    ~ Abhijit

  • How to get the return value of the method by calling the stored procedure in ApplModuleImpl

    Hello

    I use Jdev 10.1.3.4
    JSF, and ADF business components
    I created a service method in the implementing class of module request to execute the strored procedure in the database.
    This breeding returns a string value.
    now, I slipped the method of service of data control palette on my JSF page and chose ADF parameter form when I droped.
    It works very well.
    now, I want to display the string returned by the method of service after the execution on the JSF page as global messages.
    How can I achieve this.
    Help, please

    Thanks in advance

    Kind regards
    Ajit Agarwal

    Hello

    You must run programmatically run the method binding. If I'm not wrong then the following code will allow you to access the return value

    OperationBinding oper = bindings.get("MyPLSQLAccessMethodBinding") (OperationBinding);
    String returnValue = oper.execute ((String));

    Once you have the string in a managed bean you can add it to the stack of messages JSF exposed by the FacesContext

    Frank

  • [BC] Call a stored procedure taking parameters of table

    Hello!

    I currently have a request of the OIC that makes thousands of calls per second stored procedure. The stored procedure runs a business logic that I want my client application to stay informed.  I want to reduce the cat of the database and instead to call the stored procedure from thousands of times per second, call the procedure (for example) once per second, but with values of one mile.

    I used OCIBindArrayOfStruct successfully to perform inserts bulk, where my OCI application executes a () INSERT INTO using the function "iters" and it might be possible to do something similar with the stored procedure, but I want to do something slightly different, because the procedure stored something like this:

    * If a specific condition is set, call a secondary stored procedure

    * If another special condition is set, insert a row into a table of some

    I so wanted to do was to pass a table (or a series of tables) in the stored procedure, then the stored procedure to use optimal methods that are available, such as FORALL, to perform each of the tasks, the more effectively.

    So I thought to create a type, such as a TABLE OF VARCHAR2, or a VARRAY and possessing of the parameters for the stored procedure based on this type, something like:

    create or replace TYPE 'NTT_VARCHAR2' AS TABLE OF VARCHAR2 (32700);

    create or replace FUNCTION bulk_process_values)

    p_error_message OUT NOCOPY VARCHAR2,

    p_module_context_name OUT NOCOPY VARCHAR2,

    p_sql_error OUT NOCOPY VARCHAR2,

    p_count in NUMBERS

    p_non_array_var_1 IN VARCHAR2,

    p_non_array_var_2 IN VARCHAR2,

    p_array_var_1 IN NTT_VARCHAR2,

    p_array_var_2 IN NTT_VARCHAR2,

    p_array_var_3 IN NTT_VARCHAR2

    < etc. for all the variables in table >)

    RETURN NUMBER

    .. .but I am struggling to find an example of how call the procedure "bulk_process_values" stored, and even if I use a TABLE OF VARCHAR2 or a VARRAY as a parameter type.

    I searched the Internet and found this: OIC - how to bind an array to a stored procedure? - and binding table of the structs (OCIBindArrayOfStruct) sample code

    - but they take different approaches and a bit confused (the second example spoke of OTT).

    I think that the first approach is more likely to be the solution I need - but I can't help thinking - it is a bunch of stuff to move if it does not end up significantly improve performance!

    My questions are:

    * Moves to a call-SP-thousands-of-times-per-second to call-SP-fewer-times-but-with-array-parameters sensitive?

    * Should the table or VARRAY, TABLE OF VARCHAR2 parameters or something else?

    * Should I use for my case OTT?

    Samples I found are both very old - and the second example indicators that the optimal approach evolves with the OCI versions - I'm on 11.2, what is the optimal approach these days?

    * < added later > why is there no official useful example?

    Thank you very much

    Much appreciated. https://community.oracle.com/message/4528528#4528528 has actually worked, with VARRAY, with a proof of concept. Now I just need to shake a little and then get my PL/SQL for optimal PC experts. I think I was really discouraged by the lack of official documents, with the Community (Paradise) is the only way to get real results.

    Thank you JJ.

    I intend me to use the binding enforcement of the table and the table and avoid N back and forth, but I do not then get the opportunity to do something clever in the PL/SQL.

    In the PL/SQL, there is no logic occurring - I don't call the same SP tons of times, but then I want to be able to use PL/SQL optimizations such as FORALL, BULK COLLECT, reduce the number of validations and others.  There is a commit after each SP run, because otherwise the nature of demand means that the application hangs occur; However, there is a way (I think) be smart on the part that is likely to deadlock (making a shape on the Bay First, then applying the updates in the order sorted and then failed to get a blocking theoretically), and then FORALL insert for the second part of the stored procedure.

    I guess I may apply the single return, passing a table (to a commit in the SP)-which will reduce back and forth, so gain in performance, but it will not reduce the number of validations that I do - and Oracle said that commits too frequent is not good for performance. I already have code in my framework that does - by making a simple INSERT INTO.

    Good to hear that OTT is not explicitly required - and VARRAY resembles the approach to try first.

  • How to call a stored procedure stored procedure

    Hello Experts,

    I need help, even if stored procedures. I tried to know without a bit of luck. Is it possible to call the stored procedure to another stored procedure? The problem is my boss want me to work on a stored procedure, but I do not have the appropriate privileges. He won't give me permissions either. He suggested that to a stored procedure and call this stored procedure after creating a new procedure. Is this possible? If Yes, how can I do it?

    I thank in advance

    ascheffer wrote:
    Without the "privileges", whatever it is, your features in other nesting procedures won't help.

    Anton

    Unless...

    It goes to an anonymous PL/SQL block to allow him to test its procedures. ;)

    SQL> ed
    Wrote file afiedt.buf
    
      1  declare
      2    procedure test_proc(p_var IN VARCHAR2) is
      3    begin
      4      dbms_output.put_line(p_var);
      5    end;
      6  begin
      7    test_proc('This is a test proc');
      8* end;
    SQL> /
    This is a test proc
    
    PL/SQL procedure successfully completed.
    
    SQL>
    
  • Internal error: catalog view incompatible when calling a stored procedure

    Hello

    I use JDeveloper 11.1.1.4

    When you call a stored procedure from AppModuleImpl, I get this error internal error: inconsistent display catalog

    I'll call the stored procedure of this way

    String lErrCode;

    String lErrMsg;

    Result of an integer;

    ARRAY inputArray = null;

    Table STRUCT that can be passed to a PLSQL PROCEDURE

    inputArray =

    JdbcSqlMapper.preparePlSqlArrayUsingVOAttrbs (conn, recordType,

    view, rm);

    OracleCallableStatement st =

    (OracleCallableStatement) conn.prepareCall ("{?}") = call ("+

    procedureName +.

    "(?,?,?))}");

    st.registerOutParameter (1, Types.INTEGER);

    st.setObject (2, inputArray, OracleTypes.ARRAY);

    st.registerOutParameter (2, OracleTypes.ARRAY,

    recordType.getTableType ());

    st.registerOutParameter (3, Types.VARCHAR);

    st.registerOutParameter (4, Types.VARCHAR);

    St.Execute ();

    I checked the subsidies for this package to all users. All users with grants to this package.

    I don't know where I start to debug this issue.

    Kindly help.

    Thank you and best regards,

    John.

    Have yo uchecked the right of the types of data used (at least the TABLE) to the user (referred to Pokusak blog: JPublisher - incompatible catalog display)?

    Timo

Maybe you are looking for

  • Transfer of large files

    I have a few movie files that are more than 4 GB. When I try moving them to my external hard drive a window appears and says that the file is too large to move. The hard drive is formatted in fat32. Is it possible to transfer these files without refo

  • What is the best windows running on my laptop?

    My laptop is a HP G60 Notebook PC. Intel (r) Pentium (R) Dual cpu 3200 @ 2.00ghz (2 CPUs), ~2.0ghz 3002 MB OF RAM Mobile Intel 4 series express chipset family. I'm probally never the less irritable person, I can find my way around a computer without

  • Reference Dell i7 3537

    Mr President, I use dell machines for the past ten years and always prefer to buy Dell Laptop/Desktop for my offices that are composed of 12 places in the city of Karachi, as I'm running an Exchange co., and almost all my branches most of Dell comput

  • Photosmart 2610xi: cannot create key during installation

    I tried to install my photosmart 2610 xi on my windows 7 64 bit desktop, but a fatal error occurred during installation Could not create key: \Software\Microsoft\Internet Explorer\Explorer {555D4D79-4BD2-4094-A395-CFC534424A05} Bars\. Make sure you h

  • BlackBerry Curve 8330 Blackberry Smartphones and act! 6.0........

    Hello everyone, I was wondering if any of you saw it or not act! 6.0 is to synchronize with the curve. I already had the Palm Treo 700 p, which is a piece of garbage and got lucky that it worked at all. My company is upgrading to Blackberry and Palm