Random Database Query Results

Hello, I am not sure if I posted this topic in the right forum but I really need help in this one.
Let's say I have a query for a database and I would only need to display around 10 RANDOM results from my query. How do I do this?
Thanks so much. your help will be very much appreciated.

Depends on how big your table could be and how much effort you want to put into it.
Consider 'Random' as pulling a number out of a hat, reading it out and then putting it back into
the hat.
You need to write the numbers down as they come out, and as you pull a number, check that it's
not on your list. If it is, put it back and try again...
You could use a Vector:
Vector pulledNumbers = new Vector();
Random r = new Random();
int theNumber = -1;
while(theNumber < 0) {
    theNumber = r.nextInt();
    Integer ii = new Integer(theNumber);
    if (pulledNumbers.contains(ii)) {
        theNumber = -1;
    } else {
        pulledNumbers.add(ii);
}But a Set would be easier - just say set.add(ii) and it returns false if the item is in the set

Similar Messages

  • Generate an xml file from Database query results

    Hi, can anyone help me out with this problem I'm having. What are the steps in creating an xml file directly from the results of a database query. I currently have a very simply process that queries a database via a partner link. The query returns the data but it's from this point that I am stuck. I need to create an xml file with the data along with the xml tags. I've looked at dozens of tutorials with no luck.
    I would greatly appreciate help with this.
    bpel rookie

    Should be quite simple.
    Create another partnerlink, configure it to use the file adapter, and write to an XML file. In this case you need to create an XML Schema (.xsd) of the file you want to create.
    Before you write to the file, either add assign steps to copy individual attributes or use a transform activity to convert from the database format to the file (xml) format.

  • How to generate XML file from oracle database query result

    Hi dudes,
    as stated on the subject, can anyone suggests me how can i achieve the task stated above??
    Here is a brief description of my problem:
    I need to create a XML file once i query from the oracle database, and the query result returned from the database will be stored in XML file.
    I'd searched around the JAXB, DOM, SAXP and the like basic concepts, but i still don't know how to start??
    Any suggestions ???

    Read this:
    http://www.cafeconleche.org/books/xmljava/chapters/ch08s05.html
    You might have to read more of the book to understand that chapter.

  • Word Wrap database query results

    In Visual Studio 2005, when you are looking at the results of a database query, or table (show table data) etc., how can you make the results field values wrap like we use to be able to do in VS 2003 and in Visual Interdev.
    If the field values were longer then what was display in the grid output results, you could expand the column width and row height and the field values would wrap to fit.  If I try to do the same thing in VS 2005 or in sql enterprise manager 2005 the field values don't wrap, they remain displayed in one long line and they just get cut off after a specific number of characters.

    I'm a Program Manager on the SQL Server Manageability team.  We own SQL Server Management Studio.  Sorry to hear about your frustration with our product.  The team had many tasks to complete in the SQL Server 2005 timeframe and there are some usability improvements that seem simple and were overlooked.  We are committed to improving our customers' experience with our products.
    I would recommend that you go to http://connect.microsoft.com/SQLServer/ and file this issue.  You'll be able to track it throughout its lifecycle.  Once we have a solution for the scenario, we will let you know which release of SQL Server in which you will be able to see your suggestion.
    So, yes, we are listening :)
    Paul A. Mestemaker II
    Program Manager
    Microsoft SQL Server
    http://blogs.msdn.com/sqlrem/

  • Returning database query results under Apache Axis

    I'm trying to write a web service that will return the results of a standard database query. Does anyone have any pointers on what sort of data structure I should convert my ResultSet to that would be best suited to run under Apache Axis? Currently I am trying to use a String[][][], which Axis can serialize and encode fine, but seems to have problems decoding. If someone has some client-side source that is able to receive a String[][][], please post it, as I would rather not have to change the web services around if at all possible.

    According to IBM, the best way to do this is by returning an array of a complex type. Using this idea, I changed my services to return an array of DBRow objects, which I wrote for this purpose. DBRow is a simple class that contains a single private String[] with get and set accessors, in accordance with the JavaBeans standard. If you need more details, just respond to this topic.

  • Database query results

    I have made a database query:
    try{
    java.lang.Class.forName("oracle.jdbc.driver.OracleDriver");
    Connection con=DriverManager.getConnection("jdbc:oracle:abc@abc","login","pwd");
    HashMap params=new HashMap();
    q=new Query("CORE_SYSTEM/TRN_SHORD_DESC",true);
    dbr=q.executeQuery(params,con);
    taQueryOut.setText(""+q);
    taQueryOut.append(""+dbr);
    }catch(Exception e){
    e.printStackTrace();
    } // end try-catch
    The code is not important, it works.
    What methods are there for me to use for printing out the number of results returned etc. A link to a reference material would be handy too. Note that the database used is Oracle, so if there are any ora-specific functions available, good.

    This is the technique that I use to count rows:
    Quick trick that I use is
    1. make sure that your Statement is type_scroll_insensitive:
    connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
    ResultSet.CONCUR_READ_ONLY);2. move your cursor to the last row(after executing your query)
    resultset.last();3. get the row number:
    int numberOfRows = resultset.getRow(); /*returns the number of rows*/4. set the cursor back to the beginning:
    resultset.beforeFirst();5. ready to process the rows as usual.
    This technique has a drawback though:
    a scrollable resultset has less performance than non-scrollable
    hope this might help,
    Jamie

  • Serializing database query results for use as dataproviders

    I am executing my database queries in Java and passing my results to flex and creating a chart or datagrid based on the results.  The problem is, I don't know how to code this in Java in a way that flex would understand it.  For instance, Flex wants:
    <mx:DataGrid id="dg"  dataProvider="{myArray}">
      <mx:columns>
             <mx:DataGridColumn dataField="column1" />
             <mx:DataGridColumn dataField="column2" />
              <!-- etc ... -->
             <mx:DataGridColumn dataField="columnN" />
          </mx:columns>
    </mx:DataGrid>
    I need to create this table-like array in Java and have it readable as a dataprovider by flex.  I know about ArrayCollections and Java ArrayLists can be nicely converted to this in Flex, but I just don't know how to create them with a column1, column2, etc. when I don't know from query to query how many columns will be in my results.
    Any help would be greatly appreciated!

    You don't know in advanced the columns that your queries will return? 
    Or the number of records?
    Sincerely,
    Michael
    El 30/04/2009, a las 13:47, Cr99 <[email protected]> escribió:
    >
    I am executing my database queries in Java and passing my results to 
    flex and creating a chart or datagrid based on the results.  The 
    problem is, I don't know how to code this in Java in a way that flex 
    would understand it.  For instance, Flex wants:
    >
    <mx:DataGrid id="dg"  dataProvider="">
      <mx:columns>
             <mx:DataGridColumn dataField="column1" />
             <mx:DataGridColumn dataField="column2" />
              <!-- etc ... -->
             <mx:DataGridColumn dataField="columnN" />
          </mx:columns>
    </mx:DataGrid>
    >
    I need to create this table-like array in Java and have it readable 
    as a dataprovider by flex.  I know about ArrayCollections and Java 
    ArrayLists can be nicely converted to this in Flex, but I just don't 
    know how to create them with a column1, column2, etc. when I don't 
    know from query to query how many columns will be in my results.
    >
    Any help would be greatly appreciated!
    >

  • Access database query resultset in java scriptlet

    Question:
    1) I am Creating a web page and plotting points on the page:
    2) Database query results in decimal values dec_latitude and dec_longiitude.
    3) Perform calculations on lati. & long. in a java scriptlet to create a plot position (xpos, ypos).
    4) Send the xpos and ypos back to the java server page
    5) Use <IMG and absolute positioning to plot the point at position xpos, and ypos.
    6) Repeat until all rows in the query result set have been plotted.
    I don't know how to pass the dec_latitude and dec_longitude to the java scriptlet.
    After the java scriptlet calculation translates the latitude and longitude
    into xpos and ypos, I need to pass the xpos and ypos back to the java server page so that a data point is plotted on a map at position xpos, ypos.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    The code below results in a runtime error.
    Am I supposed to create a java object and access that in the java scriptlet? Can the java scriptlet access the latvar and longvar created during the "<c:set var="latvar"... ?
    If not, what mechanisum do I use to access the resulting colums: dec_latitude and dec_longitude? I need the java scriptlet to convert the
    dec_latitude and dec_longitude into a display position based on the number of pixels from the TOP and LEFT (xpos, ypos). Then plot of the data point using the IMG and (xpos, ypos). This will overlay a map whose z-index is lower than the plotted data point.
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar"); <--- runtime error !!!!
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    </c:forEach>

    Thanks
    I still get a runtime error: I translated the code you gave to code below .... which I think is equivalent. See Below: I'm still learning about this stuff so I may not have not translated this properly. Do
    you see what I am doing wrong?
    Best Regards,
    - John
    %@ page language="java" contentType="text/html;
    charset=ISO-8859-1"%>
    <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ page import="java.lang.Math"%>
    <sql:setDataSource dataSource="jdbc/SampleDB" />
    <c:set var="genus_name" value="${param.genus_name}" />
    <c:set var="species_name" value="${param.species_name}" />
    <c:set var="species_common_name" value="${param.species_common_name}" />
    <c:set var="dd_sighted" value="${param.dd_sighted}" />
    <c:set var="mm_sighted" value="${param.mm_sighted}" />
    <c:set var="yyyy_sighted" value="${param.yyyy_sighted}" />
    <c:set var="species_state" value="${param.species_state}" />
    <c:set var="species_county" value="${param.species_county}" />
    <c:set var="species_country" value="${param.species_country}" />
    <c:set var="dec_latitude" value="${param.dec_latitude}" />
    <c:set var="dec_longitude" value="${param.dec_longitude}" />
    <c:set var="notes" value="${param.notes}" />
    <c:set var="person_first_name" value="${param.person_first_name}" />
    <c:set var="person_last_name" value="${param.person_last_name}" />
    <c:set var="person_street" value="${param.person_street}" />
    <c:set var="person_city" value="${param.person_city}" />
    <c:set var="person_state" value="${param.person_state}" />
    <c:set var="person_zip" value="${param.person_zip}" />
    <c:set var="person_country" value="${param.person_country}" />
    <c:set var="person_email" value="${param.person_email}" />
    <h2>Species Sightings:</h2>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Breckenridge Citizen Bio-Survey Selective Output Page</title>
    </head>
    <body>
    Izaak Walton League of America
    <h1>Breckenridge Citizen Bio-Survey Selective Output</h1>
    <HR>
    <c:if test="${param.action == 'Submit'}">
    <%int xpos = 0;
         int ypos = 0;
         float latitude = 0.0F;
         float longitude = 0.0F;
         float latitudeMpls = 45.06F;
         float longitudeMpls = -93.14F;                    int xposMpls = 1205 - (int) Math.round(latitudeMpls);
         int yposMpls = 735 + (int) Math.round(longitudeMpls);
    %>
    <IMG SRC="minnesota_1990.jpg" ALT="minesota map" style="z-index:1;"> <----- THIS WORKS FINE
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2"> <----- THIS WORKS FINE FOR HARDCODED MPLS XPOS AND YPOS
    <sql:query var="qryBio">
    SELECT
    PERSON_FIRST_NAME,
    PERSON_LAST_NAME,
    GENUS_NAME,
    SPECIES_NAME,
    SPECIES_COMMON_NAME,
    SPECIES_COUNTY,
    SPECIES_STATE,
    SPECIES_COUNTRY,
    DD_SIGHTED,
    MM_SIGHTED,
    YYYY_SIGHTED,
    DEC_LATITUDE,
    DEC_LONGITUDE,
    NOTES,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    genus_name like rtrim(upper('${genus_name}')) AND
    species_name like rtrim(upper('${species_name}')) AND
    species_common_name like rtrim(upper
    ('${species_common_name}')) AND
    species_state like rtrim(upper('${species_state}')) AND
    species_county like rtrim(upper('${species_county}')) AND
    species_country like rtrim(upper('${species_country}')) AND
    person_first_name like rtrim(upper('${person_first_name}')) AND
    person_last_name like rtrim(upper('${person_last_name}')) AND
    person_email like rtrim(upper('${person_email}'))
    </sql:query>
    <c:forEach var="row" items="${qryBio.rows}">
    <--- THE LINE ABOVE WORKS FINE --->
    <c:set var="latvar" value="${row.dec_latitude}" scope="page" />
    <c:set var="longvar" value="${row.dec_longitude} " scope="page" />
    <%
    latitude =
    Float.parseFloat((String)pageContext.getAttribute("latvar"));
    <--- RUNTIME ERROR OCCURS HERE --- SEE LINE ABOVE --->
    longitude =
    Float.parseFloat((String)pageContext.getAttribute("longvar"));
    xpos = (int) Math.round(latitude);
    ypos = (int) Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    request.setAttribute("xpos",new Integer(xpos));
    request.setAttribute("ypos",new Integer(ypos));
    %>
    IIMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xpos%> px;
    left:<%=ypos%> px;
    z-index:2">
    <--- THIS (ABOVE) WORKS FINE WITH CORRECT VALUES FOR XPOS AND YPOS WHEN RUNTIME ERROR DOES NOT OCCUR --->
    </c:forEach>
    </c:if>

  • Access database query data in Java SCriptlet

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar");
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

    Question:
    Creating a web page and plotting points on the page:
    1) Database query results in decimal values latitude and longitude.
    2) Perform calculations on lati. & long. in a <% java scriptlet %>
    I don't know how to pass the data back and forth between the
    java server page and the java scriplet.
    After the calculation translates the latitude and longitude
    into xpos and ypos, a data point is plotted on a map.
    I tried many ways of doing it but am just guessing as
    to how to pass the data.
    Thanks in Advance. - John
    Here is what I am trying so far .... see snippet below:
    *** Query the database ***
    <sql:query var="qryBio">
    SELECT
    DEC_LATITUDE,
    DEC_LONGITUDE,
    ENTRY_TIMESTAMP
    FROM app.biosurvey where
    </sql:query>
    *** for each row retreived from the database ***
    <c:forEach var="row" items="${qryBio.rows}">
    <c:set var="latvar" value="${row.dec_latitude}" scope="page"/>
    <c:set var="longvar" value="${row.dec_longitude} "scope="page" />
    *** java code scriptlet - ***
    *** convert latitude and longitude to xpos and ypos for display ***
    <%
    latitude = (Float)pageContext.getAttribute("latvar");
    longitude = (Float)pageContext.getAttribute("longvar");
    xpos = (int)Math.round(latitude);
    ypos = (int)Math.round(longitude);
    xpos = 1082 - xpos;
    ypos = 700 + ypos;
    pageContext.setAttribute("xpos", xpos);
    pageContext.setAttribute("ypos", ypos);
    %>
    *** plot a point on the display html page overlaying the map ***
    <IMG ID="Row" SRC="smallredbox.jpg" ALT="red box"
    STYLE="position:absolute;
    top:<%=xposMpls%> px;
    left:<%=yposMpls%> px;
    z-index:2">
    </c:forEach>

  • How to display result of database query in JFrame?

    How to display result of oracle database query in JFrame?
    This is part of my code:
    String username, password;
              DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
              OracleConnection conn = DriverManager.getConnection(String url, String username, String password);
    Statement s= conn.createStatement();
    ResultSet q= s.executeQuery("SELECT A, B, C FROM TABLE X");
    Forget what url, username & password are. Is there any problem with my code?
    What should be next if I want to display result of the query in a table in JFrame?Thx !

    How to create JTable with unknown no. of rows? How to get no. of rows of a query?
    I saw the demo of creating JTable on java.sun.com but the the table has a certain no. of rows which is not applicable to my case.
    Suppose the result of query is a table with 3 attributes so there are 3 columns in the table.
    R contains the result of the query.
    Should it be something like this if I want to create JTable of the query?
    How to make n rows of {R.getString(1),R.getString(2),R.getString(3)};?
    public SimpleTableDemo() {
    super(new GridLayout(1,0));
    String[] columnNames = {"A",
    "B",
    "C",
    while (R.next())
    // content of a row
    Object[][] data = {R.getString(1),R.getString(2),R.getString(3)};
    I can't run it because I still can't debug my code which is said before.
    Thx!

  • Get a random value out of a query result

    I have a query:
    select id
    from class_schedule
    where id not in (
    select distinct(event_id) from trainer_schedule)I want to pick up a random value from this query result and assign it to a varible e.g. randomID.
    please help

    here is the example
    SQL> SELECT empno,ename
      2  FROM (
      3    SELECT empno,ename
      4    FROM EMP
      5    ORDER BY dbms_random.VALUE)
      6  WHERE ROWNUM = 1;
          7876 ADAMS
    SQL> /
          7566 JONES
    SQL> /
          7900 JAMES
    SQL> /
          7844 TURNER
    SQL>

  • Returning the result of a database query to a client

    glassfish
    JAX-WS 2.0
    NetBeans 5.5
    Is it possible to send a CachedRowSet object to a client?
    I get an error when i try to do so. (I can't deploy the web service method that returns the CachedRowSet)
    Is there a better way to return the result of database query to a client?
    I'd appreciate any suggestions or sample code.

    Hi!
    The result of this query will be the max ID of users' IDs.
    Let say we have:
    String sql="select max(users.id) from users";
    Statement st = ctx.conn.createStatement();
    ResultSet rs = st.executeQuery(sql);
    rs.next();     
    So you can get the max Id in the following way:     
    int maxId=rs.getInt("id");
    Regards,
    Rossi

  • Random results with  random access query

    Hi,
    when I execute a random access query
    (fetchConfig.setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
    fetchConfig.setFetchDirection(ResultSet.FETCH_UNKNOWN)) and iterate over the
    result set twice, the second time the objects are retrieved in a different
    order, also when I set the ordering of the objects. This only happens if the
    first loop touches the last item. If not, everything works fine. I am using
    MS Sql Server, microsoft driver, kodo 3.4
    regards,
    Christiaan

    Hi,
    I am using datastore identity. I do implement equals and hashcode in the
    super class, not sure whether that is of any impact. The order of the items
    look random to me, however it stays constant after the second loop. The same
    order is also produced when I re-start the test application. The output
    shows the index of the object I am retrieving, the description of the object
    (which is also the order in which the items are created) and their order
    attribute. The query sorts on the order attribute. As you can see the first
    loop is correct. I now and then have the situation where the last item in
    the first loop (retrieve 7) results in the first item (item nr 0) being
    retrieved. Same behaviour applies for both jtds and microsoft driver.
    first loop:
    retrieve 0: item nr: 0 order: 0
    retrieve 1: item nr: 1 order: 1
    retrieve 2: item nr: 2 order: 2
    retrieve 3: item nr: 3 order: 3
    retrieve 4: item nr: 4 order: 4
    retrieve 5: item nr: 5 order: 5
    retrieve 6: item nr: 6 order: 6
    retrieve 7: item nr: 7 order: 7
    second loop
    retrieve 0: item nr: 3 order: 3
    retrieve 1: item nr: 6 order: 6
    retrieve 2: item nr: 7 order: 7
    retrieve 3: item nr: 0 order: 0
    retrieve 4: item nr: 5 order: 5
    retrieve 5: item nr: 4 order: 4
    retrieve 6: item nr: 2 order: 2
    retrieve 7: item nr: 1 order: 1
    third loop
    retrieve 0: item nr: 3 order: 3
    retrieve 1: item nr: 6 order: 6
    retrieve 2: item nr: 7 order: 7
    retrieve 3: item nr: 0 order: 0
    retrieve 4: item nr: 5 order: 5
    retrieve 5: item nr: 4 order: 4
    retrieve 6: item nr: 2 order: 2
    retrieve 7: item nr: 1 order: 1
    "Marc Prud'hommeaux" <[email protected]> wrote in message
    news:[email protected]...
    Christiaan-
    My first guess is are you using application identity, and if so, are you
    correctly implementing the equals() and hashCode() method? Failure to do
    so may conceivably cause this problem.
    Otherwise, can you provide some details about how the results are our of
    order? It it exactly reverse or something, or are elements in random
    order?
    Christiaan wrote:
    Hi,
    when I execute a random access query
    (fetchConfig.setResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE);
    fetchConfig.setFetchDirection(ResultSet.FETCH_UNKNOWN)) and iterate over
    the result set twice, the second time the objects are retrieved in a
    different order, also when I set the ordering of the objects. This only
    happens if the first loop touches the last item. If not, everything works
    fine. I am using MS Sql Server, microsoft driver, kodo 3.4
    regards,
    Christiaan
    Marc Prud'hommeaux
    SolarMetric Inc.

  • Thread monitoring for database query

    Hi,
    I need to be able to store a database query in a thread. This means that the entire query from executing to return should take place in this thread (as well as connection etc). I would then like to know when it have finished its work so i can carry on some more porcessing.
    I tried doing this with two threads, one to do the work and the other to 'watch' and then tell me when is is done. However, i errors 'every now and again' to which i can attribute to my thread structure not working properly. I am using a synchronised class and code post the code if anyone wishes to see it, however, i would appreciate it if someone could give me a basic structure to how i can go about this so that i do not get these 'random' errors.
    Thanks Rudy

    Okay -
    I have an idea. Withut fully implementing your code, mind you.
    If looks like you're having problems with concurrent access to your Vector.
    A Vector is, of course, a Collection and a List (interfaces) - these are not thread safe. To make them thread safe, you need to "wrap" them.
    <lifted from JavaDocs>
    public static Collection synchronizedCollection(Collection c)
        Returns a synchronized (thread-safe) collection backed by the specified collection. In order to guarantee
    serial access, it is critical that all access to the backing collection is accomplished through the returned
    collection.
        It is imperative that the user manually synchronize on the returned collection when iterating over it:
      Collection c = Collections.synchronizedCollection(myCollection);
      synchronized(c) {
          Iterator i = c.iterator(); // Must be in the synchronized block
          while (i.hasNext())
             foo(i.next());
        Failure to follow this advice may result in non-deterministic behavior.
        The returned collection does not pass the hashCode and equals operations through to the backing
    collection, but relies on Object's equals and hashCode methods. This is necessary to preserve the
    contracts of these operations in the case that the backing collection is a set or a list.
        The returned collection will be serializable if the specified collection is serializable.
        Parameters:
            c - the collection to be "wrapped" in a synchronized collection.
        Returns:
            a synchronized view of the specified collection.</lifted from JavaDocs>
    Give your Vector a wrapper and see if that solves your problem.
    +M                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Getting query results from a PL/SQL procedure

    Hi! So, I’m a little stumped and I can’t seem to find the answer to what I believe is probably a simple question…
    So, here goes… I have a big ol’ union query that I use to create a report on a page, it’s about 25k – not over the 32k limit, but fails to be able to compile every time (I always get a 400 – Bad Request error). I’m not sure why this is happening, but I can remove a union statement and it compiles just fine – so it has something to do with the size of the query. ANYWAY – I’ve resolved that I should put this bad boy into the database as a stored procedure and just call it from Apex, my problem is I can’t figure out quite how to do this with variables, etc.…
    Instead of giving you my whole big query, I’ll use the emp table as the concept is the same:
    Say we have a query that creates a report on a page:
    select empno, ename, job, mgr, hiredate, sal, comm, deptno
    from emp
    where job = :P_JOB
    and hiredate >= :P_HIREDATE;
    How would I take this query, create it as a stored procedure on the db, pass the variables from Apex and return the query result set from the stored proc as a report?
    I really appreciate any help on this!
    Best,
    Gilcrest

    Hi Gilcrest,
    You should create the query as a View and use the view name and the WHERE clause in the report's sql source.
    Andy

Maybe you are looking for