How to send an array of values to stored procedures in java

can anyone tell me how ican send a two dimensional array of string values can be send to a data base at one go.
actually i am a java developer and the technolgies i am using are servlets and java data base connectivity(JDBC). the oracle developer with whom i have worked has created aprocedure for taking the two values. she has created a record and she has used the the record as an in parameter to the procedure. that particular record has two columns and i need to send it as a two dimensional array.

The PL/SQL webservice functionality in Oracle WebServices can expose PL/SQL procedures as webservices.
If you are just looking for Java solution, check out JPublisher, which maps PL/SQL stored procedure into JDBC programs.

Similar Messages

  • Sending an array of values to Oracle procedure to use in WHERE IN clause

    I have a stored procedure in Oracle as shown below:
    <p><h5><font color=NAVY>CREATE PROCEDURE MY_TEST_PROC(
    CUR OUT SYS_REFCURSOR,
    PARAM_THAT_WILL_BE USEDINSIDE_WHERE_IN
    AS
    BEGIN
    OPEN CUR FOR
    SELECT *
    FROM MY_TABLE
    WHERE COL1 IN (here I want to put values received from C#)
    END;</font></h5></p>
    On the ASP.NET application side I have a select element with several options. I want to use these list items in my WHERE clause. I know that I can have a VARCHAR2 input parameter in my stored proc, make a comma separated string from the list items, send it to the procedure. There are two concerns with going this way:
    1.I make my website vulnerable to SQL injections
    2.In my stored proc I have to use EXECUTE ('SELECT ...') pattern which I would like to avoid.
    How can I send these list items to the stored procedure and use them inside the WHERE IN clause? I'm using ODP.NET and have heard of UDT but don't know how to use it.

    Assuming a connection variable called conn and Java String array called myStringArray, here's the gist of it:
    ArrayDescriptor descriptor1 = ArrayDescriptor.createDescriptor("STRING_ARRAY", conn);
    ARRAY array1 = new ARRAY(descriptor1, conn, myStringArray);
    OracleCallableStatement cs = (OracleCallableStatement) conn.prepareCall(sql);
    cs.setARRAY(1, array1);

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

  • How to send nested object collection to PL/SQL Procedure as an Input param

    How to send nested object collection to PL/SQL Procedure as an Input parameter.
    The scenario is there is a parent mapping object containing a collection(java.sql.Array) of child objects.
    I need to send the parent object collection to PL/SQL procedure as a input parameter.
    public class parent{
    String attr1;
    String attr2;
    Child[] attr3;
    public class Child{
    String attr1;
    SubChild[] attr2;
    public class SubChild{
    String attr1;
    Urgent!!!
    Edited by: javiost on Apr 30, 2008 2:09 AM

    javiost wrote:
    How to send nested object collection to PL/SQL Procedure as an Input parameter.There are a few ways to do this, all of which likely depend on the particular database you're using.
    Urgent!!!Not to me...

  • How to bind arrays to PL/SQL stored procedure using OCI?

    Hi,
    We are having problems trying to bind arrays to PL/SQL stored procedure using OCI. Here is the situation:
    - We have a stored procedure called "GetVEPFindTasks" with the following interface:
    PROCEDURE GetVEPFindTasks (
    p_ErrorCode OUT NUMBER,
    p_ErrorMsg OUT VARCHAR2,
    p_RowCount OUT NUMBER,
    p_VEPFindTasks OUT t_VEPFindTaskRecordTable,
    p_MaxTask IN NUMBER);
    t_VEPFindTaskRecordTable is a record with the following entries:
    TYPE t_VEPFindTaskRecord IS RECORD (
    RTCID NUMBER,
    TransNum NUMBER,
    TransTimestamp VARCHAR2(20),
    Pathname1 image_data.pathname%TYPE,
    Pathname2 image_data.pathname%TYPE,
    Pathname3 image_data.pathname%TYPE,
    OperatorID operator.id%TYPE);
    - Now, we are trying to call the stored procedure from C++ using OCI (in UNIX). The call that we use are: OCIBindByName and OCIBindArrayOfStruct to bind the parameters to the corresponding buffers. We bind all parameters in the interface by name. Now, we do bind the record's individual item by name (RTCID, TransNum, etc.), and not as a record. I don't know if this is going to work. Then, we use the bind handles of the binded record items (only record items such as RTCID, TransNum, and NOT error_code which is not part of the record) to bind the arrays (using OCIBindArrayOfStruct).
    All of the parameters that are binded as arrays are OUTPUT parameters. The rest are either INPUT or INPUT/OUTPUT parameters. Now, when we try to execute, OCI returns with an error "Invalid number or types of arguments" (or something to that sort... the number was something like ORA-06550). Please help...
    Is there any sample on how to use the OCIBindArrayOfStruct with PL/SQL stored procedures? The sample provided from Oracle is only for a straight SQL statement.
    Thank's for all your help.
    ** Dannil Chan **

    As you said:
    You have to pass in an array for every field and deconstruct/construct the record in the procedure. There is no support for record type or an array of records. Can you give me a example? I'am very urgently need it.
    thanks
    email: [email protected]

  • How to find if COLUMN DEFAULT VALUE is stored as metadata?

    Hello,
    I'm using Oracle 11g enhanced ADD COLUMN Functionality. Adding new columns with DEFAULT values and NOT NULL constraint no longer requires the default value to be stored in all existing records.
    Sometimes we change DB columns from NOT NULL with DEFAULT to NULL with DEFAULT. This operation "materialize" column default.
    Is there an easy way (Dictionary view) how to find, that COLUMN default value is stored as metadata or is "materialized" ?
    Thanks. Filip
    Oracle RDBMS version : Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

    Thanks for your suggestion, but it is not what i'm looking for :-(
    I don't need to find the default value, i need to know how is default value stored. It could be stored in 2 ways.
    1. "materialized" - prior to 11G (value is physicaly stored for every column)
    2. "as a metadata" - new 11G functionality (default is not physicaly stored and if you query the column DB transalte NULL value to defaut value)
    Now I would like to now if my column is type 1) or 2). How can I do it?
    Thank you.Filip

  • How to get return values from stored procedure to ssis packge?

    Hi,
    I need returnn values from my stored procedure to ssis package -
    My procedure look like  and ssis package .Kindly help me to oget returnn value to my ssis package
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    -- =============================================
    -- Author: <Author,,Name>
    -- Create date: <Create Date,,>
    -- Description: <Description,,>
    -- =============================================
    ALTER PROCEDURE [TSC]
    -- Add the parameters for the stored procedure here
    @P_STAGE VARCHAR(2000)
    AS
    BEGIN
    -- SET NOCOUNT ON added to prevent extra result sets from
    -- interfering with SELECT statements.
    SET NOCOUNT ON;
    -- Insert statements for procedure here
    --SELECT <@Param1, sysname, @p1>, <@Param2, sysname, @p2>
    truncate table [INPUTS];
    INSERT
    INTO
    [INPUTS_BASE]
    SELECT
    [COLUMN]
    FROM [INPUTS];
    RETURN
    END
    and i am trying to get the return value from execute sql task and shown below
    and i am taking my returnn value to result set variable

    You need to have either OUTPUT parameters or use RETURN statement to return a value in stored procedures. RETURN can only return integer values whereas OUTPUT parameters can be of any type
    First modify your procedure to define return value or OUTPUT parameter based on requirement
    for details see
    http://www.sqlteam.com/article/stored-procedures-returning-data
    Once that is done in SSIS call sp from Execute SQL Task and in parameter mapping tabe shown above add required parameters and map them to variables created in SSIS and select Direction as Output or Return Value based on what option you used in your
    procedure.
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to set pdn12.trancat mandatory in this stored procedure?

    How can i make PDN12.transcat in this Stored Procedure
    USE [zIRC DEMO]
    GO
    /****** Object:  StoredProcedure [dbo].[SP_CHECK_MANDATORY_IN_OPDN]    Script Date: 03/07/2014 10:37:54 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[SP_CHECK_MANDATORY_IN_OPDN]
      @list_of_cols_val_tab_del NVARCHAR(255), @error_message NVARCHAR(255) OUTPUT
    AS
    BEGIN
    --invoice type
      select
      @error_message='In header line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND isnull(OPDN.U_InvType,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND isnull(OPDN.U_InvType,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Invoice Type is missing'
    -- num at card
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In header line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.NumAtCard,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.NumAtCard,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Vendor ref. number is missing'
      END
    -- transporter
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_Transport,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_Transport,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Transporter is missing'
      END
    --dealer
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_dealer,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(OPDN.U_Dealer,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Dealer is missing'
      END
    --base price
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_BasePrice,0)=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_BasePrice,0)=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Base Price is missing'
      END
    --taxcode
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(PDN1.TaxCode,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S','L') AND isnull(PDN1.TaxCode,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Taxcode is Missing'
      END
    -- ed rate
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDRate,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDRate,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Excice Duty Rate is missing'
      END
    -- ed duty
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDuty,0)=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('M','D','S') AND isnull(PDN1.U_EDuty,0)=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Excice Duty is missing'
      END
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND ISNULL(PDN1.U_MfgInvNo,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND ISNULL(PDN1.U_MfgInvNo,'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Mfg. invoice number is missing'
      END
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND isnull(convert(nvarchar(10),U_MfgInvDt,112),'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND isnull(convert(nvarchar(10),U_MfgInvDt,112),'')=''
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Mfg. invoice date is missing'
      END
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgQty=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgQty=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Mfg. invoice Quantity is missing'
      END
      if(ISNULL(@error_message,'')='')
      BEGIN
      select
      @error_message='In line number(s), '+ substring
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      where
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgValue=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ),1
      ,LEN((
      select CONVERT(char(2),PDN1.LineNum)+','
      from
      OPDN
      inner join PDN1 on OPDN.DocEntry=PDN1.DocEntry
      WHERE
      OPDN.DocEntry=@list_of_cols_val_tab_del AND OPDN.DocType='I' AND OPDN.U_InvType in ('D','S') AND PDN1.U_MfgValue=0
      order by
      PDN1.LineNum FOR XML PATH ('')
      ))-1
      )+' Mfg. Assessble value is missing'
      END
      if(ISNULL(@error_message,'')<>'')
      BEGIN
      return -1
      END
      else
      begin
      return 0
      end
    END

    Hello Nabil
    Could you explain what is the point of making PDN12.Trancat mandatory? I am asking this because at my end that field has got NULL value in all PDN12 table entries, and I am not sure if this field can be updated manually when creating a Good Receipt PO. Considering this, it seems that by making this field mandatory TN will block all Good Receipts from addition.
    Regards

  • How can I automatically prepend comment blocks to stored procedures?

    How can I automatically prepend comment blocks to stored procedures?
    In my organization, the standard is to comment all stored procedures with a comment block that looks like this:
    /*-- =============================================
    -- Created by: <Owner>
    -- Created date: 01/08/2012
    -- Purpose: Inserts new setting value, code and description
    -- Modifications:
    -- Modified by: <Owner>
    -- Modification date: 01/08/2012
    -- Purpose: Inserts new setting value, code and description
    -- =============================================*/Thanks.
    select * from v$version;
    BANNER                                                                        
    Oracle Database 11g Express Edition Release 11.2.0.2.0 - Production             
    PL/SQL Release 11.2.0.2.0 - Production                                          
    CORE     11.2.0.2.0     Production  Edited by: xDeviates on 01-ago-2012 7:37
    Edited by: xDeviates on 01-ago-2012 8:31

    Hi,
    If I want to write a package called pk_fubar, I copy the following script and call it fubar.sql
    --     ==========  package_name.sql starts here  ==========
    --     Package_Name.sql
    SPOOL     &home_dir\package_name.lst
    PROMPT     .     H   H  EEEE     A    DDDD
    PROMPT     .     H   H  E       A A   D   D
    PROMPT     .     HHHHH  EEE    A   A  D   D
    PROMPT     .     H   H  E      AAAAA  D   D
    PROMPT     .     H   H  EEEEE  A   A  DDDD
    @@package_name_head
    PROMPT     .     BBBB    OOO   DDDD   Y   Y
    PROMPT     .     B   B  O   O  D   D   Y Y
    PROMPT     .     BBBB   O   O  D   D    Y
    PROMPT     .     B   B  O   O  D   D    Y
    PROMPT     .     BBBB    OOO   DDDD     Y
    @@package_name_body
    SPOOL     OFF
    @@package_name_test
    -- EXIT
    --     ==========  package_name_head.sql starts here  ==========
    CREATE OR REPLACE PACKAGE     pk_package_name
    AS
    FUNCTION     sign_in
    (     in_user_name     IN     VARCHAR2
    ,     in_password_txt     IN     VARCHAR2
    RETURN     PLS_INTEGER
    END     pk_package_name;
    SHOW ERRORS;
    GRANT     EXECUTE     ON pk_package_name     TO schema_name_some_role;
    --     ==========  package_name_body.sql starts here  ==========
    CREATE OR REPLACE PACKAGE BODY     pk_package_name
    AS
    --  Procedures related to SCHEMA_NAME ...
    --  2012 July 23 -- Package started with proc_x.  (Frank Kulash)
    --     **   local procedures and variables   **
    --     **   x   **
    --     **   initialization section   **
    --     The following code is executed once per session, when the package is loaded.
    BEGIN
         set_var     ( 'DT_FMT_TXT'
              , 'YYYY-MM-DD HH24:MI:SS'
    END     pk_package_name;
    SHOW ERRORS;
    --     ==========  package_name_test.sql starts here  ==========
    --     PACKAGE_NAME_TEST.SQL -- Test procedures in schema_name.pk_package_name
    SET     DOCUMENT     OFF
    SET     SERVEROUTPUT     ON     SIZE     10000
    ALTER SESSION     SET NLS_DATE_FORMAT = 'DD-Mon-YYYY HH24:MI:SS';
    SPOOL     @@package_name_test.lst
    PROMPT
    PROMPT     ***********************
    PROMPT     **  Testing x  **
    PROMPT     ***********************
    PROMPT
    SPOOL     OFFThen I replace package_name with fubar, and schema_name with the actual schema name. Finally, I cut off parts from the end to create fubar_test.sql, fubar_body.sql and fubar_head.sql. You could easily include a multi-line procedure comment template in this script. Every time you add a procedure or function, ciopy and paste that comment template, and then modify the copy.

  • How to send more than one value to the Jump target report variable screen.

    Hi,
       I have two reports with Plant variable on their input variable screens. Say this Plant can take two values X and Y. The first report is executed with Plant value X and displays data. When a jump is made  to report two, Plant value X is retrievd into report two's plant varible value. Now how to send value Y also to Report two when jump is made. I think we can do it with a customer exit? Any help is appreciated
    Thanks
    Bhanu

    Hi Bhanu,
    I guess u have created a Variable with Sinlge value ,So Create a Variable which has Multiple Sinlge Values or Interval so that u can have more than one value and if u hvae more than value u will get data for those values and when u do a jump then u can see the data in the JUMP query for both the Values of Input.
    Rgds
    SVU123

  • How to send a list item value to URL to open data related to item value

    Hi,
    Iam using Apex4.0 and iam facing some problem. Iam unable to send selected list item value to the url specified in the HTMl region.
    Here i want to open the data related to list item value in other page.
    List item - :Familyp
    i want to pass this selected value to the url and when ever user selected the list item and clicks on the url, then it should display the item value related data in new page.
    I tried with &FamilyP in url but it's not working. Any one help me plz.
    Regards
    Vamsi.Tata

    Is it a normal Select list or Multi Select list?
    If you have select list that allows you to select multiple options then you cannot pass it through URL. Multi-select /Shuttle keep colon separated list in the item, and this confuses Apex because the Apex URL uses colons for a different purpose. No escaping or URL encoding will help.
    If it is normal select list that allows selection of only one option then you can pass through the url. Unless of course the data has a colon in it.
    For multi-select, and when the value contains colon, the only way is to save the value in session state, same page item or any other place like Application Item, and then reference it at the other end. Never pass through the URL.
    Regards,

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

  • How to pass a array of object to oracle procedure using callable

    Hi,
    I am calling a oracle stored procedure using callable statement which has IN and OUT parameter of same type.
    IN and OUT are array of objects. (ie) IN parameter as Array of Objects and OUT parameter as Array of Objects
    here are the steps i have done as advised from oracle forum. correct me if i am in wrong direction
    ORACLE types and Stored Procedure
    CREATE OR REPLACE
    TYPE APPS.DEPARTMENT_TYPE AS OBJECT (
    DNO NUMBER (10),
    NAME VARCHAR2 (50),
    LOCATION VARCHAR2 (50)
    CREATE OR REPLACE
    TYPE APPS.DEPT_ARRAY AS TABLE OF department_type;
    CREATE OR REPLACE package body APPS.insert_object
    IS
    PROCEDURE insert_object_prc (d IN dept_array, d2 OUT dept_array)
    IS
    BEGIN
    d2 := dept_array ();
    FOR j IN 1 .. d.COUNT
    LOOP
    d2.EXTEND;
    d2 (j) := department_type (d (j).dno, d (j).name, d(j).location);
    END LOOP;
    END insert_object_prc;
    END insert_object;
    JAVA CODE
    Value Object
    package com.custom.vo;
    public class Dep {
    public int empNo;
    public String depName;
    public String location;
    public int getEmpNo() {
    return empNo;
    public void setEmpNo(int empNo) {
    this.empNo = empNo;
    public String getDepName() {
    return depName;
    public void setDepName(String depName) {
    this.depName = depName;
    public String getLocation() {
    return location;
    public void setLocation(String location) {
    this.location = location;
    to call stored procedure
    package com.custom.callable;
    import com.custom.vo.Dep;
    import oracle.jdbc.OracleCallableStatement;
    import oracle.jdbc.OracleConnection;
    import oracle.jdbc.OracleTypes;
    import oracle.jdbc.pool.OracleDataSource;
    import oracle.sql.ARRAY;
    import oracle.sql.ArrayDescriptor;
    import oracle.sql.Datum;
    import oracle.sql.STRUCT;
    import oracle.sql.StructDescriptor;
    public class CallableArrayTryOut {
    private static OracleDataSource odcDataSource = null;
    public static void main(String[] args) {
    OracleCallableStatement callStatement = null;
    OracleConnection connection = null;
    try {
    odcDataSource = new OracleDataSource();
    odcDataSource
    .setURL("......");
    odcDataSource.setUser("....");
    odcDataSource.setPassword("....");
    connection = (OracleConnection) odcDataSource.getConnection();
    } catch (Exception e) {
    System.out.println("DB connection Exception");
    e.printStackTrace();
    Dep[] dep = new Dep[2];
    dep[0] = new Dep();
    dep[0].setEmpNo(100);
    dep[0].setDepName("aaa");
    dep[0].setLocation("xxx");
    dep[1] = new Dep();
    dep[1].setEmpNo(200);
    dep[1].setDepName("bbb");
    dep[1].setLocation("yyy");
    try {
    StructDescriptor structDescriptor = new StructDescriptor(
    "APPS.DEPARTMENT_TYPE", connection);
    STRUCT priceStruct = new STRUCT(structDescriptor, connection, dep);
    STRUCT[] priceArray = { priceStruct };
    ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(
    "APPS.DEPT_ARRAY", connection);
    ARRAY array = new ARRAY(arrayDescriptor, connection, priceArray);
    callStatement = (OracleCallableStatement) connection
    .prepareCall("{call insert_object.insert_object_prc(?,?)}");
    ((OracleCallableStatement) callStatement).setArray(1, array);
    callStatement.registerOutParameter(2, OracleTypes.ARRAY,
    "APPS.DEPT_ARRAY");
    callStatement.execute();
    ARRAY outArray = callStatement.getARRAY(2);
    Datum[] datum = outArray.getOracleArray();
    for (int i = 0; i < datum.length; i++) {
    oracle.sql.STRUCT os = (oracle.sql.STRUCT) datum[0];
    Object[] a = os.getAttributes();
    for (int j = 0; j < a.length; j++) {
    System.out.print("Java Data Type :"
    + a[j].getClass().getName() + "Value :" + a[j]
    + "\n");
    connection.commit();
    callStatement.close();
    } catch (Exception e) {
    System.out.println("Mapping Error");
    e.printStackTrace();
    THE ERROR
    Mapping Errorjava.sql.SQLException: Inconsistent java and sql object types
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
    at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
    at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:1130)
    at oracle.sql.StructDescriptor.toOracleArray(StructDescriptor.java:823)
    at oracle.sql.StructDescriptor.toArray(StructDescriptor.java:1735)
    at oracle.sql.STRUCT.<init>(STRUCT.java:136)
    at com.custom.callable.CallableArrayTryOut.main(CallableArrayTryOut.java:48)

    You posted this question in the wrong forum section. There is one dedicated to Java that was more appropriate.
    Anyway here is a link that describes what you should do.
    http://download.oracle.com/docs/cd/B19306_01/java.102/b14355/oraarr.htm#i1049179
    Bye Alessandro

  • How to output value from stored procedure

    Hi folks, I need to output the OrderFK from a stored procedure not really sure how to achieve this any help or tips much appreciated.
    Sql code below
    USE [TyreSanner]
    GO
    /****** Object: StoredProcedure [dbo].[AddCustomerDetails] Script Date: 11/12/2014 20:56:34 ******/
    SET ANSI_NULLS ON
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    /***********************Declare variables ***********************/
    /******tblCustomer******/
    @Forename nvarchar(50),
    @Surname nvarchar(50),
    @HouseNo nvarchar(50),
    @CustAddress nvarchar(50),
    @Town nvarchar(50),
    @Postcode nvarchar(50),
    @ContactNo nvarchar(50),
    @EmailAddress nvarchar(50),
    /******tblLink_OrderProduct******/
    @ProductQuantity int,
    @TotalProductSaleCost decimal,
    @ProductFK int,
    @FittingDate date,
    @FittingTime Time
    As
    DECLARE @CustomerFK int;
    DECLARE @OrderFK int;
    Begin TRANSACTION
    SET NOCOUNT ON
    INSERT INTO [TyreSanner].[dbo].[Customer](Forename, Surname, HouseNo, CustAddress, Town, Postcode, ContactNo, EmailAddress)
    VALUES (@Forename,@Surname,@HouseNo,@CustAddress,@Town,@Postcode,@ContactNo,@EmailAddress)
    Set @CustomerFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Order] (CustomerFK)
    VALUES (@CustomerFK)
    SET @OrderFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
    VALUES
    (@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime)
    COMMIT TRANSACTION

    Hi brucey54,
    There’re several ways to capture the value from a Stored Procedure. In you scenario, I would suggest 2 options, by an output parameter or by a table variable.
    By an output Parameter, you need to make a little bit modification on your code as below:
    USE [TyreSanner]
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    @Forename nvarchar(50),
    @FittingDate date,
    @FittingTime Time,
    @OrderFK int output
    As
    DECLARE @CustomerFK int;
    --DECLARE @OrderFK int;
    Run the following code, Then @OrderFKvalue holds the value you’d like.
    DECLARE @OrderFKvalue int;
    EXEC AddCustomerDetails(your parameters,@OrderFKvalue output)
    Anyway if you don’t like to add one more parameter, you can get the value by a table variable as well. Please append “SELECT @OrderFK;” to your Procedure as below:
    USE [TyreSanner]
    GO
    ALTER PROCEDURE [dbo].[AddCustomerDetails]
    SET @OrderFK = SCOPE_IDENTITY()
    INSERT INTO [TyreSanner].[dbo].[Link_OrderProduct](OrderFK, ProductFK, ProductQuantity, TotalProductSaleCost, FittingDate, FittingTime)
    VALUES
    (@OrderFK, @ProductFK, @ProductQuantity, @TotalProductSaleCost, @FittingDate, @FittingTime);
    SELECT @OrderFK;
    Then you can call the Stored Procedure as below:
    DECLARE @T TABLE (OrderFK INT);
    INSERT @T EXEC AddCustomerDetails(your parameters) ;
    SELECT OrderFK FROM @T;
    There’re more options to achieve your requirement, please see the below link:
    How to Share Data between Stored Procedures
    If you have any question, feel free to let me know.
    Best Regards,
    Eric Zhang

Maybe you are looking for