Calling SQL Stored procedure from PLSQL function

Hi,
I have created a simple function to return a value that is pulled back from SQL server.
FUNCTION
FUNCTION CALC_PASS_FAIL
i_lidded_sn IN TMP_CHIP_ATTR.LIDDED_SN%TYPE
RETURN NUMBER
IS
tmp_result NUMBER;
BEGIN
[email protected](i_lidded_sn,'OadmBarActive',tmp_result);
RETURN tmp_result;
END CALC_PASS_FAIL;
OUTPUT
--When executed as a procedure, i get the required output:
DECLARE
x INT;
BEGIN
x:=EQDAS_MISC.CALC_PASS_FAIL('OADM004548');
dbms_output.put_line(x);
END;
0 <------ expected output
PL/SQL procedure successfully completed.
When executed as a simple function call, i don't get any output:
SELECT CALC_PASS_FAIL ('OADM004505') FROM dual;
Any input will be greately appretiated.
Thanks,
Shashi
PS: I am using the DB Link setup usign DG4MSQL

just wondering it works as procedure as the function misses double quotes:
dbo.GetChipPareto
should be
"dbo"."GetChipPareto"
Message was edited by:
kgronau
Tested a small example using a function like:
create or replace function test(
v_ut1 in varchar2)
RETURN varchar2
IS
v_ut2 varchar2(255);
BEGIN
"dbo".OTG_TEST3@dg4msql( v_ut1, v_ut2);
RETURN v_ut2;
END test;
The function calls a SQL Server procedure OTG_TEST3 just returning the passed string and it guarantees data integrity.
Result using a stored procedure:
SQL> DECLARE
2 ret integer;
3 v_ut1 varchar2(255);
4 v_ut2 varchar2(255);
5 BEGIN
6 v_ut1 :='Hello World';
7 v_ut2 :='';
8 "dbo".OTG_TEST3@dg4msql( v_ut1, v_ut2);
9 dbms_output.put_line('Input value: ' ||v_ut1||' - Output value: '
||v_ut2);
10 END;
11
12 /
Input value: Hello World - Output value: Hello World
And calling now the function:
select test('Hello') from dual;
returns Hello

