Problems in mapping a result set into IN operator

i can't for the life of me figure out how to create the following predicate in a mapping:
WHERE table1.cola NOT IN (SELECT table2.cola
FROM table2);

Chris,
Perhaps you can use the minus operator in your example. I.e.:
select table1.cola
minus
select table2.cola
This select would result in the set of data you need.
Mark.

Similar Messages

  • Convert result set into input stream

    Hi,
    I have result set with me having 93 columns with 1 lac rows. I want to download the result set as xls file.
    Because of the data set size is large, i'm not able to hold the data in java object. So i'm trying to convert result set to input stream and giving this input stream to servlet output stream by specifying the contentType as text/xls.
    I'm not able to convert result set into input stream.
    Could you provide a solution here...
    Thanks,
    Rajesh

    1 - JDBC is the wrong way to extract this data. It's like "What's the fastest way
    to copy the Oxford English Dictionary using tweets?" I would research the
    DBMS's bulk extract functionality.
    2 - Are you dead-set absolutely sure you need to do this at all? What can you
    do with the data all in one flat file that you cannot do with SQL access to the
    data?
    3 - If you want to convert all the columns into one (not that it's a huge
    win or anything), you can use the DBMS's conversion and concatenation
    functionality in your SQL. So instead of
    "select col1, col2, col3, .... from MyBigTable"
    do (change this to whatever conversion function syntax and concat syntax your DBMS needs)
    "select convert(col1, varchar) concat ' ' concat convert(col2, varchar) concat ' ' concat convert(col3, varchar) ... from MyBigTable"
    so the result set you get is a single column.
    Joe

  • Problems with mapping after bundling messages into one XML-file

    Hi all,
    Case 1: one DebMas IDoc ==> XI ==> one XML-file : no problems with mapping.
    Case 2: several DebMas IDoc's ==> XI ==> one XML-file : problems with mapping.
    Explanation:
    Incoming DebMas IDoc's:
    Businesspartner 1 : no Customer Master Partner Functions (E1KNVPM).
    Businesspartner 2 : Customer Master Partner Functions (E1KNVPM).
    Businesspartner 3 : Customer Master Partner Functions (E1KNVPM).
    Businesspartner 4 : Customer Master Partner Functions (E1KNVPM).
    After bundling into one XML-file:
    Businesspartner 1 : no Customer Master Partner Functions (E1KNVPM).
    Businesspartner 2 : no Customer Master Partner Functions (E1KNVPM) !!!!
    Businesspartner 3 : Customer Master Partner Functions of Bp 2 (E1KNVPM) !!!!.
    Businesspartner 4 : Customer Master Partner Functions of Bp 3 (E1KNVPM) !!!!.
    All the payloads of the IDoc's are correct.
    In the message mapping we use a Container for the Partner Functions (shown as below)
    Is this a serious bug in the mapping of SAP XI ?
    Does anyone knows how to solve this serious problem.
    E1KNVVM -
    > Partner_Container
    E1KNVPM -
    > Partner
       PARVW -
    > ParnerRole
       KUNN2   -
    > PartnerNumber
    Regards,
    Theo Pijlman

    Hi,
    Example:
    Input idoc has field F1 with occurence 0..unbnd
    My input values for field F1 is
    1
    none
    2
    3
    Say, I have a mapping, F1---->TargetF1
    In the target only 3 TargetF1s will be created for the values 1,2,3 and nothing will be created for the field F1 with no value.
    To overcome this, use collapse contexts.
    F1->collapsecontexts>TargetF1
    This way, the TargetF1 fields created will have the following values:
    1
    blank
    2
    3
    Collapse contexts makes sure that a target is created, even if there is a context change specified at the source.
    Hope this is clear.
    Regards,
    Smitha.

  • Put database result set into a vector?

    I have a resultset rs I would like to put into a vector but I don't seem to get something fundamental. I can put individual items in with add() for instance but how do I dump a whole result set in there...
    and if I do so should I turn them all to strings before putting them into the vector?
    Any general advice would be appreciated, I've read a lot about Vectors today and have ended up more confused than I'd have expected. So I have come to seek some basic advice.
    private static void showResult (ResultSet rs) throws SQLException {
                            Vector vector = new Vector();
             try
                     // rs is the resultset output from a database
                                      vector.addAll(rs);
             catch(NullPointerException ex)
                    System.out.println("bugger - null pointer exception");
                    System.out.println();
                    ex.printStackTrace();
    }

    Iterate over the resultset, create your own object to store data for each row and add that object to the vector. There is no escape from this.
    catch(NullPointerException ex)You should not be handling Runtime exceptions. You need to take care not to let them occur through your coding logic.

  • Can I retrieve a result set from Oracle and then incorporate that result set into my main SQL Server Stored Procedure?

    So I have a chunk of data that only resides in Oracle. So I need to capture that information from Oracle. Now before you get over zealous, I did try with an OPENQUERY and it took FOREVER! And I don't know why the OPENQUERY took FOREVER but if I run the same
    query directly against Oracle it runs very quickly...like 20 seconds.
    So now I'm wondering...can I build a dataset in my SSRS Report that uses an Oracle Data source and an Oracle Stored Procedure in its Dataset that I'll create to aggregate this subset of data and then utilize its result set back in my main reporting
    Dataset that will utilize SQL Server? And how can I do that? Can I make my main Dataset reference, say, a #TemporaryTable that is created from my Oracle Dataset in its
    I'll continue to Google a few things as I await your review and hopefully a reply.
    Thanks in advance for your help.

    Hi ITBobbyP,
    According to your description you want to use data from a Oracle data source into a DataSet which retrieving data from SQL Server. Right?
    In Reporting Services, we can have multiple data sources in one project pointing to different database. And we can use separated dataset to retrieve data from different data source. However, it's not supported to combine the two datasets together
    directly. We can only use Lookup(), LookupSet() function to combine fields from different dataset into one tablix when there are common columns between two datasets. This is the only way to make tow result sets together in SSRS.
    Reference:
    Lookup Function (Report Builder and SSRS)
    LookupSet Function (Report Builder and SSRS)
    Best Regards, 
    Simon Hou
    TechNet Community Support

  • Exporting query result set into CSV file using Forms

    Hi ,
    My requirement is
    -> I need to create a form where I have a Multi line text box and two button.
    -> When I enter a query in text box and click on Execute button, It should execute a select query.
    -> After execution, Result set needs to be exported into an Excel file.
    Please give a hint how to do this????
    Thanks,
    maddy

    as you are using text item to write SQL query by the user
    so for that you need to use the exec_sql package to parse the text items query and get definitions and values of the columns being
    resulted in the result set of the query.
    once your query is execute to the desired connection then you need to use fetch the result to the CSV file by use of the TEXT_io package
    which will open the text file with .csv extension and you have to pass the each line to that text file with comma separated values as "ss","rr" etc.
    or you can use the ole2 package to call the excel application and then fetch the data of exe_sql query to that.

  • Problem in creating Saved Result Set (SRS) in OBIEE 10.1.3.4

    Hi,
    We have migrated Siebel Analytincs 7.8.5 to OBIEE 10.1.3.4, and we are now unable to create any SRS from OBIEE though we can create Segment and marketing cache for the segment.
    We did the following steps -
    1. Unisntall Siebel Analytincs 7.8.5
    2. Install OBIEE 10.1.3.4
    3. Use MIGRATE tool (sawmigrate) to migrate RPD & WEBCAT
    4. We have ALTERed the SRS tables - M_SR_HEADER, M_SR_ACCOUNT (as in OBIEE version there are many new columns have been added)
    5. We passed GLOBAL CONSISTENCY in the RPD
    6. We followed the steps in the document *"Oracle®Marketing Segmentation Guide Version 10.1.3.4 July 2008"*
    7. We created a Saved Result Set Format as instructed in the document - here we are very confused to select the list of columns - we don't know what should be the excat source / format
    8. Then we click the SRS create button
    9. We got the below error -
    Error Codes: QS2QOLYY:GDL67CY9:IHVF6OM7:OPR4ONWY:U9IM8TAC
    Error in getting cursor for WorkNode (Id:0)
    Authentication Failure.
    Odbc driver returned an error (SQLDriverConnectW).
    *State: 08004. Code: 10018. [NQODBC] [SQL_STATE: 08004] [nQSError: 10018] Access for the requested connection is refused. [nQSError: 43001] Authentication failed for Administrator in repository Star: invalid user/password. (08004)*
    Can anyone help us to resolve the issue ?
    A quick response is much much appreciated.
    Many Thanks,
    Prasanta

    Hi,
    It seems like you didnt setup the Administrator user for Saved Result Sets as it mentioned in the Marketing Segmentation Guide.
    Here is an extract from the guide:
    Setting Up the Web Administrator for Managing Cache and Saved Result Sets
    Some queries issued by the segmentation engine require the use of the Execute Physical stored
    procedure. These queries include delete statements on the cache, delete statements on the saved
    result sets, and insert statements for the cache and saved result set. The Execute Physical stored
    procedure must be run by a user with administrator privileges. The administrator user is set up in
    the instanceconfig.xml file.
    NOTE: The BI Administrator password and login parameters are case sensitive.
    To set up the administrative user in the instanceconfig.xml file
    1 Open a command shell and navigate to the <OracleBI>/web/bin, where <OracleBI> represents
    the root directory of the installation.
    2 Execute the following command:
    cryptotools credstore -add -infile <OracleBIData>/web/config/credentialstore.xml
    3 When prompted, enter the following values:
    Credential Alias: admin
    Username: Administrator
    Password: <enter Admin password here>
    Do you want to encrypt the password? y
    Passphrase for encryption: <password >
    Do you want to write the passphrase to the xml? n
    File "<OracleBIData>/web/config/credentialstore.xml" exists. Do you want to overwrite it? y
    4 Open the credentialstore.xml file and verify that the following section has been created:
    <sawcs:credential type="usernamePassword" alias=“admin">
    <sawcs:username> Administrator </sawcs:username>
    <sawcs:password>
    <xenc:EncryptedData>

  • Concatenate result set into a string SQL

    Hi, I need some help with concatenating a resultset to avoid duplication of data.
    I have 3 tables:
    SCRIPT
    ID - Number PK
    DATE - Date
    TITLE - Varchar2
    AUTHOR
    A_ID - Number PK
    A_Name - Varchar2
    SCRIPT_AUTHOR
    ID - Number - PK, FK to Script.ID
    A_ID - Number PK, FK to Author.A_ID
    I need to list all authors for each script on one line, at the moment I have the following SQL :
    Select S.Title, SA.A.ID
    FROM SCRIPT S, SCRIPT_AUTHOR SA
    WHERE SCRIPT.ID = SCRIPT_AUTHOR.ID
    and as expected this is returning a dataset as follows - giving me 2 lines in this case for one script :
    S.TITLE, SA.A_ID
    1, 1
    1, 2
    What I am actually after is a result set that combines both the authors in this case in one record: 1, 1:2 so I only have 1 line per script.
    The scripts can have many authors, and I will want to do this for many scripts at a time.
    I have hit a blank on how to do this, is it possible to do this with SQL?
    Many Thanks
    p.s. Using: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0

    Hi,
    That's called "String Aggregation"
    [AskTom.oracle.com|http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2196162600402] shows several different ways to do it.
    I recommend the first one, the user-defined function STRAGG, which you can copy from that page.
    Once you have STRAGG installed, your query is simply
    Select       S.Title
    ,       STRAGG (SA.A.ID)     AS sa_id_list
    FROM       SCRIPT     S
    ,       SCRIPT_AUTHOR SA
    WHERE       SCRIPT.ID = SCRIPT_AUTHOR.ID
    GROUPB BY s.Title;On Oracle 10 (and up) you may have a similar function, WM_CONCAT (owned by WMSYS), already installed.
    WM_CONCAT is not documented, so you may not want to use it in your Production applications.

  • What is the best way of converting everything in a result set into a string

    hello folks
    What do you think is the best way of converting everything in a resultset into a string???
    At the moment I'm using
    rs.getString(i);
    everywhere (no matter if the underlying datatype is a date or whatever..) it converts automatically evertything expect NULL into a valid string.
    Are there better (simple to use..) ways?

    I don't see a big switch construct. How about trying the following:
    Call this method from your original method by passing the resultset obtained.
    public String[] convert(ResultSet rs) {
         int col = ((ResultSetMetaData) rs.getMetaData()).getColumnCount();
         String[] record = new String[col];
         int i=0;
         while(rs.next()) {
              if(rs.wasNull()) record[i] = new String();
              else record[i] = rs.getString(i);
              i++;
         return record;
    iDriZ

  • Problem using the FederatedSearch / Result set empty

    Hello,<br>
    <br>
    I've the following problem using the FederatedSearch:<br>
    In my KM-Folder I've two documents.<br>
    I created a simple search AbstractPortalComponent to search in the special KM-Folder.<br>
    If the query is "*" I will get the right number of documents.<br>
    But If I will access them the iterator is empty...<br>
    Please see the code below:<br>
    <br>
    Best regards<br>
    Klaus<br>
    <br>
    <br>
    IIndexService indexService = (IIndexService) ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.INDEX_SERVICE);<br>
    <br>
    SearchQueryListBuilder sqb = new SearchQueryListBuilder();<br>
    <br>
    sqb.setSearchTerm(query);<br>
    IQueryEntryList qel = sqb.buildSearchQueryList();<br>
    RidList ridList = new RidList(); <br>
    ridList.add(RID.getRID(OR_KM_ROOT_PATH + "/" + OR_KM_CURRENT_PATH));<br>
    ridList.add(RID.getRID(OR_KM_ROOT_PATH + "/" + OR_KM_ARCHIVE_PATH));<br>
    IResourceContext resourceContext = new ResourceContext(user);<br>
    IFederatedSearch federatedSearch = (IFederatedSearch) indexService.getObjectInstance(IWcmIndexConst.FEDERATED_SEARCH_INSTANCE);<br>
    IFederatedSearch search = (IFederatedSearch) indexService.getObjectInstance(IWcmIndexConst.FEDERATED_SEARCH_INSTANCE);<br>
    ISearchSession session = federatedSearch.searchWithSession(qel, ridList, resourceContext, null, null);<br>
    response.write("-"+session.getTotalNumberResultKeys()); ### writes 2-ok-<br>
    response.write("- "+session.getNumberResultKeys()); ### writes 2-ok-<br>
    ISearchResultList sresults = session.getSearchResults(1,session.getTotalNumberResultKeys());<br>
                   <br>
    ISearchResultListIterator iter = sresults.listIterator();<br>
    response.write("> "iter.hasNext()"<br>");          ### writes "false"!???
    <br>               
    while (iter.hasNext())<br>
    {<br>
    ...<br>
    }<br>

    The plan is to be running with more than just two sites (though at the moment I am testing with only two).
    What happens is a client comes on-line and requests a list of sites from a router. It then picks one of the sites from the list and adds that as a replication site in the repmgr.
    It then goes about opening up the database and doing some other bookeeping. Finally we start the replication manager and once the NEWMASTER event is recieved a sync is done.
    So while this DELAYCLIENT/rep_sync is a bit overkill for the two-site test I am doing now, the design I am working towards will be a multi-site setup.

  • How to split a result set into n-number ranges, each range has same max-min

    Hi guys,
    suppose there's a table T1(fvalue number),
    we can easily get the MAX and MIN of fvalue, for example, 19 and 5, I need to split them into, for example, 3 ranges, 5-9, 10-14, 15-19, they have the same max-min. And for each range, I need to know the count of rows that fall into this range.
    does anyone have any clues? is there any analytic function i can use to accomplish this?
    many thanks.

    There are the NTILE and WIDTH_BUCKET functions that may be of use. However, I'm not exactly sure what you are after.
    It is always helpful to provide the following:
    1. Oracle version (SELECT * FROM V$VERSION)
    2. Sample data in the form of CREATE / INSERT statements.
    3. Expected output
    4. Explanation of expected output (A.K.A. "business logic")
    5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Combining result set of two services into one result set

    Hi,
    I have a model where I am getting one result set (6 Fields) from BI query and another result set (3 Fields which gives real time values) from OLTP system. I want to show the output of these two result sets into single result set (7 Fields). I have a common field in both the result sets as key field.
    I tried this using UNION operator but I am not able to set the Key fields and also in the table view of UNION operator I am getting any field to be added to table.
    Can anyone help me to solve this problem?
    Any help is appreciated.
    Regards,
    Amit

    Hi Amit,
    in this case, you have to use the combine-operator. However, this operator needs a key-field in each of these sets. E.g. Combine set (<u>customer-id</u>, order-id, week, delivery-state) with set (<u>customer-id</u>, city, client-class).
    The combine operator might not be available when compiling to webdynpro, I did not check that.
    Best Regards, Benni

  • JSP Servlet and convert the result set of an SQL Query To XML file

    Hi all
    I have a problem to export my SQL query is resulty into an XML file I had fixed my servlet and JSP so that i can display all the records into my database and that the goal .Now I want to get the result set into JSP so that i can create an XML file from that result set from the jsp code.
    thisis my servlet which will call the jsp page and the jsp just behind it.
    //this is the servlet
    import java.io.*;
    import java.lang.reflect.Array;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.logging.Level;
    import java.util.logging.Logger;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.naming.*;
    import javax.sql.*;
    public *class *Campaign *extends *HttpServlet
    *private* *final* *static* Logger +log+ = Logger.+getLogger+(Campaign.*class*.getName());
    *private* *final* *static* String +DATASOURCE_NAME+ = "jdbc/SampleDB";
    *private* DataSource _dataSource;
    *public* *void* setDataSource(DataSource dataSource)
    _dataSource = dataSource;
    *public* DataSource getDataSource()
    *return* _dataSource;
    *public* *void* init()
    *throws* ServletException
    *if* (_dataSource == *null*) {
    *try* {
    Context env = (Context) *new* InitialContext().lookup("java:comp/env");
    _dataSource = (DataSource) env.lookup(+DATASOURCE_NAME+);
    *if* (_dataSource == *null*)
    *throw* *new* ServletException("`" + +DATASOURCE_NAME+ + "' is an unknown DataSource");
    } *catch* (NamingException e) {
    *throw* *new* ServletException(e);
    protected *void *doGet(HttpServletRequest request, HttpServletResponse response)
    throws IOException, ServletException
    Connection conn = *null*;
    *try* {
    conn = getDataSource().getConnection();
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select post_id,comments,postname from app.posts");
    // out.println("Le r&eacute;sultat :<br>");
    ArrayList <String> Lescomments= *new* ArrayList<String>();
    ArrayList <String> Lesidentifiant = *new* ArrayList<String>();
    ArrayList <String> Lesnoms = *new* ArrayList <String>();
    *while* (rs.next()) {
    Lescomments.add(rs.getString("comments"));
    request.setAttribute("comments",Lescomments);
    Lesidentifiant.add(rs.getString("post_id"));
    request.setAttribute("id",Lesidentifiant);
    Lesnoms.add(rs.getString("postname"));
    request.setAttribute("nom",Lesnoms);
    rs.close();
    stmt.close();
    *catch* (SQLException e) {
    *finally* {
    *try* {
    *if* (conn != *null*)
    conn.close();
    *catch* (SQLException e) {
    // les param&egrave;tres sont corrects - on envoie la page r&eacute;ponse
    getServletContext().getRequestDispatcher("/Campaign.jsp").forward(request,response);
    }///end of servlet
    }///this is the jsp page called
    <%@ page import="java.util.ArrayList" %>
    <%
    // on r&eacute;cup&egrave;re les donn&eacute;es
    ArrayList nom=(ArrayList)request.getAttribute("nom");
    ArrayList id=(ArrayList)request.getAttribute("id");
    ArrayList comments=(ArrayList) request.getAttribute("comments");
    %>
    <html>
    <head>
    <title></title>
    </head>
    <body>
    Liste des campagnes here i will create the xml file the problem is to display all rows
    <hr>
    <table>
    <tr>
    </tr>
    <tr>
    <td>Comment</td>
    <td>
    <%
    for( int i=0;i<comments.size();i++){
    out.print("<li>" + (String) comments.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>nom</td>
    <td>
    <%
    for( int i=0;i<nom.size();i++){
    out.print("<li>" + (String) nom.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    <tr>
    <td>id</td>
    <td>
    <%
    for( int i=0;i<id.size();i++){
    out.print("<li>" + (String) id.get(i) + "</li>\n");
    }//for
    %>
    </tr>
    </table>
    </body>
    </html>
    This is how i used to create an XML file in a JSP page only without JSP/SERVLET concept:
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (*char*)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = *new* File("C:\\Users\\user\\workspace1\\demo\\WebContent\\YourFileName.xml");
    //outputFile.createNewFile();
    FileWriter outfile = *new* FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
    // Define connection string and make a connection to database
    Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/SAMPLE","app","app");
    Statement stat = conn.createStatement();
    // Create a recordset
    ResultSet rset = stat.executeQuery("Select * From posts");
    // Expecting at least one record
    *if*( !rset.next() ) {
    *throw* *new* IllegalArgumentException("No data found for the posts table");
    outfile.write("<Table>"+cLf);
    // Parse our recordset
    // Parse our recordset
    *while*(rset.next()) {
    outfile.write("<posts>"+cLf);
    outfile.write("<postname>" + rset.getString("postname") +"</postname>"+cLf);
    outfile.write("<comments>" + rset.getString("comments") +"</comments>"+cLf);
    outfile.write("</posts>"+cLf);
    outfile.write("</Table>"+cLf);
    // Everything must be closed
    rset.close();
    stat.close();
    conn.close();
    outfile.close();
    catch( Exception er ) {
    %>

    Please state your problem that you are having more clearly so we can help.
    I looked at your code I here are a few things you might consider:
    It looks like you are putting freely typed-in comments from end-users into an xml document.
    The problem with this is that the user may enter characters in his text that have special meaning
    to xml and will have to be escaped correctly. Some of these characters are less than character, greater than character and ampersand character.
    You may also have a similiar problem displaying them on your JSP page since there may be special characters that JSP has.
    You will have to read up on how to deal with these special characters (I dont remember what the rules are). I seem to recall
    if you use CDATA in your xml, you dont have to deal with those characters (I may be wrong).
    When you finish writing your code, test it by entering all keyboard characters to make sure they are processed, stored in the database,
    and re-displayed correctly.
    Also, it looks like you are putting business logic in your JSP page (creating an xml file).
    The JSP page is for displaying data ONLY and submitting back to a servlet. Put all your business logic in the servlet. Putting business logic in JSP is considered bad coding and will cause you many hours of headache trying to debug it. Also note: java scriptlets in a JSP page are only run when the JSP page is compiled into a servlet by java. It does not run after its compiled and therefore you cant call java functions after the JSP page is displayed to the client.

  • Mapping query result to excel sheet

    Hi Experts,
    i have a requirement where in i need to map the result into particular cellls of the excel sheet, because the excel sheet acts as front end which has graphs and by just putting the result in particular cells of excel the graph is automatically generated, so is there any way where i can map the result cells into particulat cells in excel?
    Thank you.

    Hi Shetty,
    You might have stopped reading this thread since you have the answer you need for now.  From experience, let me tell you what might happen next.
    If the query definition is ever changed ... say, a new characteristic is added because a different user has a slightly different need ... the result table will move down by a few rows and your equation no longer works.
    If you think this might happen, let me tell you a very easy way to get around it.
    1.  Name the range(s) you will use.  If the first result is in cell B31 on Sheet1, then go to cell B31 on Sheet1 and Select Insert>>Name>>Define.  Call it something you will remember, like "LastMonthSales" (no spaces, but underline is OK)
    2. use the range name in your formula.  This happens automatically, in fact.  If you press = then click on cell B31, Excel will automatically use the range name instead of the range address.  Excel LIKES names.
    3. now, go to the Visual Basic Editor (Tools >> Macro >> Visual Basic Editor; or, Alt+F11).  In your workbook, there should be a subroutine as follows:
    Sub SAPBEXonRefresh(queryID As String, resultArea As Range)
    If you do not find it, add it.  This probably also means that you are using Excel 2002 or later and have not set your Macro security to "trust access to Visual Basic Project"; so, change that security setting (Tools >> Options >> Security >> Macro Settings).
    The visual basic code is very simple.  For each result that you need to map you will want one line of code like this one:
    resultArea.Cells(4, 2).Name = "LastMonthSales"
    The Cells(4, 2) are counted from the top left of the result table.  So, in this case if B31 = Cells(4,2), then the top left of my result table must have been in cell A28 in Excel.
    This subroutine will be run automatically every time that the query is refreshed.  So, if the result table moves, the names will move with it.  One less thing to worry about.
    If you do not think you need to do this today, don't!  No sense in doing work that is not necessary.  But, save this.  I suspect that some day you will need it.
    - Pete

  • Overwriting result sets in a file

    Hello, I am querying a database and putting the results into a ResultSets. When the user clicks a button the results are written to an Excel worksheet. However, each time you click the button or write to the worksheet, the ResultSet is appended to the previous one. Is there a way to overwrite??? Thank you in advance.

    here is the method I created to insert a result set into MS Excel
    public void output_vehicleInfo(ResultSet rset)
    try{
    prepared_statement = con.prepareStatement("insert into \"VehicleInfo$\" (BumperNumber, Noun, Section) values (?, ? ?)");
    while(rset.next())
    prepared_statement.setString(1,rset.getString(1));
    prepared_statement.setString(2,rset.getString(2));
    prepared_statement.setString(3,rset.getString(3));
    prepared_statement.execute();
    //catch clause
    The code works; however, it doesn't insert at the beginning of the table. It inserts after the last record. I want to overwrite all data with the insert.

Maybe you are looking for