Calling the Java Method in PL/SQL Java Stored procedure errors out

Hi,
I could not find a suitable thread to post my PL/SQL question so iam posting it here.........
I have written a java class by name XYZ which has a method ABC for which there are 9 arguements being passed and its a VOID method.
This java class has been loaded into ORACLE using DBMS_JAVA.LOADJAVA pkg, Now this class is being called in the oracle as a JAVA Stored procedure...... When ever im trying to call the procedure it throws the following error
ORA-29531: no method
*Cause:    An attempt was made to execute a non-existent method in a
Java class.
*Action:   Adjust the call or create the specified method.
The code snippet as follows
JAVA CODE:
Class xyz
public static void Abc (String hostName,
int port,
String serviceURL,
String soapAction,
int timeOut,
String wsUser,
String wsPasWd,
String keyStore,
String keyStorePasWd)
//method implementation
JAVA STORED PROCEDURE:
create OR REPLACE procedure ABC_JAVA_SP_CALL
(p_hostname in varchar2, p_port in number, p_serviceurl in varchar2, p_soapaction in varchar2, p_timeout in number, p_wsuser in varchar2, p_wspasswd in varchar2, p_ks_path in varchar2, p_ks_passwd in varchar2)
as
language java
name 'xyz.Abc(java.lang.String, int, java.lang.String, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String, java.lang.String)';
When i try to call
declare
p_hostname varchar2(100);
p_port number;
p_serviceurl varchar2(100);
p_soapaction varchar2(100);
p_timeout number;
p_wsuser varchar2(100);
p_wspasswd varchar2(100);
p_ks_path varchar2(100);
p_ks_passwd varchar2(100);
begin
//SP which returns the values for the required parameters.
comppkg.getvcsinfo(
p_hostname,
p_port ,
p_serviceurl,
p_soapaction,
p_timeout,
p_wsuser,
p_wspasswd,
p_ks_path,
p_ks_passwd
Layer7_icengc_ws_tes(p_hostname,
p_port ,
p_serviceurl,
p_soapaction,
p_timeout,
p_wsuser,
p_wspasswd,
p_ks_path,
p_ks_passwd);
end;
This thing ends up with
29531. 00000 - "no method %s in class %s"
*Cause:    An attempt was made to execute a non-existent method in a
Java class.
*Action:   Adjust the call or create the specified method.
Im not understanding what wrong am i doing
pls help
Edited by: madhusudan on Feb 12, 2013 8:07 PM

Hello,
there is the forum {forum:id=65} for questions about using Java within Oracle.
Regards
Marcus
Edited by: Marwim on 13.02.2013 07:56
I could not find a suitable thread to post my PL/SQL question so iam posting it here.........You got the hint to the correct forum alread in another thread {message:id=10837976}
And if you think this is not related to Java but PL/SQL, then you should ask in {forum:id=75}

Similar Messages

  • Java web service to invoke a stored procedure in the database

    Hi
    Does anybody have a example Java web srevice to invoke a stored procedure in the database
    regards
    Edited by: hrishy on May 20, 2011 12:11 AM

    hrishy wrote:
    Thanks i have modified the title so its easy to comprehendWrite the two parts mentioned above and post if you get problems with your code.
    First write code that calls the stored procedure and test that to make sure that it works.
    Then write a simple webservice and test it out to make sure it works. The integration should be trivial after that.

  • Howto call the @Remove method of a stateful session bean after JSF page ...

    I use EJB3, JPA, JSF in my web application. There are 2 database tables: Teacher and Student. A teacher can have many (or none) students and a student can have at most 1 teacher.
    I have a JSF page to print the teacher info and all his students' info. I don't want to load the students' info eagerly because there's another JSF page I need to display the teacher info only. So I have a stateful session bean to retrieve the teacher info and all his students' info. The persistence context in that stateful session bean has the type of PersistenceContextType.EXTENDED. The reason I choose a stateful session bean and an extended persistence context is that I want to write something like this without facing the lazy initialization exception:
    <h:dataTable value="#{backingBean.teacher.students}" var="student">
        <h:outputText value="${student.name}"/>
    </h:dataTable>Because my session bean is stateful, I have a method with the @Remove annotation. This method is empty because I don't want to persist anything to the database.
    Now, my question is: How can I make the @Remove method of my stateful session bean be called automatically when my JSF page finishes being rendered?

    Philip Petersen wrote:
    I have a few questions concerning the EJB remove method.
    1) What is the purpose of calling the remove method on stateless session
    bean?There isn't one.
    >
    2) What action does the container take when this method is called?It checks that you were allowed to call remove (a security check) and then
    just returns.
    >
    3) What happens to the stateless session bean if you do not call the remove
    method?Nothing
    >
    4) Is it a good practice to call the remove method, or should the remove
    method be avoided in the case of stateless session beans?
    Personally, I never do it.
    -- Rob
    >
    >
    Thanks in advance for any insight that you may provide.
    Phil--
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnWebLogic.com
    [att1.html]

  • Does setSelectionPath() method of JTree calls the treeValueChanged() method

    Hello,
    Just wanted to know whether setSelectionPath() method of JTree calls the treeValueChanged() method after selecting the path?
    Thanks.

    Hi SaucyMexican,
    Thank you for using Apple Support Communities. 
    It looks like PayPal is still an accepted form of payment for the Apple Store:
    Payment methods you can use in the iTunes Store, Mac App Store, App Store, and iBooks Store - Apple Support
    If you are still having difficulties you can take a look at this article for assistance.
    Change or remove your payment information from your iTunes Store account (Apple ID) - Apple Support
    Regards,
    Jeff D. 

  • JSP does not call the right method in controller class

    Hi all,
    I have a jsp file which loads a page at this address: http://localhost:8080/dir/list/
    I've added two checkboxes to the page; user can check both checkboxes, only one or none. Following is code I have in jsp file:
    <form class="checkboxForm">
    <c:choose>                                                                                                         
    <c:when test='${newItems==true}'>
    <input id="newItems" type="checkbox" value="#" name="newItems" class="checkbox2" checked="checked" /><strong> New Businesses   </strong>                                                                 
    </c:when>
    <c:otherwise>
    <input id="newItems" type="checkbox" value="#" name="newItems" class="checkbox2"/><strong> New Businesses   </strong>
    </c:otherwise>
    </c:choose>
    <c:choose>                                                                                                         
    <c:when test='${rejectedItems==true}'>
    <input id="rejectedItems" type="checkbox" value="#" name="rejectedItems" class="checkbox3" checked="checked"/><strong> Rejected Businesses   </strong>                                                                 
    </c:when>
    <c:otherwise>
    <input id="rejectedItems" type="checkbox" value="#" name="rejectedItems" class="checkbox3"/><strong> Rejected Businesses   </strong>
    </c:otherwise>
    </c:choose>
    <a href="#" onclick="apply();">
    <button name="apply" class="btn-primary" value="Apply" tabindex="4">Apply</button>
    </a>
    </form>
    <script type="text/javascript">
    function apply(){
         var newItems = document.getElementById("newItems").checked;
         var rejectedItems = document.getElementById("rejectedItems").checked;
         alert("Inside apply() method.");
         alert("newItems= " + newItems + ", rejectedItems: " + rejectedItems);     
         window.location = "<c:url value='/list/'/>" + newItems + "/" + rejectedItems;
         alert("window.location= " + window.location);
         alert("Add extra delay!");
         return false;
    </script>This is my Controller class:
    // Method1: this method gets called when the user loads the page for the first time.
    @RequestMapping(value="/list", method = RequestMethod.GET)
    public String list(Model model, HttpServletRequest request) {          
              System.out.println("Controller: method1: Passing through...");
              model.addAttribute("newItems", Boolean.TRUE);
              model.addAttribute("rejectedItems", Boolean.TRUE);
              // Does other things.
    // Method3: this method gets called when user checks/unchecks one of the checkboxes and clicks on Apply button.
    @RequestMapping(value="/list/{newItems}/{rejectedItems}", method = RequestMethod.GET)
    public String list(@PathVariable Boolean newItems, @PathVariable Boolean rejectedItems, Model model, HttpServletRequest request) {          
              System.out.println("Controller: method3: Passing through...");
              model.addAttribute("newItems", newItems);
              model.addAttribute("rejectedItems", rejectedItems);
    // Does other things.
         }The way my jsp code is written now, it calls the correct method and displays the correct url. When page loads for the first time, it calls method1 and the url is:
    http://localhost:8080/dir/list
    When the user checks/unchecks one or both checkboxes and clicks on apply button, method3 is called and this url is displayed:
    If both checkboxes are checked which both booleans are set to true:
    http://localhost:8080/dir/list/true/true
    Everything is fine... however, if I comment these two lines at the end of JavaScript apply() function,
    alert("window.location= " + window.location);
    alert("Add extra delay!");Then method3 will never gets called; only method1 gets called and I see this url:
    http://localhost:8080/url/list//?newItems=%23&rejectedItems=%23&apply=Apply
    I do not know why it gets confused bet. method1 and method3 and cannot pick the right method?
    I tried to use the POST method instead, but the page goes directly to our internal error page and it never reaches the method I wrote in my controller for POST:
    I don't really know what I'm doing wrong? Any help is greatly appraciated.
    Edited by: ronitt on Dec 13, 2011 2:35 PM

    I changed the <form> in the jsp to div and its working fine. I do not need to have comments in JavaScript funcion() anymore. I don't know why that made the difference though? According to:
    http://www.w3schools.com/tags/tag_form.asp
    The <form> tag is used to create an HTML form for user input.
    The <form> element can contain one or more of the following form elements:
    <input>
    <textarea>
    <button>
    <select>
    <option>
    <optgroup>
    <fieldset>
    <label>
    An HTML form is used to pass data to a server.
    I do have <button> and also send the data - the value of checkboxes - to server. So I think it should also work with <form>.
    Please let me know if you have any idea. Thanks.

  • How can I call the create method in BO from Application Service

    Hello!
    When I create a Business Object, CAF generates some methods automatically.
    How can I call the create method in the BO from Application Service logic?
    When i call the method then the entityManager and the sessionContext is NULL.
    How can I initialize this?
    Can anybody help me?
    Thanks, Thomas

    If you are using CE 7.11...
    1) In the Application Services, add the BO as dependant object in dependencies tab.
    2) In the implemention, add the following codes to call create method of the BO:
    this.get<BO>.createMethod();
    julius

  • How to call a sql server stored procedure from oracle

    Hi all,
    Please anybody tell me how to call a sql server stored procedure from oracle.
    I've made an hsodbc connection and i can do insert, update, fetch data in sql server from oracle. But calling SP gives error. when I tried an SP at oracle that has line like
    "dbo"."CreateReceipt"@hsa
    where CreateReceipt is the SP of sql server and hsa is the DSN, it gives the error that "dbo"."CreateReceipt" should be declared.
    my database version is 10g
    Please help me how can i call it... I need to pass some parameters too to the SP
    thanking you

    hi,
    thank you for the response.
    when i call the sp using DBMS_HS_PASSTHROUGH, without parameters it works successfully, but with parameters it gives the following error
    ORA-28500: connection from ORACLE to a non-Oracle system returned this message:
    [Generic Connectivity Using ODBC][Microsoft][ODBC SQL Server Driver]Invalid parameter number[Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index (SQL State: S1093; SQL Code: 0)
    my code is,
    declare
    c INTEGER;
    nr INTEGER;
    begin
    c := DBMS_HS_PASSTHROUGH.OPEN_CURSOR@hsa;
    DBMS_HS_PASSTHROUGH.PARSE@hsa(c, 'Create_Receipt(?,?)');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,1,'abc');
    DBMS_HS_PASSTHROUGH.BIND_VARIABLE@hsa(c,2,'xyz');
    nr:=DBMS_HS_PASSTHROUGH.EXECUTE_NON_QUERY@hsa(c);
    DBMS_HS_PASSTHROUGH.CLOSE_CURSOR@hsa(c);
    end;
    Create_Receipt is the sp which requires two parameters.
    please give me a solution
    thanking you
    sreejith

  • Can a SQL Server stored procedure call an SAP function module?

    Can a SQL Server stored procedure call an SAP function module.? The stored procedure will be called via a trigger when data records are added to a Z table.

    You have two options:
    - the other software can use the RFC SDK and call directly in the system
    - the other software can use a database connect
    Markus

  • Call a UNIX shell script from an oracle stored procedure

    We need to call a UNIX shell script from an oracle stored procedure
    i.e. the control should come back to the procedure once the script completes. Can any body help to achieve this ?

    There are various ways in achieving this.
    For Example, you can call a PRO*C-Library residing on the database server.
    This requires a PL/SQL library to be generated and some changes to the Listener configuration.
    It is also possible to implement a java procedure on the database being invoked by a PL/SQL wrapper class.
    In this way (and if used right) there is also granularity regarding the filestructure permissions given and it may be called during a Forms or other PL/SQL session.
    The article below explains a more generic approach how to invoke shell commands from within an Oracle Instance.
    Be careful with this, because it really works ;)
    Refer to :
    http://www.oracle-base.com/articles/8i/ShellCommandsFromPLSQL.php
    Message was edited by:
    user434854

  • Calling Oracle stored procedure with out param of user define type from Entity Framework 5 with code first

    Guys i am using Entity Framework 5 code first (I am not using edmx) with Oracle and all works good, Now i am trying to get data from stored procedure which is under package but stored procedure have out param which is user define type, Now my question is
    how i will call stored procedure from entity framework
    Thanks in advance.

    I agree with you, but issue is we have lots of existing store procedure, which we need to call where damn required. I am sure those will be few but still i need to find out.
    If you think you are going to get existing MS Stored Procedures  or Oracle Packages that had nothing to do with the ORM previously to work that are not geared to do simple CRUD operations with the ORM and the database tables, you have a rude awakening
    coming that's for sure. You had better look into using ADO.NET and Oracle Command objects and call those Oracle Packages by those means and use a datareader.
    You could use the EF backdoor, call Oracle Command object and use the Packages,  if that's even possible, just like you can use MS SQL Server Stored Procedures or in-line T-SQL via the EF backdoor.
    That's about your best shot.
    http://blogs.msdn.com/b/alexj/archive/2009/11/07/tip-41-how-to-execute-t-sql-directly-against-the-database.aspx

  • Please Help!!!!! Problem Migrating from sql 2000 stored procedure to PL/SQL

    I have used a tool to convert my sql 2000 stored procedure to Oracle 10g PL/SQL, here is an example
    SQL 2000 Stored Procedure
    CREATE PROCEDURE [GetEmployees]
    AS
    Select * from EMPMST ORDER BY emp_name
    GO
    After Transformation i got 2 files, one was a procedure and other a package
    CREATE OR REPLACE PACKAGE GLOBALPKG
    AS
         TYPE RCT1 IS REF CURSOR;
         TRANCOUNT INTEGER := 0;
         IDENTITY INTEGER;
    END;
    CREATE OR REPLACE PROCEDURE GetEmployees
         RCT1 IN OUT      GLOBALPKG.RCT1
    AS
    BEGIN
         OPEN RCT1 FOR
         SELECT *
         FROM EMPMST
         ORDER BY emp_name;
    END;
    When i execute the procedure GetEmployees i got this error :
    SQL> execute GetEmployees;
    BEGIN GetEmployees; END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'GETEMPLOYEES'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Please Help me in debugging this error. Thanks in advance.

    As the poster above mentioned you cannot call "GetEmployees" without a parameter.
    Note that the procedure declaration has the following line
    RCT1 IN OUT GLOBALPKG.RCT1
    This means that whenever you want to call the procedure you must pass it a variable of type GLOBALPKG.RCT1
    However unless this is merely a homework or learning exercise (i.e. you are not porting the code of a production application) i would strongly recommend that you do not attempt to simply convert the code to PL/SQL.
    The reasoning behind this is that Oracle's architecture will be completely different to the source of the original code and if you attempt to simply port the code (especially using an automatic tool) you will almost certainly hit problems.
    For example the SQL Server's 2000 code may (should be) be written based on SQL Server's locking strategy. Oracle's locking strategy is completly different if you try to use the same techniques as you do in SQL Server the performance will suffer.
    Porting a code or a database schema from one platform to another involves a lot of analysis in order to take advantage of the features of the destination platform.
    As I said this may not be important to you depending on why you are attempting a port.
    Good Luck.

  • Call a function inside a package from a stored procedure

    Hello:
    I am kind of new to the stored procedure. Does anyone know how to call a function inside a package from another stored procedure?
    I have a existing function (func_b) inside a package (pack_a) and it returns a cursor. I want to call this function from a stored procedure (proc_c) so that I use the data inside the cursor.
    can I do the following in proc_c:
    my_cursor1 SYS_REFCURSOR;
    begin
    my_cursor1 := exec pack_a.func_b
    end
    It will be very helpful if anyone can point me to any reading or example. Thank you very much for your information.

    guys:
    Thank you for your information so far. I need some more help here. I was able to run the function in my stored procedure. However, I was not able to print the result on the screen to view the cursor result, although I am using dbms_output.put_line statement inside my stored procedure.
    I use the following statement to execute my stored procedure on sql*plus. I can tell the stored procedure is executed successfully, but I did see anything printed:
    DECLARE TEMP VARCHAR2(100);
    BEGIN PROC_LAWS_CAD_NAME_SEARCH('LPD', 'TEST DEVICE ID', 'TEST LAST NAME', 'TEST FIRST NAME', 'F', '11112009', TEMP); END;
    I tried to use 'set serveroutput on' and got the following error:
    ERROR:
    ORA-06502: PL/SQL: numeric or value error: host bind array too small
    ORA-06512: at line 1
    I am kind of confused now. thank you for your help.
    Jack
    Here is my procedure:
    create or replace
    PROCEDURE PROC_SEARCH
    ( AGENCY_ID IN VARCHAR2,
    DEVICE_ID IN VARCHAR2,
    L_NAME IN VARCHAR2,
    F_NAME IN VARCHAR2,
    SEX IN VARCHAR2,
    DOB IN VARCHAR2,
    CAD_NAME_SCH_RESULT_STR OUT VARCHAR2)
    AS
    v_agy_id varchar2(10);
    v_device_id varchar2(20);
    v_l_name varchar2(25);
    v_f_name varchar2(15);
    v_sex varchar2(1);
    v_dob date;
    -- this cursor is going to be used to store a list of warrant matching
    -- name search criteria
    cad_srch_cursor sys_refcursor;
    objSrch SEARCH_RESULT_TEMP%ROWTYPE;
    BEGIN
    cad_srch_cursor := SEARCH_PKG.SEARCH('TESTING', 'TESTER', null, null,null, null, getPhonetic('TESTING'));
    LOOP
    FETCH cad_srch_cursor INTO objSrch;
    EXIT WHEN cad_srch_cursor%NOTFOUND;
    --insert into SEARCH_RESULT_TEMP (name_last) values (objSrch.name_last);
    CAD_NAME_SCH_RESULT_STR := objSrch.name_last;
    dbms_output.put_line('First:'||objSrch.name_first||':Last:'||objSrch.name_last||':Middle:'||objSrch.name_middle);
    end LOOP;
    END PROC_LAWS_SEARCH;
    -----------------------------------------

  • Converting SQL Server Stored Procedure to Oracle

    Hi there,
    I tried to use SwisSQL to convert my SQL Server stored procedure to Orcale without much success.
    Is there anyone who could help me out with this?
    My SQL Server Stored Procedure is:
    CREATE PROCEDURE [dbo].[SP_BackgroundCheckRequest]
         --MASTER Table
         @MASTER_ID int,
         @PERSONNEL_ID int = NULL,
    @DATE_OF_BIRTH datetime = NULL,
         @GENDER varchar(1) = NULL,
         @COUNTRY_OF_BIRTH varchar(3) = NULL,
    @TOWN_OF_BIRTH varchar(100) = NULL,
         @STATE_OF_BIRTH varchar(50) = NULL,
         @CHECK_CATEGORY varchar(10) = NULL,
         @CHECK_TYPE varchar(10) = NULL,
         @PRIORITY varchar(10) = NULL,
         @PRIORITY_REASON varchar(100) = NULL,
         @SCREENING_LEVEL nchar(1) = NULL,
         @POSITION nchar(50) = NULL,
         @REQUEST_SOURCE varchar(60) = NULL,
         --NAME_TYPE Table
         @NAME_TYPE varchar(5) = NULL,
         @FAMILY_NAME varchar(50) = NULL,
         @FIRST_NAME varchar(50) = NULL,
         @MIDDLE_NAME varchar(50) = NULL,
         @TITLE varchar(10) = NULL,
         @PREFFERED_NAME varchar(40) = NULL,
         @PREVIOUS_NAME varchar(140) = NULL,
         --ADDRESS_TYPE Table
         @ADDRESS_TYPE varchar(10) = NULL,
         @ADDRESS_LINE_1 varchar(30) = NULL,
         @ADDRESS_LINE_2 varchar(30) = NULL,
         @ADDRESS_LINE_3 varchar(30) = NULL,
         @COUNTRY varchar(3) = NULL,
         @SUBURB varchar(50) = NULL,
         @STATE varchar(50) = NULL,
         @POSTCODE varchar(15) = NULL,
         @START_DATE varchar(10) = NULL,
         @END_DATE varchar(10) = NULL,
         --LICENSE_TYPE Table
         @LICENSE_TYPE varchar(5) = NULL,
         @LICENSE_AGENCY varchar(15) = NULL,
         @LICENSE_NUMBER varchar(100) = NULL,
         @LICENSE_SIGHTED varchar(1) = NULL,
         --PHONE_TYPE Table
         @TELEPHONE_TYPE varchar(5) = NULL,
         @TELEPHONE_NUMBER varchar(20) = NULL,
         @MOBILE_TYPE varchar(5) = NULL,
         @MOBILE_NUMBER varchar(20) = NULL,
         @EXTENSION_TYPE varchar(5) = NULL,
         @EXTENSION_NUMBER varchar(20) = NULL,
         --PASSPORT_TYPE Table
         @PASSPORT_TYPE varchar(5) = NULL,
         @PASSPORT_NUMBER varchar(50) = NULL,
         @PASSPORT_COUNTRY varchar(3) = NULL,
         @PASSPORT_SIGHTED varchar(1) = NULL
    AS
    BEGIN TRANSACTION
    INSERT into MASTER (MASTER_ID, PERSONNEL_ID, DATE_OF_BIRTH, GENDER, COUNTRY_OF_BIRTH,
         TOWN_OF_BIRTH, STATE_OF_BIRTH, CHECK_CATEGORY, CHECK_TYPE, PRIORITY, PRIORITY_REASON,
         SCREENING_LEVEL, POSITION, REQUEST_SOURCE)
         VALUES (@MASTER_ID, @PERSONNEL_ID, @DATE_OF_BIRTH, @GENDER, @COUNTRY_OF_BIRTH,
         @TOWN_OF_BIRTH, @STATE_OF_BIRTH, @CHECK_CATEGORY, @CHECK_TYPE, @PRIORITY, @PRIORITY_REASON,
         @SCREENING_LEVEL, @POSITION, @REQUEST_SOURCE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into MASTER table!', 16, 1)
         RETURN
    END
    INSERT into NAME_TYPE (MASTER_ID,NAME_TYPE,FAMILY_NAME,FIRST_NAME,MIDDLE_NAME,TITLE)
         VALUES (@MASTER_ID,@NAME_TYPE,@FAMILY_NAME,@FIRST_NAME,@MIDDLE_NAME,@TITLE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into NAME_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into ADDRESS_TYPE (MASTER_ID,TYPE,ADDRESS_LINE_1,ADDRESS_LINE_2,ADDRESS_LINE_3,
              COUNTRY,SUBURB,STATE,POSTCODE,START_DATE,END_DATE)
         VALUES (@MASTER_ID,@ADDRESS_TYPE,@ADDRESS_LINE_1,@ADDRESS_LINE_2,@ADDRESS_LINE_3,
              @COUNTRY,@SUBURB,@STATE,@POSTCODE,@START_DATE,@END_DATE)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into ADDRESS_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into LICENSE_TYPE (MASTER_ID,TYPE,AGENCY,NUMBER,SIGHTED_YN)
         VALUES (@MASTER_ID,@LICENSE_TYPE,@LICENSE_AGENCY,@LICENSE_NUMBER,@LICENSE_SIGHTED)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into LICENSE_TYPE table!', 16, 1)
         RETURN
    END
    INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
         VALUES (@MASTER_ID,@TELEPHONE_TYPE,@TELEPHONE_NUMBER)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting Telephone number into PHONE_TYPE table!', 16, 1)
         RETURN
    END
    IF ((@MOBILE_TYPE <> NULL) AND (@MOBILE_NUMBER <> NULL))
    BEGIN
         INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
              VALUES (@MASTER_ID,@MOBILE_TYPE,@MOBILE_NUMBER)
         IF @@ERROR <> 0
         BEGIN
              ROLLBACK
              RAISERROR ('Error inserting Mobile number into PHONE_TYPE table!', 16, 1)
              RETURN
         END
    END
    IF ((@EXTENSION_TYPE <> NULL) AND (@EXTENSION_NUMBER <> NULL))
    BEGIN
         INSERT into PHONE_TYPE (MASTER_ID,TYPE,NUMBER)
              VALUES (@MASTER_ID,@EXTENSION_TYPE,@EXTENSION_NUMBER)
         IF @@ERROR <> 0
         BEGIN
              ROLLBACK
              RAISERROR ('Error inserting Extension number into PHONE_TYPE table!', 16, 1)
              RETURN
         END
    END
    INSERT into PASSPORT_TYPE (MASTER_ID,NUMBER,COUNTRY,SIGHTED_YN)
         VALUES (@MASTER_ID,@PASSPORT_NUMBER,@PASSPORT_COUNTRY,@PASSPORT_SIGHTED)
    IF @@ERROR <> 0
    BEGIN
         ROLLBACK
         RAISERROR ('Error inserting values into PASSPORT_TYPE table!', 16, 1)
         RETURN
    END
    COMMIT

    First, a basic concept. That also illustrates how different Oracle is (and PL/SQL) from SQL-Server (and T-SQL).
    PL/SQL integrates two different languages. The PL language. The SQL language. It allows you to code SQL source code natively inside the PL language. The PL compiler is clever enough to do the rest - make calls to the SQL engine to create SQL cursors, bind PL variable values to bind variables in the SQL code. Etc.
    PL is a "proper" programming language. It is much like Pascal (it is based on Ada, a close family member of Pascal). It is nothing at all like T-SQL.
    Okay, now for the very basic rule for Oracle development.
    Maximize SQL. This means using the SQL language to crunch data. It is the "closest" to the data. It is designed and optimised for dealing with data. Do your data processing using SQL.
    Minimize PL/SQL. This means using the PL language not to crunch data, but to provide the conditional logic. Implement business rules. And then have the SQL language crunch the data as the data processing language.
    Attempting to directly translate T-SQL code into PL/SQL is flawed. It is like trying to make coffee with teabags. Yeah, the tea may have caffeine it, but it is not coffee.
    To do what that T-SQL script does, insert a row into a table, a typical PL/SQL equivalent will look as follows:
    create or replace procedure InsertMaster( masterRow master%rowtype ) authid definer is
    .. types and variables declared here
    begin
      -- masterRow is a record structure that matches the actual MASTER table
      .. apply business rules and validation to the data.. raising user exceptions as needed
      -- e.g. the POSITION column must be upper case
      masterRow.position := upper(masterRow.position);
      -- after the business logic and data validation we can add the row to the table
      -- (PL will make the INSERT call to the SQL engine)
      insert into master values masterRow;
    end;No commit. The caller does the business transaction. It needs to decide when to commit to maintain the integrity of the data in the database. It may need to do several more calls, before committing.
    With this approach, we can give the application schema (the caller) execute privs on this procedure. This procedure is defined with definer rights. This means it runs with the privs of owner of that procedure and MASTER table. It is trusted code. It does all the correct stuff to add a valid and checked row to the MASTER table. So we give the app schema execute privs on the procedure and no insert priv on the MASTER table.
    The only way the caller can add row to the MASTER table is via this trusted procedure of ours.
    And this is a typical approach in Oracle - using the PL/SQL (both PL language and SQL language) code to create an interface to a logical database in Oracle. Abstracting the complexities of SQL from the caller. Moving business and validation into PL. Allowing us the flexibility of modifying business and validation logic, without touching a single byte of caller/client code. Allowing us to manage and tune SQL performance without dealing with (badly designed and coded) SQL from a client - as the SQL resides in PL/SQL packages and procedures and functions.

  • How to find the columns and tables used in a stored procedure?

    Hi,
    Can someone suggest how to find the columns and tables used within a stored procedure?
    Thanks
    VBK

    For example:
    SQL> create or replace
      2    procedure p1
      3      is
      4          cnt number;
      5      begin
      6          select count(*) into cnt from emp;
      7  end;
      8  /
    Procedure created.
    SQL> select  referenced_owner,
      2          referenced_name
      3    from  dba_dependencies
      4    where owner = 'SCOTT'
      5      and name = 'P1'
      6      and referenced_type = 'TABLE'
      7  /
    REFERENCED_OWNER               REFERENCED_NAME
    SCOTT                          EMP
    SQL> SY.

  • I need return the result of a query on a stored procedure

    I need return the result of a query on a stored procedure, I mean when I execute a stored procedure it returns a result set as a select query.
    Best regards...

    If you want some pl/sql code that can be used in a query as it were a table you may be interested in table functions:
    SQL> create or replace type
      2  t_emp is object (
      3  name            varchar2(30),
      4  hire_date date,
      5  salary       number);
      6  /
    Tipo creato.
    SQL> create or replace type
      2  t_emptab is table of t_emp;
      3  /
    Tipo creato.
    SQL> create or replace function tab_fun(p_dept in number)
      2  return t_emptab is
      3  e t_emptab;
      4  begin
      5    select t_emp(ename,hiredate,sal)
      6      bulk collect into e
      7      from emp
      8     where deptno=p_dept;
      9
    10    return dip;
    11  end;
    12  /
    Funzione creata.
    SQL> select *
      2  from table(tab_fun(20));
    NAME                           HIRE_DATE  SALARY
    SMITH                          17-DIC-80        800
    JONES                          02-APR-81       2975
    SCOTT                          09-DIC-82       3000
    ADAMS                          12-GEN-83       1100
    FORD                           03-DIC-81       3000A procedure cannot be used in a select statement.
    Max
    http://oracleitalia.wordpress.com

Maybe you are looking for