Similar Messages

  • Call a pl/sql stored procedure from a report link

    Hello everyone:
    I have a report with a link in a column, which takes you to another page and passes values to that page, but also need the link, run a stored procedure before going to the other page.
    In the Forum I found cases similar to this, but none of the examples is clear to me how I do this. It seems that the target of the link should be URL, and also I have to call the stored procedure with a javascript function.
    My questions are:
    - Is this the best method to make what I need?
    - How should be the syntax of the link that takes me to another page and run the "stored procedure"
    - How and where I put the function "javascript" to run the "stored procedure"
    BDD: Oracle 11 g
    Apex version 4.1
    Best regards
    Gerard

    Hi,
    Change the link to call an apex.submit process. (javascript).
    Edit:
    I've set up a basic example.
    Region 1 (just so you can see the value getting set):
    select :P27_HIDDEN item_Value
    from dual
    Region 2:
    select rownum id, dbms_random.string('U', 12) sss
    from dual
    connect by level <= 20
    item attributes for ID:
    Target: URL
    URL: javascript:apex.submit({request:'NAVIGATE', set:{'P27_HIDDEN':#ID#}});
    (P27_HIDDEN is just a hidden item i created)
    http://apex.oracle.com/pls/apex/f?p=54920:27
    Edit2:
    In your case, then you can just have a page process based on conditions request = expression1, expression1: NAVIGATE..... then a page branch to go to the desired page, also with the same conditions
    Edit3:
    Im not sure what examples you are referring to , as you didn't supply any links; but you mention calling the stored procedure from javascript, so would likely involve some AJAX, but imo not necessary.

  • Calling PL/SQL stored procedure from JSP tag

    Hello,
    I need to call a PL/SQL procedure from a JSP tag , I donot want to use any Bean to call the PL/SQL procedure. How would I call PL/SQL stored procedure from within JSP using JSP tag library, need some code.
    Thank you
    Syed

    need to call a PL/SQL procedure from a JSP tag , I donot want to use any Bean to call the PL/SQL procedure. How would I call PL/SQL stored procedure from within JSP using JSP tag library, need some code.
    regards
    Indira Rani Bandi

  • Calling pl/sql stored procedure from shell script ( kshell)

    hello.,
    i have written a stored procedure. i need to call this stored procedure from a unix shell script ( korn shell).
    can anyone please help me how can i do it.actually there are 3 stored procedures. so my shell script has to call each stored procedure, execute it then go to next stored procedure execute it.
    if by chance inbetween any stored procedure do not execute then the shell script has to tell me that this stored procedure failed to execute.
    please help me in this.
    thanks
    madan

    Sorry Madan,
    Following is the complete solutiion:
    !# /usr/bin/ksh
    sqlplus -s user/pass@server << EOF > a.log
    exec proc1;
    exec proc2;
    exec proc3;EOF
    if [ $? -eq 0 ]
    then
            echo "\n Procedures completed successfully at `date`"
    else
            echo "!!! FAILED!!!"
            echo "Details can be found in a.log File"
    fi

  • Calling a stored procedure from within a ViewObject

    Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
    select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
    If not, is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
    In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
    We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.

    Is it possible to make stored procedure call from within a BC4J ViewObject? Basically something like this:
    select * from table(f1(3)); where f1 is a table function. Using Oracle's pipelined table functions?
    Yes. Using our expert-mode query feature this is possible.
    is it possible to call a stored procedure from Java and have the returned results be put back into a BC4J RowSet.
    Yes. See this article about basing a view object on a REF CURSOR:
    http://radio.weblogs.com/0118231/2003/03/03.html
    In addition, is there a way to create a JDBC Resultset from a BC4J RowSet?
    No. Not directly. What's the business requirement here so I can understand better?
    We need to be able to dynamically create our SQL statements (the entire SQL, not just the where clause) but are required to have these sql statements generated/executed from within a pl/sql stored procedure in the database.
    REF CURSOR would work fine, or if it's just the statement that needs to be generated dynamically, you could fetch the text of the SQL statement from the stored procedure, then use createViewObjectFromQueryStmt(). Although this has runtime overhead involved with describing the query.
    The REF CURSOR based approach is probably best for this.

  • Calling packaged stored procedure from Java

    Hi All,
    I'm trying to call a stored procedure from Java but I'm having
    problems with registrating the output parameter. I'm getting
    the error: Conflicting parameters.: sqltype=2003
    This is the stored procedure which is located in a package in
    the Oracle database:
    package Pack_GetAgencyInformation as
    Type InfoType is record ( agen_code varchar(3), agen_designation
    varchar(30), agen_adresse varchar(60), agen_tel varchar(12) );
    function GetAgencyInformation( P_AGENCE VARCHAR )
    return Pack_GetAgencyInformation.InfoType
    end Pack_GetAgencyInformation;
    This is the Java source from where I'm calling the procedure:
    //DriverManager.registerDriver (new
    oracle.jdbc.driver.OracleDriver());
         Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection conn = DriverManager.getConnection
    ("jdbc:oracle:thin:@164.48.69.125:1521:ventes", "system", "*****
    // @machineName:port:SID,
    userid, password
    CallableStatement cs = conn.prepareCall("{ ? = call
    Pack_GetAgencyInformation.GetAgencyInformation( ? )}");
         try {
              cs.registerOutParameter( 1,
    oracle.jdbc.driver.OracleTypes.ARRAY);
         } catch (SQLException e) {
              e.printStackTrace();
         cs.setString(2, "001" );
         //ResultSet rset = cs.executeQuery();
    The stacktrace:
    java.sql.SQLException: Parametertypen conflicteren.:
    sqlType=2003
    at oracle.jdbc.dbaccess.DBError.throwSqlException
    (DBError.java:168)
    at oracle.jdbc.dbaccess.DBError.throwSqlException
    (DBError.java:210)
    at
    oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
    (OracleCallableStatement.java:220)
    at
    oracle.jdbc.driver.OracleCallableStatement.registerOutParameter
    (OracleCallableStatement.java:350)
    at dbAccess.main(dbAccess.java:25)
    I think it has to do with the type InfoType which is created in
    the Stored Procedure. I'm absolute no Oracle expert and I
    prefer not to make changes to the Oracle database. So any
    solution in Java is welcome!
    BR, H.Rietman

    I managed to get it to work only by changing the stored
    procedure. I have changed the return type record to a Ref
    Cursor type (had to change alot of code for this). It seams
    that Oracle JDBC drivers DON'T support the Record type as a
    return type.
    So the next question is: is it possible to typecast a record
    type to a ref cursor type in Oracle. In this way I can easily
    change the return type for the stored procedures.
    /Harald

  • How to send a Varying Array param to a PL/SQL Stored Procedure from Java

    * I am VERY new to jdbc, and even somewhat new to Java
    * I'm using Java 1.5, Oracle 10g.
    * I need to call the following PL/SQL Stored Procedure from Java:
    procedure setEventStatus
    i_deQueueStatus in deQueueStatus_type
    *deQueueStatus_type is the following (an array of deQueueStatus_OBJ):
    CREATE OR REPLACE TYPE deQueueStatus_OBJ as object
    eventID number (20),
    dequeuestatus varchar2(20)
    CREATE OR REPLACE TYPE deQueueStatus_TYPE IS VARYING ARRAY(500) of deQueueStatus_obj
    *I have created a Java object as follows:
    public class EventQueueDeQueueStatus
         long      eventID;
         String      dequeueStatus;
         EventQueueDeQueueStatus(long eventID, String dequeueStatus)
              this.eventID = eventID;
              this.dequeueStatus = dequeueStatus;
    I have an ArrayList of these.
    I need to pass this list to the Stored Procedure. How do I create a java.sql.Array so I can call CallableStatement.setArray to set the parameter? Or do I use something else? I have tried setObject with both the ArrayList and also with a primitive array, but got "Invalid Column Type" both times.
    Any help would be greatly appreciated. I just got this task today, and I have to make it work by Tuesday :-( !
    Thanks,
    Kathy

    Kathy,
    Search the archives of this forum and the JDBC forum for the terms STRUCT and ARRAY and you can find some sample code on the JDBC How-To Documents page and the JDBC Samples which can both be accessed from this page:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/index.html
    Good Luck,
    Avi.

  • Calling a stored procedure from a url

    I am needing to call a stored procedure from a url string (or
    anchor) understand that from training to be as follows:
    http://host:port/pls/dad/package.procedure?query_string
    With that in mind, I am getting an error as follows:
    Not Found
    The requested URL /pls/portal30/at_hrfm.checkshow.showcheck was
    not found on this server.
    Here is a sample of my url
    http://servername:port/pls/portal30/at_hrfm.checkshow.showcheck
    I can see servername:port/pls/portal30, it is just the
    procedure I am having a problem with.
    Here is a sample of my source code that is created under the
    at_hrfm schema (I also tried under portal30 schema).
    package body checkshow as
    procedure showcheck as
    begin
    htp.htmlOpen;
    htp.headOpen;
    htp.title('My Check');
    htp.comment ('This should be your Check');
    htp.bodyOpen;
    htp.header (1,'Check');
    htp.print ('checkdate');
    htp.bodyClose;
    htp.headClose;
    htp.htmlClose;
    end;
    end;

    I think I figured this out. I don't think the grant to ANONYMOUS is going to work with production XE and the online documentation is in need of an update. It appears that production XE has been locked down and you will need to specify the name of each stored procedure you wish to allow to be executed by adding it to the WWV_FLOW_EPG_INCLUDE_MOD_LOCAL function. This is spelled out in more technical detail here: http://download.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25309/adm_wrkspc.htm#BEJCGJFJ
    Another alternative that would work involves creating a separate DAD. Using the DAD approach with my schema made all of my stored procedures callable from a web browser, so I rejected this approach. To make this usable (secure) I would have needed to create and maintain a separate database user for the DAD and then only granted it execute for the stored procedures I wanted to be callable from a URL.
    Finally I read about using an on-demand procedure and having it invoke the desired stored procedure. While I didn't try this out, it sounds like another good approach because it maintains session security. If it can be used to return an image I do not know.
    - Jim

  • Calling Oracle Stored Procedure from BC4J JSP App

    I am on an extremely tight deadline and am trying to get my JSP application to use an Oracle Stored Procedure. I need to take some input from the user and send these values as parameters. Has anyone worked with Stored Procedures in JDev3.1? Please reply with some sample code if possible.
    Thanks.

    Hi,
    Someone posted a similar request the other day. Here is my response to them:
    Basically, you need to create a custom method from your JSP's ViewObject, which calls the stored procedure. You can then call the ViewObject's custom method from the JSP client.
    Here is how I have done it:
    1. Choose the ViewObject that your JSP is based on and choose 'Edit' from the context menu.
    2. On the Java tab of the ViewObject wizard, choose Generate Java File checkbox for the View Object Class and click the Finish button. A file is created under the ViewObject node in the Navigator named 'viewobjectImpl.java'.
    3. Open the viewobjectImpl.java file in the code editor and create a method to call your stored procedure (see sample code below).
    4. Compile the VOImpl.java file.
    5. Choose the view object again, and choose Edit again from the context menu.
    6. On the Client Methods tab, you should now see your method appear in the Available field. Select it and shuttle it to the Selected field.
    7. Click Finish to leave the VO wizard, and rebuild your Business Components project.
    8. In your JSP, call the custom method (see sample code below).
    sample code for custom method calling a stored procedure from VOImpl.java file:
    public int getTotalHits(String mon, String year) {
    CallableStatement stmt = null;
    int total;
    // the call to the PL/SQL stored proc
    String totalhits = "{? = call walkthru.total_hits(?,?)}";
    // use the AM conxn 2 call storedproc
    stmt = getDBTransaction().createCallableStatement(totalhits, 1);
    try
    // Bind the Statement Parameters and //Execute this Statement
    stmt.registerOutParameter(1,Types.INTEGER);
    stmt.setString(2,mon); stmt.setString(3,year);
    stmt.execute();
    total = stmt.getInt(1);
    catch (Exception ex)
    throw new oracle.jbo.JboException(ex);
    finally
    try
    stmt.close();
    catch (Exception nex)
    return total;
    sample render code for calling custom method from JSP custom bean:
    public void render() {
    int totalhits;
    try
    Row[] rows;
    // Retrieve all records by default, the qView variable is defined in the base class
    qView.setRangeSize(-1);
    qView.first();
    rows = qView.getAllRowsInRange();
    // instantiate a view object for our exported method
    // and call the stored procedure to get the total
    ViewObject vo = qView.getViewObject();
    wtQueryView theView = (wtQueryView) vo;
    totalhits = theView.getTotalHits(session.getValue("m").toString(),session.getValue("y").toString());
    out.println(totalhits);
    } catch(Exception ex)
    throw new RuntimeException(ex.getMessage());
    }

  • Calling invalid stored procedure from java

    Will the stored procedure which is invalid get re-compiled automatically when called from a java program?
    1.a stored procedure is invalid (oracle 9i)
    2.calling the stored procedure from a java program
    3.what will happen a.oracle recompiles the stored procedure
    b.returns an sql exception
    what happens,kindly help
    drop your mail to [email protected]
    Keep Smiling and Mailing,
    Vijay Anand Natesan.

    thank you ..Kindly let me know if any of your friends have tried this

  • How to call a stored procedure from WorkShop

    Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
    me .. Today I'm simply trying to find out how to call a stored procedure from
    within workshop, using any of the DB Controls .. I see workshop provides a way
    create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
    to be entered in place of the inline query .. Perhaps I've over looked it. Any
    advise on the best way to tackle this task will be appreciated.
    Atahualpa

    Atahualpa--
    Maybe this will help:
    http://edocs.bea.com/workshop/docs81/doc/en/workshop/guide/controls/database/conStoredProcedures.html
    Eddie
    Atahualpa wrote:
    Hello Everyone .. I'm quite new with WebLogic 8.1 & WorkShop, so please bare with
    me .. Today I'm simply trying to find out how to call a stored procedure from
    within workshop, using any of the DB Controls .. I see workshop provides a way
    create a Java Control, Rowset Control, but it wont easily allow for a stored procedured
    to be entered in place of the inline query .. Perhaps I've over looked it. Any
    advise on the best way to tackle this task will be appreciated.
    Atahualpa

  • Calling Oracle Stored Procedure from Weblogic.

    Hi All,
    I am using Oracle 11g R2 and weblogic 10.3.5.0
    Do you know if it is possible to call a stored procedure from Weblogic.
    Basically, what I would like to do is to call the following procedure : EXEC DBMS_SESSION.SET_IDENTIFIER('provider_a') when my application connects to my database, "provider_a" being the user used to connect to the oracle schema.
    Thanks.

    Up !
    Thanks.

  • Can i call a stored procedure from OracleDashboardPrompt?

    Hi,
    Can i call a stored procedure from OracleDashboardPrompt once i click the Go button in OBIEE?The input parameters to the procedure are the one that i have given in DashboardPrompt.and based on the result of the procedure(either 0 or 1),i have to display reports.Can anyone help me.
    Thanks in Advance...

    Please find below the possible approach to the scenario:
    1.Create a prompt for the column which you need as input to store proc and create a presentation variable for that .
    2.Create a dummy report with 1 column which will have the above created presentation variable as filter(We can design this reports in such a way like the first column will get filtered based on the presentation variable)
    3.Create a second column and in the column definition we can add a code like
    evaluate('StoreProc(%1)','@{firstcolumn}')
    4.We can hide the first column in the report and only show the output of store proc to the end user
    Hope this helps :)

  • Can we call a stored procedure from a Trigger

    Hello Everyone,
    I need some help in writing the triggers in Oracle 10g Database.
    Can we call a stored procedure from a trigger?

    Can we call a stored procedure from a trigger? Yes. Why did you think we couldn't?
    Cheers, APC

  • Error when calling a stored procedure from a SQL Script

    Apologies if this is a really dumb question but I can't seem to call a procedure in package from a SQL script. I have a simple package.procedure containing a loop to populate a table. I would like to include a call to this procedure from my database install script, that also includes my CREATE and INSERT statements. I run the script using "@install_databae" and the CREATE and INSERT statements run fine. The script gives an error when it reaches the line below:
    exec lazarus.PopulateGridPositions;
    and gives the error.....
    BEGIN lazarus.PopulateGridPositions; END;
    ERROR at line 1:
    ORA-04063: package body "LAZARUS.LAZARUS" has errors
    ORA-06508: PL/SQL: could not find program unit being called: "LAZARUS.LAZARUS"
    ORA-06512: at line 1
    The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.
    I've obviously missed some fundamental concept with scripts and SQL. Please can anybody help me?

    Histon FTM wrote:
    ORA-04063: package body "LAZARUS.LAZARUS" has errors Above, obviously conflicts with the statement that follows:
    >
    The procedure and package have both compiled without errors and the statement on its own works fine in SQL*Plus.I suggest you take a look in the USER_ERRORS view to see, what the errors are.
    And just checking:
    You have schema called LAZARUS, which holds a package named LAZARUS, which holds a procedure called POPULATEGRIDPOSITIONS?
    Edited by: Toon Koppelaars on Oct 1, 2009 5:55 PM

Maybe you are looking for