How to pass the parameter values to the stored procedure from java code?

I have a stored procedure written in sqlplus as below:
create procedure spInsertCategory (propertyid number, category varchar2, create_user varchar2, create_date date) AS BEGIN Insert into property (propertyid, category,create_user,create_date) values (propertyid , category, create_user, create_date); END spInsertCategory;
I am trying to insert a new row into the database using the stored procedure.
I have called the above procedure in my java code as below:
CallableStatement sp = null;
sp = conn.prepareCall("{call spInsertCategory(?, ?, ?, ?)}");
How should I pass the values [propertyid, category, create_user, create_date) from java to the stored procedure?[i.e., parameters]
Kindly guide me as I am new to java..

Java-Queries wrote:
I have a stored procedure written in sqlplus as below:FYI. sqlplus is a tool from Oracle that provides a user interface to the database. Although it has its own syntax what you posted is actually PL/SQL.

Similar Messages

  • How to fetch %ROWTYPE OUT param of  a stored procedure from Java program?

    I have a stored procedure that has IN / OUT parameter as table_name%ROWTYPE.
    From a java program how can I access this ROWTYPE variable?
    I tried all possible documentation and none of the explains whether or not this is supported.
    My use case expect exactly 1 record from the procedure and we would prefer not to use REF CURSOR.
    Is there a way to achieve this? If so, can someone help me with it by posting the sample code to achieve this?
    I tried all the possible OracleTypes to register the OutParameter and they all fail.
    Looks like there isn't any equivalent of %ROWTYPE in OracleTypes either.
    If you need, I can post my sample procedure that uses %ROWTYPE as OUT parameter.
    I really appreciate your help in this regard.
    - Karthik

    Hi,
    If "returning only 1 record" the showstopper for not using Ref Cursor, you might want to reconsider because as you probably know, the ref cursor is only a pointer and requires additional step to retrieve the data.
    Kuassi

  • How to show a parameter value in the paper layout

    Hi,
    I have a paper parameter form. I need to show the value of the parameter at the top of my report as part of the title. Any ideas?
    Thanks,

    It should display the parameter value in the field you created in the paper layout.
    Make sure you selected the source of the field.
    From the property inspector of the created field go to the source property and select the parameter name from the pop-up list.
    Regards
    Mostafa Abolaynain

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

  • Memory leak problem while passing Object to stored procedure from C++ code

    Hi,
    I am facing memory leak problem while passing object to oracle stored procedure from C++ code.Here I am writing brief description of the code :
    1) created objects in oracle with the help of "create or replace type as objects"
    2) generated C++ classes corresponding to oracle objects with the help of OTT utility.
    3) Instantiating classes in C++ code and assigning values.
    4) calling oracle stored procedure and setting object in statement with the help of setObject function.
    5) deleted objects.
    this is all I am doing ,and getting memory leak , if you need the sample code then please write your e-mail id , so that I can attach files in reply.
    TIA
    Jagendra

    just to correct my previous reply , adding delete statement
    Hi,
    I am using oracle 10.2.0.1 and compiling the code with Sun Studio 11, following is the brief dicription of my code :
    1) create oracle object :
    create or replace type TEST_OBJECT as object
    ( field1 number(10),
    field2 number(10),
    field3 number(10) )
    2) create table :
    create table TEST_TABLE (
    f1 number(10),f2 number (10),f3 number (10))
    3) create procedure :
    CREATE OR REPLACE PROCEDURE testProc
    data IN test_object)
    IS
    BEGIN
    insert into TEST_TABLE( f1,f2,f3) values ( data.field1,data.field2,data.field3);
    commit;
    end;
    4) generate C++ classes along with map file for database object TEST_OBJECT by using Oracle OTT Utility
    5) C++ code :
    // include OTT generate files here and other required header files
    int main()
    int x = 0;
    int y = 0;
    int z =0;
    Environment *env = Environment::createEnvironment(Environment::DEFAULT);
    Connection* const pConn =
    env->createConnection"stmprf","stmprf","spwtrgt3nms");
    const string sqlStmt("BEGIN testProc(:1) END;");
    Statement * pStmt = pConn->createStatement(sqlStmt);
    while(1)
    TEST_OBJECT* pObj = new TEST_OBJECT();
    pObj->field1 = x++;
    pObj->field2 = y++;
    pObj->field3 = z++;
    pStmt->setObject(1,pObj);
    pStmt->executeUpdate();
    pConn->commit();
    delete pObj;
    }

  • Unable to change the parameter value in the configtool

    Hi All,
    Error
    In the Configtool I have changed the custom value to u2018TRUEu2019 of the key u201Cume.superadmin.activatedu201D under Cluster-data -> instance -> server -> services -> com.sap.security.caore.ume.service. Now I am trying to change the value again to u2018FALSEu2019 but the value is not getting updated even after the server is restarted OS level. Please advise.
    System details:
    SAP: PI 7.0
    DB:   MS SQL 2000
    OS:   Windows 2003 server
    Thanks in advance.
    Regards,
    Dinesh

    Hi Dinesh,
    There are a variety of reasons why this is not getting reflected :
    1) When you make changes if you use an AS ABAP or LDAP directory as the data source. The default values of the UME properties assume the database of the AS Java as the data source. This requires you to reconfigure the data source before you can restart the AS Java.
    2) The cluster nodes have not been restarted after the changes
    3) Changes apart from global configuration have also been made elsewhere.
    4)properties as described in Editing UME Properties.
    Editing UME Setting:
    a) Start the Config Tool by executing
    \j2
    ee\configtool\configtool.bat.
    b) In the tree, navigate to Global server
    configuration services com.sap.security.core.ume.
    service.
    The list of UME properties appears.
    Regards
    joel
    Edited by: joel trinidade on Apr 15, 2009 12:29 PM

  • How i can set the selected item of a dropDown component from java code

    Hi
    Thank you for reading my post
    How i can set the slected item of a DropDown component from backing beans java code ?
    it is binded with a database , so one field determine its display and one other field determine its value , I want to set the selected item of this combobox
    In back code i have both value and display values to use them .
    can some one give me some help ?
    Thanks ,

    See code sample 3 at http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
    See also, the selection components row in the table under http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/helloweb.html
    It says
    One way to preselect items is to call setSelectedValue(Object[]) or setSelectedValue(Object) from the prerender() method. You pass in the return values of the items that you want preselected. Be sure to verify that getSelected() returns null before setting the default options, or you will overwrite the user's selections on a post-back.

  • Send Datetime2 value to a SQL Procedure from Java using Hibernate

    Hi All,
    I Have a Procedure which takes a parameter of type datetime2.
    The procedure is called from Java Hibernate.
    How can I Pass datetime2 value to SQL procedure from Java?
    Thanks in advance,
    Shraddha Gore

    You may define a global empty array in some package. Then you can do:
    SQL> CREATE OR REPLACE PACKAGE pkg
    AS
       g_empty   DBMS_SQL.varchar2_table;
    END pkg;
    Package created.
    SQL> CREATE OR REPLACE PROCEDURE p (
       p_tuids   IN   DBMS_SQL.varchar2_table "DEFAULT pkg.g_empty"
    AS
    BEGIN
       NULL;
    END p;
    Procedure created.
    SQL> BEGIN
       p ();
    END;
    PL/SQL procedure successfully completed.

  • Pass PL/SQL Record variable to Stored procedure in Java

    Can some one please give me a code snippet for passing a Record Type variable returned by Stored Procedure. Following is the scenario.
    A record type variable REC_VAR is made of three columns of a table as follows
    EmpNo Number, Empname Varchar2(50), Zip_Code Varchar2(5).
    I am populating this variable in Java code and passing it to Stored Procedure.
    Can I referance Record Type variable in a Oracle package from Java code.
    How would I define these variables as per table’s column type and pass to SP in a java program.
    Thanks,

    58838,
    The following entry -- from the Ask Tom Web site may be helpful (assuming you haven't already seen it):
    how to access variable
    If it doesn't help, you can always search the site.
    Good Luck,
    Avi.

  • How to create and execute PL/SQL program or Procedure from Java (JDBC)

    hi all,
    user will enter the Pl/Sql program from User-Interface. that program has to be create in DB and execute that.
    due to some confusions, how to execute this from Java, i (user) entered the same logic through a Procedure.
    my Java code is
    Statement st = con.createStatement();
    Statement.execute(procedure_query); // procedure name is myPro
    CallableStatement cs = con.prepareCall("{call myPro}");
    (as given in SUN docs - http://java.sun.com/docs/books/tutorial/jdbc/basics/sql.html)
    but its not creating the procedure.
    and i tried to run a procedure (which is already created) with CallableStatement, and this is also not working.
    how to get this.
    thanks and regards
    pavan

    Hi,
    SInce the PL/SQL block is keyed in dynamically, you probably want to use the anonymous PL/SQL syntax for invoking it:
    // begin ? := func (?, ?); end; -- a result is returned to a variable
    CallableStatement cstmt3 =
    conn.prepareCall(“begin ? := func3(?, ?); end;”);
    // begin proc(?, ?); end; -- Does not return a result
    CallableStatement cstmt4 =
    Conn.prepareCall(“begin proc4(?, ?); end;”);
    SQLJ covered in chapter 10, 11, and 12 of my book furnish a more versatile dynamic SQl or PL/SQL mechanisms.
    Kuassi
    - blog http://db360.blogspot.com/
    - book http://db360.blogspot.com/2006/08/oracle-database-programming-using-java_01.html

  • How to call PL-SQL script/stored procedure from Java?

    Assume I want to call a PL-SQL stored procedure from external Java program.
    How can I do this?
    Is there a simple "Hello world" example for this?
    Peter

    This forum is for Oracle only not for java
    Ug

  • How to pass line item values in the table paramer of FM

    Hi all,
    When i will give the import of  the FM as VBELN"sales order number.
    I want to display all the line items for "PO Quantity in the out put of the FM.
    For this i thnk i have to pass the line item values in the table parameter of the FM.
    Can any body please tell me how to pass the values for the line items in the table parameter fo teh FM.
    Please give a example.
    Thanks

    Sub pLoopThroughPivotFields()
    Dim oItem As Excel.PivotItem
    Dim oField As Excel.PivotField
    Set oField = ThisWorkbook.Worksheets("Sheet1").PivotTables("Pivot Table name").PivotFields("field name")
    For Each oItem In oField.PivotItems
    oField.CurrentPage = oItem.Name
    'Put your copy code here
    DoEvents
    Next oItem
    End Sub
    Felipe Costa Gualberto - http://www.ambienteoffice.com.br

  • How to get dynamic paramete value in the context node?

    Hi, experts,
    There are some attributes in the node context(ee_node) that contained the attribute named "ANSSA" in the view(test_view) in the WDA for abap. In the method WDDOMODIFYVIEW of the view(test_view), there is dynamically string , ex."ANSSA". How can I get the value of the "ANSSA" from the node(ee_node)?
    I try to use the following code to get the value in the method WDDOMODIFYVIEW of the view(test_view):
    Method wddomodifyview.
    *importing   para    type   string.
      data:
        Node_Ee_Address                     type ref to If_Wd_Context_Node,
        Elem_Ee_Address                     type ref to If_Wd_Context_Element.
    navigate from <CONTEXT> to <EE_ADDRESS> via lead selection
      Node_Ee_Address = wd_Context->get_Child_Node( Name = IF_ADDR_AUTO_DISP_VIEW=>wdctx_Ee_Address ).
    get element via lead selection
      Elem_Ee_Address = Node_Ee_Address->get_Element(  ).
    get single attribute
      Elem_Ee_Address->get_Attribute(
        exporting
          Name =  para
        importing
          Value = ??? ).
    But I don't know how to replace the "???"   .
    endmethod
    I don't know how to replace the "???"  in the method wddomodifyview? Do you give me some hint for it?
    You can reply back to me via e-mail if you think we should discuss this internally at [email protected] or [email protected]
    Thanks.
    Best regards,
    tao

    Hello Neha,
    Thank you for your help in advance.
    I am very sorry that the above method name ought to be "modifyview", not "wddomodifyview"(I write the error word in the question so that I am very sorry.). I am very sorry the error method name occuring your misunderstand.
    The "para" is the transfered parameter that it is supposed to represent the name of "ANSSA". Actually, the "para" may represent other attribute in the node context, ex. "ENDDA"(date type) attribute.
    I don't write such code in the method modifyview: lv_anssa like ls_ee_node-anssa. Because I am not sure that the  "para"  represent the name of "ANSSA", and the "para" may represent other attribute in the node context, ex. "ENDDA"(date type) attribute.  The  "para" is only the transfered parameter from other method for representing the name of attribute.
    Method modifyview.
    *importing para type string.
    DATA:
    lo_nd_ee_node type ref to if_wd_context_node,
    lo_el_ee_node type ref to if_wd_context_element,
    ls_ee_node type wd_this->element_ee_node.
    I cann't write such code. Because I am not sure that the para represent the name of "ANSSA"******************
    data lv_anssa like ls_ee_node-anssa.
    lo_nd_ee_node = wd_context->get_child_node( name = wd_this->wdctx_ee_node ).
    lo_el_ee_node = lo_nd_ee_node->get_element( ).
    lo_el_ee_node->get_attribute(
    exporting
    name = para
    importing
    value = ??? ).
    endmethod.
    I don't know how to replace the "???". Do you give me more hints?
    Thanks a million.
    Regards,
    Neha

  • SQL Query: How to pass list of values to the IN operator

    Hi,
    I'm trying to pass a list of values to the WHERE <a> IN <list>
    I dont want to use dynamic cursors (REF CURSOR). Is this possible using Oracle SQL?
    Please let me know.
    My program:
    DECLARE
    list_of_ids := '10, 20, 30';
    SELECT MAX(sal) INTO max_sal FROM employee WHERE emp_id IN (list_of_ids);
    END;
    Thanks in Advance,
    Niko

    You do not want to pass a comma separated list. You want to pass a collection. So
    CREATE TYPE num_tbl
    AS
    TABLE OF NUMBER;
    DECLARE
      l_list_of_ids num_tbl := num_tbl( 10, 20, 30 );
    BEGIN
      SELECT max(sal)
        INTO max_sal
        FROM employee
       WHERE emp_id IN (SELECT * FROM TABLE( l_list_of_ids ));
    END;
    /Justin

  • How to pass a Variable value into an ODI Scenario from ODI Package

    I have created an Interface that uses the variable #ENTITY_ID for retrieving entity data from the DWH; now I have generated a Scenario from the interface and placed the Scenario in an ODI Package; am not sure how to pass the #ENTITY_ID variable to the ODI Scenario?
    Any help is greately appreciated.
    Best Regards
    Bee

    Hi Sutrtha,
    Yeah I got the pop up asking to select the variables used, I have selected ENTITY_ID that was used by the interfaces, but on execution of the package the Scenario did not work as the passeed variable #ENTITY_ID is set to 0 instead of the value I am passing.
    Am I missing something?
    Regards
    B

Maybe you are looking for

  • Error in NWDS WAR import. taglib.

    Hi Experts, my requirement is to customize the login page for CE 7.1. I have taken the WAR file, Imported it into NWDS. I imported the jar file logon.jar also. But immediately after the import, but im facing an error which say: "Cannot find the tag l

  • Printing to a printer connected to a Mac through a PC?

    Alright so I have been having this problem that has been going on for a few days now. Every night after I get home from school I spend hours trying to figure out how to get my Windows 7 laptop to print to my printer that is connected to my iMac. Now,

  • RFC with VBA Help Needed.

    Hi. I'm preety new to RFCand but I have to challenge following topic: I need to call SAP transaction  MF42N from RFC. I want to pass the parametres from Excel spreadsheet or externat .csv or .txt file.  Can you please provide some example code. I kno

  • Logging in to another user in B1

    Hello Guys   Iam using SAP B1 2004 2B PL:40,(India)   When iam trying to enter with another userID according to the Authorizations, When i Logged in to that, iam not able to open any document & getting a message "Generating this document requires num

  • Imac sharing my wireless to a PC over ethernet (and switch)

    So I've got next to me an imac currently connected via a wireless N time capsule upstairs. I'm trying to get my PC hooked up to my Imac via "Internet Sharing". At this point I have... Base station wireless-->Imac Downstairs-->Straight through to swit