How to add records or how to maintain list in stored Procedure

Hi,
I am facing an issue in the addition of record in the type
create or replace
TYPE               "PROD_SEARCH_COUNT_TBL"                                          AS TABLE OF PROD_SEARCH_COUNT_OBJ;
create or replace
TYPE               "PROD_SEARCH_COUNT_OBJ"                                          AS OBJECT
( /* TODO enter attribute and method declarations here */
    V_Name Varchar2(500 Byte),
    v_Value Varchar2(500 Byte),
    v_count Number
I want to add records to the type I tried following way
prod_wcf_rec PROD_SEARCH_COUNT_TBL;
  SELECT PROD_SEARCH_COUNT_OBJ('Name1','Value1',1) BULK COLLECT INTO prod_wcf_rec FROM DUAL;
    SELECT PROD_SEARCH_COUNT_OBJ('Name2','Value2',2) BULK COLLECT INTO prod_wcf_rec FROM DUAL;
    SELECT PROD_SEARCH_COUNT_OBJ('Name3','Value3',3) BULK COLLECT INTO prod_wcf_rec FROM DUAL;
    SELECT PROD_SEARCH_COUNT_OBJ('Name4','Value4',4) BULK COLLECT INTO PROD_WCF_REC FROM DUAL;
DBMS_OUTPUT.PUT_LINE ('-----------------------------Looping----------------------------');
FOR i in 1 .. prod_wcf_rec.COUNT
LOOP         
DBMS_OUTPUT.PUT_LINE (prod_wcf_rec(i).V_Name||' - '||prod_wcf_rec(i).v_Value||' - '||prod_wcf_rec(i).v_count);     
   END LOOP;
   DBMS_OUTPUT.PUT_LINE ('-----------------------------Looping----------------------------');
In printing I am getting last records only .So is there any way to add records to PROD_SEARCH_COUNT_TBL
How to add records or how to maintain list in stored Procedure

Every time you BULK COLLECT into a collection type the value is overwirtten. So you need to try something like this.
SQL> create or replace type prod_search_count_obj as object(v_name varchar2(500 byte), v_value varchar2(500 byte), v_count number)
  2  /
Type created.
SQL> create or replace type prod_search_count_tbl as table of prod_search_count_obj
  2  /
Type created.
SQL> declare
  2    prod_wcf_rec prod_search_count_tbl;
  3  begin
  4    select obj_val
  5      bulk collect into prod_wcf_rec
  6      from (
  7            select prod_search_count_obj('name1','value1',1) obj_val from dual
  8            union all
  9            select prod_search_count_obj('name2','value2',2) from dual
10            union all
11            select prod_search_count_obj('name3','value3',3) from dual
12            union all
13            select prod_search_count_obj('name4','value4',4) from dual
14           );
15
16    dbms_output.put_line ('-----------------------------looping----------------------------');
17    for i in 1 .. prod_wcf_rec.count
18    loop
19      dbms_output.put_line (prod_wcf_rec(i).v_name||' - '||prod_wcf_rec(i).v_value||' - '||prod_wcf_rec(i).v_count);
20    end loop;
21    dbms_output.put_line ('-----------------------------looping----------------------------');
22  end;
23  /
-----------------------------looping----------------------------
name1 - value1 - 1
name2 - value2 - 2
name3 - value3 - 3
name4 - value4 - 4
-----------------------------looping----------------------------
PL/SQL procedure successfully completed.
SQL>

Similar Messages

  • How to add a new printer into printer list?

    Dear all,
    May I know how to add new printer into my printer list in SAP system? My company SAP is SAP 4.0B. Can any one please teach me how to add printer step-by-step?
    Thanks alot!!
    PC

    Solved

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

  • How to add record in List Box in Screen Painter(SE51) ?

    I am not able to add record in List box in Screen Painter using se51 Transaction code.
    Regards,
    Nirav Desai

    Dear All,
        I found the solution.
    If you are facing same problem , follow the bellow steps.
    1. Declare in report.
    TYPE-POOLS: VRM.
    DATA: NAME TYPE VRM_ID,
    LIST TYPE VRM_VALUES,
    VALUE LIKE LINE OF LIST.
    2. IN PBO Event.
    clear: list.
    NAME = 'TXT_PERIOD'.    " your screen field name
    VALUE-KEY = '1'.
    VALUE-TEXT = 'LINE 1'.
    APPEND VALUE TO LIST.
    VALUE-KEY = '2'.
    VALUE-TEXT = 'LINE 2'.
    APPEND VALUE TO LIST.
    VALUE-KEY = '3'.
    VALUE-TEXT = 'LINE 3'.
    APPEND VALUE TO LIST.
    CALL FUNCTION 'VRM_SET_VALUES'
    EXPORTING ID = NAME VALUES = LIST.
    Regards,
    Nirav Desai

  • How to add a Field to the Result List in Activity

    Hello Experts !
    We are on CRM 7.0. I want to add a field to the Result List of Activity (Component: BT126S_APPT / View: ApptSR). This field is the address of the "Employee Responsible".
    So, how can I add a field to the Result List? AET is not a relevant tool for us because we don't want to create an attribute it already exist in the BOL. We just have to enhance the result list with BOL existing attributes.
    Also, after I add the field, I will need to populate my field with Data via some method.
    Thanks in Advance to all !
    Mariano.-
    SAP.

    Hi Mariano,
    The component was missing some technical data. Implement sap notes 1226612, 1363752, and then follow the manual procedure shown below.
    u2022     Execute transaction SE11.
    u2022     Choose the Radio button "Data Type" and enter value
                  "CRMST_QUERY_R_ACT_BTIL" in the Data Type field.
    u2022     Click on "Change" button.
    u2022     Position the cursor before the Includes added to this structure. Click
                 On the "+" button to add a new attribute.
    u2022     Enter the following details in the newly added blank row.
         Component: PERSON_RESP_LIST
         Component Type: CRMT_PERSON_RESP_LIST.
    u2022     Save the changes and activate the structure.
    u2022     Add the "Employee Responsible" field to the View configuration.
    u2022     Open the BSP application BT126S_APPT.
    u2022     Double-click on the view BT126S_APPT/ApptSR in the left side panel.
    u2022     Choose tab "Configuration" in right side panel.
    u2022     Choose the right configuration by using the "Choose Configuration" button.
    u2022     Click on the Edit button.
    u2022     Add the "Employee Responsible" attribute from the "Available fields" list to "Displayed fields" list.
    u2022     Save the changes
    Regards
    Krishna

  • How to add new data element to field list

    Hi,
    I am implementing Succession Planning 3.0 SP1.
    To make new data element was successful.
    I want to use them as sort field, however I don't know how to add them to the list of fields with caption.
    (i.e. to setting Visualize>My Org Units>Sort Fields)
    If you know how to config data elements usw. Please advise.
    Best Regards,
    Hiroshi Takimoto

    Hi Hiroshi,
    There are 2 ways to do this, both involving some customization of the application.
    1) Extend your HR-OCI views (TMC_O_SUCC_T & TMC_O_SUCC_B for My Org Units and TMC_IN_REP_T_DT & TMC_IN_REP_B_DT) to include Short Name. You probalby want to seek help from an OM consultant if this is not your area of expertise.
    2) Create a linked data element that links together the existing data elements and a new data element which includes Short Name. Your new data element must have the name of the existing data elements or you should change the hierarchy configuration that uses these data elements. Beware that this can prove troublesome for the Position Hierarchy because of the "virtual root" that is created - sometimes the join does not work because of this.
    Best regards,
    Luke

  • Create Tabular Form wizard - how to add rows to Table / View Owner list?

    Create Tabular Form wizard asks to choose "Table / View Owner"
    How to add additional schemas/users to this "Table / View Owner" dropdown list?

    Next step:
    I tried to create 2nd application - and it sees and allows to select from schemas I added in previous step.
    Then I tried to add 1 more schema - and 2nd application can't see it...
    I create 3rd application and select 1st schema (assigned when workspace was created) - and it sees only this one schema
    I create 4th application and select another schema (added in previous steps) - and it sees 2 schemas from 4 assigned
    what is this?
    how to live with it?

  • How to Return ten records into java class by using oracle stored procedure

    Hello sir/Friends
    There is a procedure that returns 10 records from the oracle table and i want to display all 10 records into the table in java class.
    Please reply
    Thanking you.

    When you execute the stored procedure it will return your results as a ResultSet. Iterate over itto get the values you need then do with them as you please.
            List<MyObject> results = new ArrayList<MyObject>();
            MyObject mo = null;
            ResultSet rs = stmt.executeQuery("SELECT a_value FROM a_table");
            while (rs.next())
                mo = new MyObject();
                mo.setValue(rs.getString(1));
                results.add(mo);
            }

  • How to add a calculated field in a list definition (schema.xml)?

    Hello,
    I'm currently trying to add a calculated field to a list definition (schema.xml).
    I have put the following code at the end of the schema.xml for the list I want to create. But when I deploy and activate the feature for the list, it doesn't appear in the list field.
    <Field ID="{EE20EC4B-4216-4259-A84F-C478CE42B70F}" Name="EC_EventsMgmt_CalculatedTime" StaticName="EC_EventsMgmt_CalculatedTime" Group="EC_EventsMgmt" Type="Calculated" DisplayName="Calculated Time" Required="TRUE" Hidden="FALSE" ReadOnly="FALSE" Format="DateTime"> <Formula>=DATE(2009,1,1)+TIME(EC_EventsMgmt_ScheduleHour,EC_EventsMgmt_ScheduleMinute,0)</Formula> <FieldRefs> <FieldRef Name="EC_EventsMgmt_ScheduleHour"/> <FieldRef Name="EC_EventsMgmt_ScheduleMinute"/> </FieldRefs> </Field>
    Could you please give me some help and explain me why it is not working?
    Thanks a lot.

    Hi there.
    If I understand correctly, you create this list within the same feature?
    If so, the list isn't available during the propagation, and therefore the calculated field can't be added.
    If this is the case, then you could work around this by adding a feature activated event handler to your feature and add the calculated field programmatically in that event.
    Hope this helps.
    Regards,
    Magnus
    My blog: InsomniacGeek.com

  • How to add a button on the ALV LIST pop up

    Hi ,
    Can any one help me to add a button on the ALV list which is a pop up using ABAP Objects.
    Thanks in advance.
    Regards,
    Kavya.

    HI ,
    I want to add a push button on the ALV list out put which is comming as a pop up and I want this using classes and methods.
    I have got a method IF_SREL_BROWSER_COMMANDS~ADD_BUTTONS from class cl_gos_attachment_list  but still I am unable to get any additional button on the output ALV popup.
    Please help.
    Regards,
    Kavya.

  • How can i create a Global Temporary Table inside a Stored Procedure....

    Hi...
    I need to create a Global Temporary Table inside a Stored
    Procedure....
    I have no idea how to do that....
    Please....if u can send me a sample, send to me....
    Thanks a lot

    To create a global temporary table inside a stored procedure,
    the minimal syntax would be:
    CREATE OR REPLACE PROCEDURE procedure_name
    AS
    BEGIN
    EXECUTE IMMEDIATE 'CREATE GLOBAL TEMPORARY TABLE table_name'
    || '(column_name NUMBER)';
    END procedure_name;
    As Todd stated, it would probably be better to create the global
    temporary table outside of the procedure:
    SQL> CREATE GLOBAL TEMPORARY TABLE table_name
    2 (column_name NUMBER);
    Table created.
    You can also specify things like ON COMMIT PRESERVE ROWS or ON
    COMMIT DELETE ROWS.
    It may be that there is something else, like a PL/SQL table of
    records or a cursor, that would suit your needs better. It is
    difficult to guess without knowing what you want to do with it.

  • How to get multiple out parameters from a pl/sql stored procedure in ADF Jdeveloper 11g release2

    I´m trying to call from AppModuleImpl a stored procedure from my oracle DB which receives one input parameter and returns 5 out parameters. 
    I´m using jdeveloper 11g release2  ADF and I have created a java bean "ProRecallPlatesBean " with the atributes and accesors and I serialize it. just like in this article http://docs.oracle.com/cd/E24382_01/web.1112/e16182/bcadvgen.htm#sm0297
    This is my code so far:
    public ProRecallPlatesBean getCallProRecallPlates(String numPlates) {
    CallableStatement st = null;
    try {
              // 1. Define the PL/SQL block for the statement to invoke
              String stmt = "begin CTS.Pk_PreIn.proRecallPlates(?,?,?,?,?,?); end;";
              // 2. Create the CallableStatement for the PL/SQL block
              st = getDBTransaction().createCallableStatement(stmt,0);
              // 3. Register the positions and types of the OUT parameters
              st.registerOutParameter(2,Types.VARCHAR);
    st.registerOutParameter(3,Types.VARCHAR);
    st.registerOutParameter(4,Types.VARCHAR);
    st.registerOutParameter(5,Types.VARCHAR);
    st.registerOutParameter(6,Types.VARCHAR);
    // 4. Set the bind values of the IN parameters
    st.setString(1,numPlates);
    // 5. Execute the statement
    st.executeUpdate();
    // 6. Create a bean to hold the multiple return values
    ProRecallPlatesBean result = new ProRecallPlatesBean();
    // 7. Set values of properties using OUT params
    result.setSpfVal(st.getString(2));
    result.setTransportTypeVal(st.getString(3));
    result.setTransportCompanyVal(st.getString(4));
    result.setCompanyDescrVal(st.getString(5));
    result.setDGAPrint(st.getString(6));
    // 8. Return the result
    return result;
    } catch (SQLException e) {
    throw new JboException(e);
    } finally {
    if (st != null) {
    try {
    // 9. Close the JDBC CallableStatement
    st.close();
    catch (SQLException e) {}
    In Jdeveloper I went into AppModule.xml JAVA>Client Interface section and expose "getCallProRecallPlates" Then I can see "getCallProRecallPlates" in Data Controls, I drag and drop it to a JSF page, an input text component and a button are generated in order to put in there the procedure input parameter (numPlates).
    I don't know if I'm on the right track.
    When I click the button, the "result" variable is supposed to be filled with data from the stored procedure. I want each of those values to be displayed in Output text or input text adf components but I dont know how. Thank you very much in advance I´m a newbie and i'll appreciate your help!

    What version are you on?
    Works fine for me on my 11g:
    SQL> create or replace procedure testxml (clob_out out clob)
      2  is
      3     l_clob   clob;
      4     l_ctx    dbms_xmlquery.ctxhandle;
      5  begin
      6     l_ctx := dbms_xmlquery.newcontext ('select * from dual');
      7     l_clob := dbms_xmlquery.getxml (l_ctx);
      8     clob_out := l_clob;
      9     dbms_xmlquery.closecontext (l_ctx);
    10  end testxml;
    11  /
    Procedure created.
    SQL>
    SQL> variable vout clob;
    SQL>
    SQL> exec testxml (:vout)
    PL/SQL procedure successfully completed.
    SQL>
    SQL> print vout
    VOUT
    <?xml version = '1.0'?>
    <ROWSET>
       <ROW num="1">
          <DUMMY>X</DUMMY>
       </ROW>
    </ROWSET>But definitely you can optimize your proc a bit: Try
    create or replace procedure testxml (clob_out in out nocopy clob)
    is
       l_ctx    dbms_xmlquery.ctxhandle;
    begin
       l_ctx := dbms_xmlquery.newcontext ('select * from dual');
       clob_out := dbms_xmlquery.getxml (l_ctx);
       dbms_xmlquery.closecontext (l_ctx);
    end testxml;
    /

  • How can I use a button to trigger a SQL Stored Procedure?

    I have a stored procedure (UpdateAdsUsers) that performs updates on multiple tables all tied together with one
    parameter - @username
    (I'm using DWCS5, SQL SERVER 2008, ASP VB)
    UPDATE users SET defaultview='0' WHERE user_name=@username
    UPDATE db_settings SET valuestr='MM/DD/YYYY' WHERE keyword='dateformat' AND user_name=@username
    UPDATE db_settings SET valuestr='Y' WHERE keyword='COPY_MSG_VIA_EMAIL' AND user_name=@username
    UPDATE db_settings SET valuestr='4' WHERE keyword='web_download_rend' AND user_name=@username
    UPDATE db_settings SET valuestr='Y' WHERE keyword='cpy_confirm' AND user_name=@username
    UPDATE db_settings SET valuestr='WLPG:12' WHERE keyword='INITIAL_ASSETS' AND user_name=@username
    UPDATE db_settings SET valuestr='20' WHERE keyword='thumb_disp_row' AND user_name=@username
    UPDATE db_settings SET valuestr='20' WHERE keyword='text_disp_row' AND user_name=@username
    UPDATE db_settings SET valuestr='5' WHERE keyword='para_disp_row' AND user_name=@username
    UPDATE db_settings SET valuestr='a.editorial.company_name' WHERE keyword='sortorder1' AND user_name=@username
    UPDATE db_settings SET valuestr='a.editorial.title' WHERE keyword='sortorder2' AND user_name=@username
    UPDATE db_settings SET valuestr='a.editorial.production_type' WHERE keyword='sortorder3' AND user_name=@username
    UPDATE tnailview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='adsx_type', fourth_field='adsx_status' WHERE user_name=@username
    UPDATE textview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='title_desc', fourth_field='production_type', fifth_field='audio_summary', sixth_field='totalruntime', seventh_field='adsx_type', eighth_field='adsx_status' WHERE user_name=@username
    UPDATE paraview_fields SET rendition='1', first_field='company_name', second_field='title', third_field='title_desc', fourth_field='production_type', fifth_field='audio_summary', sixth_field='totalruntime', seventh_field='adsx_type', eighth_field='adsx_status' WHERE user_name=@username
    SELECT * FROM adsx_preferences WHERE user_name=@username
    This functions perfectly in SQL.
    Using Dreamweaver CS5, I've added the Procedure as a Command (ADS_User) with the one variable (@username).
    <%
    set ADS_User = Server.CreateObject("ADODB.Command")
    ADS_User.ActiveConnection = MM_ADSX_STRING
    ADS_User.CommandText = "dbo.UpdateAdsUser"
    ADS_User.Parameters.Append ADS_User.CreateParameter("@RETURN_VALUE", 3, 4)
    ADS_User.Parameters.Append ADS_User.CreateParameter("@username", 129, 1,32,ADS_User__username)
    ADS_User.CommandType = 4
    ADS_User.CommandTimeout = 0
    ADS_User.Prepared = true
    ADS_User.Execute()
    %>
    In a perfect world, either an image click or a form submit would run the procedure.  The parameter (@username) is currently sent to the page as a URL Querystring of the same name.
    I'm sure it's something obvious, but I'm new.
    Thanks in advance

    I'm not sure what your question is. Is this currently failing? Or are you not able to figure out how to send the username to the script page? You really just need to create a form and pass the value in a form field.
    >The parameter (@username) is currently sent to
    >the page as a URL Querystring of the same name.
    Never use a querystring to update data. It is too dangerous. Use the post method instead.

  • How do you send a date from java to a stored procedure

    Oracle 8.0.5
    using thin drivers
    I'm trying to pass a date to a stored procedure. Does anybody
    have an example of how to do this.
    I want to send a month-day-year 01/01/1999 to oracle to be
    inserted into the table. what should the java code look like?
    and what should the (in) line look like in oracle.
    Thanks
    Kirk
    null

    Wow. You got me there.  All of the pdfs that i have, when i tap that icon, open a drop down window with the choices of e mail or print.  I wonder if the particular pdf you are working on is somehow protected?  Try a different pdf and see if the box recats the same way.   You might also do a full shut down and just try again.  Make sure there is not an old instance of i books, or some other pdf editor sitting in the task bar, by doblue clicking the home button, and shutting down any open apps.

  • How to retrieve 'long' column with 32K length in Java stored procedure

    For some reasons, we are not using CLOB, BLOB, or BFILE to store large objects and I have to live with LONG. So I wrote a Java stored procedure to insert, select and manipulate a LONG column by retrieving the LONG into a java.lang.String class (which happens to be the Java class mapped to the LONG SQL datatype). It all works fine as long as the length of the value being retrieved is less than the magic figure of 32767 bytes (which is the restriction on LONG and VARCHAR2 datatype in PL/SQL as well). So looks like Oracle's implementation of the JVM limits String values to a max of 32767 bytes. Suggestions on how to overcome this limitation (other classes that you suggest or do I have to move to files)?
    Thanks,
    Jeet
    null

    the jvm has nothing to do with it ...
    this is a pol/sql limitation on parameters in stored procedures.
    and java stored procedures require a clal spec that makes the j-s-p look like a pl/qsl stored proc.

Maybe you are looking for

  • How to add related fields from one transaction to other transacction?

    Hi all, I have a problem. I need to add an OPPORTUNITY field (SALESCYCLE) to the ACTIVITY transaction because of an upgrade and I'm now in a new world... The CRM 2007 is an unexplored place to me. I added some custom fields (Z fields from the CUSTOME

  • IPhoto won't open because of problem 10.6.8

    Recently my iTunes and iPhoto stop opening on my Macbook Pro running 10.6.8 Every time I open either one, it crashes and i get this notification saying there's a problem. Any idea on how i can reinstall or fix the problem without the startup disc? He

  • Order by taking too much time. Tried using all_rows hints no use.Pls advice

    I run the query without order by and finishes in less than 30 sec. Once you have order by,query just hangs. Pls advice. Thanks. select col4,col6 from table a , table b, table c where a.col1 = b.col2 and a.col1 = c.col3 order by col1,col2 desc

  • Can't print with Adobe Reader 9.4.1

    I have an Apple Computer.  I can't print any PDF documents with Adobe 9.4.1 For the last couple weeks, I get the error message (from my Epson printer) says: pstopdffilter/pstocupsraster failed with err number 13 This has never been a problem before. 

  • Why do I get, 'Sorry, I could not process the following files:' ?

    Working in Photoshop CS6 Extended - Think I've done everything right, including setting the action (see images)!  I go to Scripts > Image Processor > Select Folder > Save in same location > Select file type + quality > Run action.  New JPG folder IS