Using a Collection of beans to store a result set help.

Does anyone have any sample code on the subject? This is something I wrote up, but I wanted feedback, and also an example of how to retreive data out of the array of beans in jsp
package beanpersonal;
import beandatabase.DBConnection;
import java.sql.Connection;
import java.sql.SQLException;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
import java.util.Collection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
public class PersonNew {
public PersonNew() { }
public Collection getPersondata( String alias, String password ) {
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Collection retValue = new ArrayList();
String query = "SELECT * FROM person WHERE (alias = ?, password = ?)";
try {
conn = DBConnection.getDBConnection();
stmt = conn.prepareStatement( query );
stmt.setString( 1, alias );
stmt.setString( 2, password );
rs = stmt.executeQuery();
while (rs.next()) {
PersonalInfo beanrow = new PersonalInfo();
beanrow.setAlias(rs.getString("alias"));
beanrow.setPassword(rs.getString("password"));
retValue.add(beanrow);
return retValue;
catch( SQLException sqle ) {
//sqle.printStackTrace();
//throw new ApplicationSpecficException("Cannot query db", sqle);
throw new RuntimeException(sqle);
finally {
try {if (rs != null) rs.close();} catch (SQLException e) {}
try {if (stmt != null) stmt.close();} catch (SQLException e) {}
try {if (conn != null) conn.close();} catch (SQLException e) {}
}

sorry i only view the codes, but don't read it as a whole maybe this codes can help you..
jsp:
<%@ page contentType="text/html;charset=windows-1252"%>
<%@page import="java.util.*,mypackage.TestBean"%>
<%
String name = request.getParameter("name")!=null?request.getParameter("name"):"";
String age = request.getParameter("age")!=null?request.getParameter("age"):"";
System.out.println(name);
System.out.println(age);
Collection col = new ArrayList();
col = (Collection)session.getAttribute("col")!=null?(Collection)session.getAttribute("col"):new ArrayList();
TestBean tBean = new TestBean();
if(!name.equals(""))
  tBean.setName(name);
if(!age.equals(""))
  tBean.setAge(age);
if(!age.equals("") || !name.equals(""))
  col.add(tBean);
session.setAttribute("col",col);
%>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"/>
    <title>untitled</title>
  </head>
  <body>
    <form>
      <table cellspacing="0" cellpadding="0" border="1" width="200">
        <tr>
          <td>Name</td>
          <td>
            <input type="text" name="name"/>
          </td>
        </tr>
        <tr>
          <td>Age</td>
          <td>
            <input type="text" name="age"/>
          </td>
        </tr>
        <tr>
          <td colspan="2">
            <input type="submit" value="Submit"/>
          </td>
        </tr>
      </table>
      <%
      if(col.size()>0){
      Iterator iter = col.iterator();
      %>
      <table cellspacing="0" cellpadding="0" border="1" width="200">
        <tr>
          <td>
            NAME
          </td>
          <td>
            AGE
          </td>
         </tr>
        <%while(iter.hasNext()){
          tBean = (TestBean)iter.next();
        %>
          <tr>
            <td>
              <%=tBean.getName()%>
            </td>
            <td>
              <%=tBean.getAge()%>
            </td>
           </tr>
        <%}%>
      </table>
      <%}%>
    </form>
  </body>
</html>TestBean.java
package mypackage;
public class TestBean
  private String name;
  private String age;
  public TestBean()
  public String getName()
    return name;
  public void setName(String name)
    this.name = name;
  public String getAge()
    return age;
  public void setAge(String age)
    this.age = age;
}

Similar Messages

  • HT5616 I can not use my icloud email in app Store in August please help

    I can not use my icloud email in app Store in August please help ?!?

    Try contacting app store support:
    http://www.apple.com/support/mac/app-store/contact/
    We are just other users like you and cannot help with payment/financial matters.

  • Can i store the Result set values as a Session variable

    hai,
    I want the result set values of a query to be used many times and I want the same resultset between different page calls.
    I want all those records fetched from the database to be available in the next page with out refetching from the database.
    can any one help me out. its very urgent.....
    Thanks and regards,
    Ravikiran
    mail to me at : [email protected]

    "can i store the Result set values as a Session variable "
    Practically Yes u can
    but u want be able to accesses it in other pages
    u can try it and see
    the other thing u can do is store the values from the resultset in a object say vector and put vector in seesion and u can use this any where
    for e.g
    Vector v=new Vector();
    While(rs.next())
    v.addElement(rs.getString(1));
    v.addElement(rs.getString(2));
    session.putValue("myVector",v);
    now where u want to get it do this
    Vector myvec=(Vector)session.getValue("myVector");
    do do futher

  • Using RAW in Jave Bean to store data in Oracle 8i database

    I have a question about using RAW in java program to read write data in Oracle database. Is there any sample with key information for me to refer to? Your help will be appreciated.
    Jane

    I have a question about using RAW in java program to read write data in Oracle database. Is there any sample with key information for me to refer to? Your help will be appreciated.
    Jane Jane,
    here is a code snippet provided by our QA team
    hope it helps
    Kuassi
    1. Create the table:
    "CREATE TABLE rawtable (key VARCHAR2(30), rawcol RAW(2000), longrawcol
    LONG RAW, moredata VARCHAR2(100))"
    2. Write the data:
    byte x[] = {1,2,3,4,5};
    byte y[]= {6,7,8,9,10};
    PreparedStatement pstmtR =
    conn.prepareStatement("INSERT INTO rawtable (key, rawcol,
    longrawcol, moredata) VALUES (?, ?)");
    pstmtR.setString(1, "rawcol data");
    pstmtR.setBytes(2, x);
    pstmtR.setNull(3, Types.LONGVARBINARY);
    pstmtR.setString(4, "Here's some more data!");
    pstmtR.execute();
    pstmtR.setString(1, "longrawcol data");
    pstmtR.setNull(2, Types.BINARY);
    pstmtR.setBytes(3, y);
    pstmtR.setString(4, "Here's some more data!");
    pstmtR.execute();
    pstmtR.setRAW(1, RAW_obj) can be used to insert the RAW data.
    You can also use setBinaryStream to insert RAW data:
    CallableStatement cstmt =
    conn.prepareCall ("begin insert into rawtab values (?,?); end;");
    cstmt.setBinaryStream (1, (java.io.InputStream) new
    ByteArrayInputStream(rawbuf), rawbuf.length);
    cstmt.setBinaryStream (2, (java.io.InputStream) new
    ByteArrayInputStream(lrawbuf), lrawbuf.length);
    3. Read the data:
    InputStream is = null;
    byte rawbuf [];
    byte lrawbuf [];
    ResultSet rset = stmt.executeQuery("SELECT rawcol, longrawcol FROM
    rawtable");
    // You can retrieve the data with the following methods
    rawbuf = rset.getBytes(1);
    lrawbuf = rset.getBytes(2);
    RAW raw1 = rset.getRAW(1);
    is = rset.getBinaryStream(column);
    is = rset.getAsciiStream(column);
    is = rset.getUnicodeStream(column);
    When using CallableStatement:
    ((OracleCallableStatement)cstmt).registerOutParameter(1,
    OracleTypes.RAW);

  • Using a variable in SQL to store intermediate results

    I'm new to Crystal Reports, so pardon my ignorance.
    I need to write a SQL statement in Crystal Reports (Ver. 11) that uses results from a query and stores them in a variable for further use in the statement. Something like this:
    DECLARE @my_variable INT;
    SET @my_variable=
    CASE
                    WHEN DATEPART (m,{?Date})<7
                    THEN DATEPART (yyyy,( DATEADD (year,-1, {?Date})))
                    ELSE DATEPART (yyyy,( DATEADD (year,0, {?Date})))
    END
    (Where {?Date} is a date parameter)
    Is it possible to achieve this in the above form or some other form in Crystal Reports?
    Thanks

    Simple answer... When I used the variable, I marked it as a string.  There is an email address setting.

  • How to Store the result sets of a stored procedure that is returning more that one result set in two different table ?

    Hi Experts,
       I have on stored procedure which returns mote than one resultset i want that to store in two different temp table how can achieve this in SQL server.
     following is the stored procedure and table that i need to create.
    create procedure GetData as begin select * from Empselect * from Deptend 
    create table #tmp1 (Ddeptid int, deptname varchar(500),Location varchar(100))
    Insert into #tmp1 (Ddeptid , deptname ,Location )
    exec GetData
    create table #tmp (empid int , ename varchar(500),DeptId int , salary int)
    Insert into #tmp (empId,ename,deptId,salary)
    exec GetData
    Niraj Sevalkar

    You cant get two resultsets out of SP like this. The workaround is to merge and bring the resultsets.
    For this number of columns as well as corresponding datatypes have to be compatible. Also you will need one additional column which indicates resultset value. Then use this as filter to get your desired resultset out
    create procedure GetData as
    begin
    select 'resultset1' as Cat,*,.. N columns from Emp
    union all
    select 'resultset2' as Cat,*,.. N columns from Dept
    end
    create table #tmp1 (Ddeptid int, deptname varchar(500),Location varchar(100))
    Insert into #tmp1 (Ddeptid , deptname ,Location )
    Select column1,column2,column3
    from OPENROWSET('SQLOLEDB','Data Source=Server_name;Trusted_Connection=yes;
    Integrated Security=SSPI','Execute yourdb..GetData')
    WHERE Cat = 'resultset1'
    create table #tmp (empid int , ename varchar(500),DeptId int , salary int)
    Insert into #tmp (empId,ename,deptId,salary)
    Select column1,column2,column3, column4
    from OPENROWSET('SQLOLEDB','Data Source=Server_name;Trusted_Connection=yes;
    Integrated Security=SSPI','Execute yourdb..GetData')
    WHERE Cat = 'resultset2'
    also see
    http://sqlblogcasts.com/blogs/madhivanan/archive/2007/11/26/select-columns-from-exec-procedure-name-is-this-possible.aspx
    Another method is to populate table with relevant resultset within procedure itself and then select from the table directly outside.
    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

  • SQL Query - store the result for optimization?

    Good day experts,
    I am looking for advice on a report. I did a lot of analytic functions to get core data that I need to make my report and its takes around 50 min for SQL to complete. Now with this data I need to create 3 different reports and I cant use the same SQL since there is a lot of agregation (example would be group by product in one case and by client in 2nd). For each of those different group bys I need a different report.
    So how to create 3 reports from 1 SQL query without running the query 3 times?
    First thing that comes to mind is to store the result set into a dummy table and then query the table since the core data I get is around 300 rows and then do different group bys.
    Best regards,
    Igor

    So how to create 3 reports from 1 SQL query without running the query 3 times?
    You already know the obvious answer - store the data 'somewhere'.
    The appropriate 'somewhere' depends on your actual business requirements and you did not provide ALL of them.
    MV - if the query is always the same you could use an MV and do a complete refresh when you want new data. The data is permanent and can be queried by other sessions but the query that accesses the data will be frozen into the MV definition.
    GTT (global temp table) - if a NEW data load AND the three reports will ALWAYS be executed by a single session and then the data is NOT needed anymore then a GTT can work. The query that loads the GTT can be different for each run but the data will only be available for a single session and ONLY for the life of that session. So if anything goes wrong and the session terminates the data is gone.
    First thing that comes to mind is to store the result set into a dummy table and then query the table since the core data I get is around 300 rows and then do different group bys.
    That is commonly referred to as a 'REPORT-READY table'. Those are useful when the data needs to be permanent and available to multiple sessions/users. Typically there is a batch process (e.g. package procedure) that periodically refreshes/updates the data during an outage window. Or the table can have a column (e.g. AS_OF) that lets it contain multiple sets of data and the update process leaves existing data alone and creates a new set of data.
    If your core data is around 300 rows you may want to consider a report-ready table and even using it to contain multiple sets of data. Then the reports can be written to query the data using an AS_OF value that rolls up and returns the proper data. You don't need an outage window since older data is always available (but can be deleted when you no longer need it.
    If you only need one set of data you could use a partitioned work table (with only one partition) to gather the new set of data and then an EXCHANGE PARTITION to 'swap' in the new data. That 'exchange' only takes a fraction of a second and avoids an outage window. Once the swap is done any user query will get the new data.

  • Can we store result set in session..??

    can we store result set object in session..??if yes ,,say i close the connection and use that result set object in some another page,,what happen if u call updateRow(),deleteRow() or insertRow()

    You can store a result set object in session.
    However you also have to keep that result sets connection open and dedicated to that result set.
    In that scenario you will have a 1 db connection per session. Not very nice. And NOT recommended.
    Once you close a ResultSet's connection then you shouldn't access the ResultSet. Simple as that.

  • Store result set in to cache

    i want to store some result set(select clause) into cache and reuse into latter part.
    kindly help me out.(oracle 10g)
    Edited by: anutosh on Oct 12, 2009 6:11 AM

    i am inserting value into 2 tables
    'INSERT INTO ' ||
    in_fct_table ||
    ' NOLOGGING SELECT * FROM ' ||
    in_fct_table ||
    '_STG PARTITION(' ||
    f_pop_partition.partition_name ||
    ') LOG ERRORS INTO ' ||
    in_fct_table ||
    '_D(''' ||
    f_pop_partition.partition_name ||
    ''') REJECT LIMIT UNLIMITED';
    duplicates data stored in <_ d> (suffix) table and remaining data(without duplicate) want to store in in_fct_tables(variable name) based on some partition.
    data from in_fct_tables(variable name) table want to populate into some other table . so for that we need to capture the data from in_fct_table.

  • How to get a collection of beans using web services

    Hi,
    I'm new to SOAP and Web Services I'd like to know whether the following is possible
    or not.
    I've created an EJB with this business interface:
    public interface Users implements EJBObject {
    public User[] getUsers( ) ...
    Where the User object is a bean with some properties:
    public User implements Serializable {
    public void setName( ... ) ...
    public String getName( ) ...
    public void setAddress( ... ) ...
    public String getAdress( ) ...
    I've create the ejb-jar.xml and weblogic-ejb-jar.xml that contain the definition
    of my EJB and then I try to deploy the web services using the ant task 'wsgen'.
    I get the following exception:
    org.xml.sax.SAXException: Could not find a codec that understood how to convert
    class [LUser; using http://schemas.xmlsoap.org/soap/encoding/
    : [ CodecFactory: http://xml.apache.org/xml-soap/literalxml=null, http://schemas.xmlsoap.org/soap/encoding/=null,
    =null]
    Can someone help to resolve this ? Also, I'd like to know if it's possible that
    a web service return a collection of beans as shown above ?
    Thanks for your help.
    Ludovic.

    Java beans are serialized/deserialized by the soap encoding codec
    itself. you dont have to write custom encoders. I think the error
    is because you dont have the java bean class on the server side.
    Java bean class file should be in the classpath or it should be
    added to the ejb jar file.
    thanks,
    -manoj
    Ludovic Deravet wrote:
    Thanks for your help. Indeed, that was my problem.
    But now I'm facing this one:
    [SOAPException: faultCode=SOAP-ENV:Client; msg=No Deserializer found to
    deserialize a 'urn:local:ns0:return' using encoding style 'http://sch
    emas.xmlsoap.org/soap/encoding/'.;
    targetException=java.lang.IllegalArgumentException: No Deserializer found to
    deserialize a 'urn:local:ns0:
    return' using encoding style 'http://schemas.xmlsoap.org/soap/encoding/'.]
    at org.apache.soap.rpc.Call.invoke(Call.java:246)
    at com.webservices.WSClient.main(WSClient.java:38)
    Did you implement your own deserializer to read your array of beans (called
    Data) ? Or do I need to do something else ?
    Thanks.
    Ludovic.
    "manoj cheenath" <[email protected]> wrote in message
    news:[email protected]...
    You can do this. I guess, the problem is because you have
    not defined a package for the bean.
    Try something like:
    package foo.bar;
    class User{
    I am attaching an example.
    -manoj
    Ludovic Deravet wrote:
    Hi,
    I'm new to SOAP and Web Services I'd like to know whether the following
    is possible
    or not.
    I've created an EJB with this business interface:
    public interface Users implements EJBObject {
    public User[] getUsers( ) ...
    Where the User object is a bean with some properties:
    public User implements Serializable {
    public void setName( ... ) ...
    public String getName( ) ...
    public void setAddress( ... ) ...
    public String getAdress( ) ...
    I've create the ejb-jar.xml and weblogic-ejb-jar.xml that contain thedefinition
    of my EJB and then I try to deploy the web services using the ant task'wsgen'.
    I get the following exception:
    org.xml.sax.SAXException: Could not find a codec that understood how toconvert
    class [LUser; using http://schemas.xmlsoap.org/soap/encoding/
    : [ CodecFactory: http://xml.apache.org/xml-soap/literalxml=null,
    http://schemas.xmlsoap.org/soap/encoding/=null,> > > =null
    Can someone help to resolve this ? Also, I'd like to know if it's
    possible that
    a web service return a collection of beans as shown above ?
    Thanks for your help.
    Ludovic.

  • Using java beans to store records from recordset

    Hi there,
    I have been stuck on an issue with Java Beans in JSP for the last few days and cant get my head around it.
    I am basically trying to retrieve all the records out of a resultset which pulls records from a table through a JDBC connection and store the records in a html table using the java beans getProperty tag.
    Problem is that the first row of the recordset is being applied to every row in the table. I have tried implementing for loops to iterate through the result set but without any luck.
    I need help urgently
    Thank you

    Thanks for the feedback M
    I have added the JSTL 1.1 library and used the Foreach components and data source components which now totally eliminate the need for beans altogether. :P
    <c:forEach var="row" items="${deejays.rows}">
    <tr onmouseover="this.bgColor='gold';"
    onmouseout="this.bgColor='#FFFFFF';">
    <c:forEach var="column" items="${row}">
    <td>
    <c:out value="${column.value}"/>
    </td>
    </c:forEach>
    <td width="24%" align="center">
    <input type="image" src="7af5.jpg" name="test" value="test"/>
    </td>
    <td width="15%">
    <input type="radio" name="book1"/>
    </td>
    </tr>
    </c:forEach>
    </table><p align="left">
    How and where do i add the beans in here now???

  • How do I make a table of contents for a collection of six short stories that is after the legal page and NOT in the front on an unnumbered page?

    How do I make a table of contents for a collection of six short stories that is after the legal page and NOT in the front on an unnumbered page?
    When I first started I made a title page and then pasted in my first story from a .TXT file. After cleaning up I went back to the front a couple of empty lines ahead of the story and typed in the story title.  Unlarged the font size and centered it, then

    You can't do that. This is what the Pages User Guide, downloadable from your Pages Help menu, says:
    Creating and Updating a Table of Contents
    Each table of contents (TOC) you create using a Word Processing template lists only the content that follows it, up until the next table of contents. If you want a master table of contents for the entire document, it must be the only table of contents, and it must be at the beginning of the document.
    You can do it manually though.

  • How to use BULK COLLECT, FORALL and TREAT

    There is a need to read match and update data from and into a custom table. The table would have about 3 millions rows and holds key numbers. BAsed on a field value of this custom table, relevant data needs to be fetched from joins of other tables and updated in the custom table. I plan to use BULK COLLECT and FORALL.
    All examples I have seen, do an insert into a table. How do I go about reading all values of a given field and fetching other relevant data and then updating the custom table with data fetched.
    Defined an object with specifics like this
    CREATE OR REPLACE TYPE imei_ot AS OBJECT (
    recid NUMBER,
    imei VARCHAR2(30),
    STORE VARCHAR2(100),
    status VARCHAR2(1),
    TIMESTAMP DATE,
    order_number VARCHAR2(30),
    order_type VARCHAR2(30),
    sku VARCHAR2(30),
    order_date DATE,
    attribute1 VARCHAR2(240),
    market VARCHAR2(240),
    processed_flag VARCHAR2(1),
    last_update_date DATE
    Now within a package procedure I have defined like this.
    type imei_ott is table of imei_ot;
    imei_ntt imei_ott;
    begin
    SELECT imei_ot (recid,
    imei,
    STORE,
    status,
    TIMESTAMP,
    order_number,
    order_type,
    sku,
    order_date,
    attribute1,
    market,
    processed_flag,
    last_update_date
    BULK COLLECT INTO imei_ntt
    FROM (SELECT stg.recid, stg.imei, cip.store_location, 'S',
    co.rtl_txn_timestamp, co.rtl_order_number, 'CUST',
    msi.segment1 || '.' || msi.segment3,
    TRUNC (co.txn_timestamp), col.part_number, 'ZZ',
    stg.processed_flag, SYSDATE
    FROM custom_orders co,
    custom_order_lines col,
    custom_stg stg,
    mtl_system_items_b msi
    WHERE co.header_id = col.header_id
    AND msi.inventory_item_id = col.inventory_item_id
    AND msi.organization_id =
    (SELECT organization_id
    FROM hr_all_organization_units_tl
    WHERE NAME = 'Item Master'
    AND source_lang = USERENV ('LANG'))
    AND stg.imei = col.serial_number
    AND stg.processed_flag = 'U');
    /* Update staging table in one go for COR order data */
    FORALL indx IN 1 .. imei_ntt.COUNT
    UPDATE custom_stg
    SET STORE = TREAT (imei_ntt (indx) AS imei_ot).STORE,
    status = TREAT (imei_ntt (indx) AS imei_ot).status,
    TIMESTAMP = TREAT (imei_ntt (indx) AS imei_ot).TIMESTAMP,
    order_number = TREAT (imei_ntt (indx) AS imei_ot).order_number,
    order_type = TREAT (imei_ntt (indx) AS imei_ot).order_type,
    sku = TREAT (imei_ntt (indx) AS imei_ot).sku,
    order_date = TREAT (imei_ntt (indx) AS imei_ot).order_date,
    attribute1 = TREAT (imei_ntt (indx) AS imei_ot).attribute1,
    market = TREAT (imei_ntt (indx) AS imei_ot).market,
    processed_flag =
    TREAT (imei_ntt (indx) AS imei_ot).processed_flag,
    last_update_date =
    TREAT (imei_ntt (indx) AS imei_ot).last_update_date
    WHERE recid = TREAT (imei_ntt (indx) AS imei_ot).recid
    AND imei = TREAT (imei_ntt (indx) AS imei_ot).imei;
    DBMS_OUTPUT.put_line ( TO_CHAR (SQL%ROWCOUNT)
    || ' rows updated using Bulk Collect / For All.'
    EXCEPTION
    WHEN NO_DATA_FOUND
    THEN
    DBMS_OUTPUT.put_line ('No Data: ' || SQLERRM);
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.put_line ('Other Error: ' || SQLERRM);
    END;
    Now for the unfortunate part. When I compile the pkg, I face an error
    PL/SQL: ORA-00904: "LAST_UPDATE_DATE": invalid identifier
    I am not sure where I am wrong. Object type has the last update date field and the custom table also has the same field.
    Could someone please throw some light and suggestion?
    Thanks
    uds

    I suspect your error comes from the »bulk collect into« and not from the »forall loop«.
    From a first glance you need to alias sysdate with last_update_date and some of the other select items need to be aliased as well :
    But a simplified version would be
    select imei_ot (stg.recid,
                    stg.imei,
                    cip.store_location,
                    'S',
                    co.rtl_txn_timestamp,
                    co.rtl_order_number,
                    'CUST',
                    msi.segment1 || '.' || msi.segment3,
                    trunc (co.txn_timestamp),
                    col.part_number,
                    'ZZ',
                    stg.processed_flag,
                    sysdate
    bulk collect into imei_ntt
      from custom_orders co,
           custom_order_lines col,
           custom_stg stg,
           mtl_system_items_b msi
    where co.header_id = col.header_id
       and msi.inventory_item_id = col.inventory_item_id
       and msi.organization_id =
                  (select organization_id
                     from hr_all_organization_units_tl
                    where name = 'Item Master' and source_lang = userenv ('LANG'))
       and stg.imei = col.serial_number
       and stg.processed_flag = 'U';
    ...

  • How to use same collection on two forms

    Hi ,
    My issue scenerio is--
    I have two forms one is calling form other is call form. User will go to calling form and press button to open call form. In call form user will select some records. That records i want to store in collection. then user will close call form , and on calling form i want to use those collection values.
    For this i did some coding like
    I created a type in database , then I created a record type in which i stored selected records information. I can see that values have been properly stored in collection till i exit call form.
    Once i am back on calling form it becomes null.
    Please help..
    Regards,
    Kuldeep

    *Before posting on this forum please read*
    >
    I can see that values have been properly stored in collection till i exit call form.
    Once i am back on calling form it becomes null.Hi,
    Do you perform commit_form or commit when/before exit call form ?
    Hope this helps
    If someone's response is helpful or correct, please mark it accordingly.

  • Approach of using Bulk Collect

    Hi Experts,
    how to use bulk collect for uncertain number of columns of select statement.
    Master table structure:
    Create table tabmst
    (id number,
    cls_input varchar2(2000),
    price number);
    insert into tabmst(1,'select product, price from product',500);
    insert into tabmst(2,'select product, price,purchase_dt from product',100);
    insert into tabmst(3,'select * from product',1000);
    Currently I want to store Select statement of cls_input column in a local variable like
    dyn_qry:= cls_input; by using a cursor.
    Now my question is how to use Bulk Collect by using "Execute Immediate" in Bulk collect variable as there is not certainity of the number of columns from "Select Statment". Please suggest.
    Sample code:
    I created TYPE variable for Bulk Collect also support blk_var;
    Declare
    dyn_qry varchar2(3000);
    cursor c1 is select * from tabmst;
    begin
    for i in c1 loop
    dyn_qry:= cls_input;
    Execute immediate dyn_qry into blk_var;
    End Loop;
    End;
    Now I want to store values of Each "Select statements columns" which is executing by dynamic SQL. but it is uncertain that how many columns with return from dynamic SQL.
    Please suggest the approach on the same. Thanks in advance.

    >
    I don't think you can use bulk collect with EXECUTE IMMEDIATE. They do two different things. EXECUTE IMMEDIATE allows the execlution of dynamic SQL. BULK COLLECT provides optimization of SELECT statements when loading the contents into collections. I am not aware of any support for BULK COLLECT with EXECUTE IMMEDIATE.
    You may be able to do this a different way. If you must use dynamic SQL (I suggest you don't unless it is absolutely necessary. Dynamic SQL is hard to write, hard to debug, hard to maintain, and hard to tune) use a reference cursor instead. You can use the BULK COLLECT with the standard fetch.

Maybe you are looking for