How to return a record's column head given a record of a table.

Hi:
Do you know how to return a record's column head given a record of a table.
For example, in a table with 3 columns "ID", "Education", "Age".
Give you the record "Bachelor", how can you use a SQL to return the correspondent column head "Education"?
Thanks for the big help.

Have a look at http://java.sun.com/j2se/1.4.2/docs/api/java/sql/ResultSetMetaData.html.
import java.sql.*;
import java.util.*;
ResultSet rs = stmt.executeQuery("SELECT * FROM testTable");
ResultSetMetaData rsmd = rs.getMetaData();
// loop through rsmd.getColumnCount() {
     String columnName = getColumnName(i);
     // run a query SELECT * FROM testTable WHERE columnName='Bachelor'
     // if rs !=null return columnName and break out of the loop
}

Similar Messages

  • How do I make a JTable's header sorting actually change the actual table?

    How do I make a JTable's header sorting actually change the actual table?
    Currently, I'm using
    table.setAutoCreateRowSorter(true);to allow the user to sort the table.
    However, I want to be able to load something based on the selected row's index. The problem is that when the table is rearranged, the change appears to only be local, in other words, the actual table isn't changing.
    For instance:
    index 0 "A"
    index 1 "B"
    index 2 "C"
    Sorted in reverse gives me
    "C"
    "B"
    "A"
    But C is still index 2 (instead of 0).
    Thanks in advance.

    Cross posted and answered in the Swing forum.
    [http://forums.sun.com/thread.jspa?threadID=5353865]
    I see this is not your first incidence of cross posting. In future, please post a question once only.
    db

  • Regarding how to delete the record in internal table

    Hi experts ,
    how to delete the record in intarnal table after validating the data,
    if record contains invalid fields?
    i am giving my code see this and give me the answer?
    loop at it_data into wa_data .
    Validate  Cost Center
        READ TABLE it_kostl INTO wa_kostl WITH KEY kostl = wa_data-kostl BINARY SEARCH.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-004.
        ENDIF.
    Validate source file material ( material number )
    loop at it_mara into wa_mara .
      read table it_ausp into wa_ausp with key atwrt = wa_data-i_matnr .
               if sy-subrc NE 0 .
       PERFORM update_error_log USING wa_data
                                           text-002.
    delete it_data-objek .
         else.
      read table it_mara into wa_mara with key  matnr = wa_ausp-objek .
           if sy-subrc EQ 0 .
           wa_data-objek = wa_mara-matnr.
           wa_data-matkl = wa_mara-matkl.
         ENDIF.
         Modify it_data from wa_data  .
      endif.
    *endloop.
    Validate unit of measure (unit)
        READ TABLE it_t006 INTO wa_t006 WITH KEY msehi = wa_data-unit .
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-003.
        endif.
    Validate delivery location ( storage location )
        READ TABLE it_lgort INTO wa_lgort WITH KEY del_loc = wa_data-del_loc.
        IF sy-subrc NE 0.
          PERFORM update_error_log USING wa_data
                                         text-001.
             if wa_data-flag ='x' .
          delete it_data from  wa_data .
        endif.
        ENDIF.
    endloop.

    Hi Naren,
    First get the index number of the IT_data table and store it in one variable whose declaration like this.
    data: tabix type sy-tabix.
    while reading the internal table it_data set the tabix variable.
    tabix = sy-tabix.
    Instead of  the above use below one.
    Delete it_data-objek
    Use the Below statement it will delete  the row from the internal table.
    Delete it_data-objek index tabix
    Thanks,
    Chidanand

  • How to insert a record in ROOSPRMSC table? (accidentally deleted)

    Calling an InfoPackage in BW causes short dump, while fixing the short dump issue, accidentally
    deleted the "ROOSPRMSC" table entries.
    Could you tell me how to insert a record in "ROOSPRMSC" table???

    Hi Senthil,
    Regards,
    Phani Raj Kallur
    Message was edited by: Phani Raj Kallur

  • How can i fetch records from 3 tables in a single query  without using join

    Hi.
    Can any body please tell me <b>How can i fetch records from 3 tables with a single query  without using joins</b>
    Thanx
    prabhudutta

    Hi Prabgudutta,
    We can fetch the data by using the views concept.
    Go throuth this info we can know the how to create view and same like database table only we can fetch the data.
    Views conatin the data at runtime only.
    Four different view types are supported. These differ in the
    way in which the view is implemented and in the methods
    permitted for accessing the view data.
    Database views are implemented with an equivalent view on
    the database.
    Projection views are used to hide fields of a table (only
    projection).
    Help views can be used as selection method in search helps.
    Maintenance views permit you to maintain the data
    distributed
    on several tables for one application object at one time.
    step by step creation of Maintenance view:
    With the help of the table maintenance generator, you are able to maintain the ENTRIES of the table in SM30 transaction.
    It can be set in transaction SE11 - Tools - Table maintenance generator.
    Table maintanance Generator is used to manually input values using transaction sm30
    follow below steps
    1) go to se11 check table maintanance check box under attributes tab
    2) utilities-table maintanance Generator-> create function group and assign it under
    function group input box. Also assign authorization group default &NC& .
    3) select standard recording routine radio in table table mainitainence generator to move table
    contents to quality and production by assigning it to request.
    4) select maintaience type as single step.
    5) maintainence screen as system generated numbers this dialog box appears when you click on create button
    6) save and activate table
    One step, two step in Table Maintenance Generator
    Single step: Only overview screen is created i.e. the Table Maintenance Program will have only one screen where you can add, delete or edit records.
    Two step: Two screens namely the overview screen and Single screen are created. The user can see the key fields in the first screen and can further go on to edit further details.
    SM30 is used for table maintenance(addition or deletion of records),
    For all the tables in SE11 for which Table maintenance is selected , they can be maintained in SM30
    Sm30 is used to maintain the table ,i.e to delete ,insert or modify the field values and all..
    It creates the maintenance screen for u for the aprticular table as the maintenance is not allowed for the table..
    In the SE11 delivery and maintenance tab, keep the maintenance allowed..
    Then come to the SM30 and then enter the table name and press maintain..,
    Give the authorization group if necessary and give the function group and then select maintenance type as one step and give the screen numbers as system specified..
    Then create,,,
    Then u will able to see the maintenance view for the table in which u can able to insert and delete the table values...
    We use SM30 transaction for entering values into any DB table.
    First we create a table in SE11 and create the table maintenance generator for that Table using (utilities-> table maintenance generator) and create it.
    Then it will create a View.
    After that from SM30, enter the table name and Maintain, create new entries, change the existing entries for that table.
    Hope this resolves your query.
    Reward all the helpful answers.
    Rgds,
    P.Naganjana Reddy

  • How to delete a record from BSEG table

    Dear Experts,
    How to delete a record from BSEG table.
    If there possible to delete some records from transparent table ?
    Please help.
    Regards,
    Tan

    Hi,
    Deleting a record from a standard table can be done only if table maintenance exists - Cehck tcode - SM30.  But it is not advisable to delete records, coz the records may be dependent on many other tables.  If u delete in a single place, there may be chance that inconsistency in the data happens and hence will affect ur financial statements.
    Pls. assign points, if useful
    Regards,
    Sridevi

  • How to identify new records in a table using OBIEE

    Hi,
    I have price change table as and when a record comes into this table i have to generate an alert. Then show a report with the price changes on which i can invoke an action to go into my transactional system to make the chnage. And once the change is made the process again starts to look for any new price chnage records that are recieved.
    Could anyone pls tell me how to identify new records in a table.
    Rgds

    SELECT ID, LastName, FirstName,
    RANK() OVER (PARTITION BY LastName,
    FirstName ORDER BY ID) AS SeqNumber
    FROM
    (SELECT ID, LastName, FirstName
    FROM Customers
    WHERE (LastName, FirstName) IN
    (SELECT LastName, FirstName
    FROM Customers
    GROUP BY LastName, FirstName
    HAVING COUNT(*) > 1)

  • How to avoid WRAP of EXCEL Column HEADER Fields

    We have 3 tablix in the rdl file with 11 inch * 8.5 inch (to print in A4)
    Tablix 1 - HTML viewer
    Tablix 2 - EXCEL
    Tablix 3 - PDF 
    The size of the rdl is fixed , if size altered then printing becomes an issue.
    So we have to keep the rdl size fix
    but at the same time the WRAP of column header of the EXCEL need to be avoided ,
    because if the size of the column header is not reduced then we cannot be able to accomodate in the defined page size
    Eaxmple of SOme Header Field Name 
    1.OccupationCode 
    2.ChargeJobPhase which are quiet large fields, so it need to be wrapped(to reduce the length of the column to accomodate ) to fit in the page.
    So as an Alternative option  I use the COncept of Subreport and called it by adding row outside group otherwise the
    Report Server treats subreport as new report for each instance of the parent report.
    The challenge we faced is when export to EXCEL some of the columns is getting merged , I believe the size of the child report (sub report) is having the length
    greater than the parent report (Called Report )  and the size has to be large otherwise the COLUMN HEADER need to reduced which makes it Wrapped 
    So  is there any alternative without changing the parent report size and without WRAPPING the HEADER text of CHild report the MERGING of cell can be avoided.
    Since MERGING is happening which is not allowing us to PUT  FILTER in EXCEL but we need to have FILTER applicable since the END user use it to sort, find the records.

    Hi SubhadipRoy,
    In Reporting Services, whether to wrap text or not is depended on the CanGrow property. If we set the CanGrow property of tablix header row to true, then the header row of tablix will be expanded. If we set the CanGrow property of tablix header row
    to false, the header row will be shrunk as the designed size.
    So if we want to avoid wrap text, we can try to set the CanGrow property of tablix header row to false in Reporting Services level. Alternatively, we can click the Wrap Text button to enable the expended extra-long text property in Excel level.
    If there are any other questions, please feel free to ask.
    Thanks,
    Katherine Xiong
    Katherine Xiong
    TechNet Community Support

  • How to dynamically display value in column header

    Hi,
    I have a requirement where in the user selects a particular value from a drop down list, and the same has to be displayed in the column header. For example, there are A,B,C,D types of quantities in a drop down list. Once the user selects these values and submits, the column header should display the quantity type selected. Kindly let me know how this can be achieved.
    Regards
    Snehith.

    Hi Snehith,
    In Layout Mode, Double click the Column in the Table, the Control Properties window is opened, switch to the "Display" tab, then press on the formula button next to the "Label:".
    Use the Expression Builder to have the label be the value you want it to be: for example:
    NSTR(#ID[ACA9TU]@MAX_ROWS,'Z3.0')
    This formula takes a numeric field, formats it into a string and displays it.
    For more information about how to build expression, please see:
    http://help.sap.com/saphelp_nw70/helpdata/en/bd/90db4238bbf140e10000000a1550b0/frameset.htm
    Regards.
    Omer.

  • How to return varied no.of columns from Stored Procedure?

    Hi All,
    I have situation where I need to return with columns which will keep changing. At any given point of time I will be returning 10 columns. But there are some conditions where I need to add multiples of 4 no.of columns.
    Ex: Always 10 columns.
    If condition1
    return 10 + 4 columns
    if condition2
    return 10 + 4 + 4 columns
    How can I handle this?
    Can any one help me here.
    Thanks
    Vikram

    Change the stored procedure to a single column set return type like returning nulls if column is not applicable.
    Alternate, split the sp to single column set sp-s.
    You can get the returned column set by SELECT TOP(0) * INTO spxColumns FROM OPENQUERY..... method:
    http://sqlusa.com/bestpractices2005/selectfromsproc/
    http://www.sqlusa.com/bestpractices/select-into/
    Note, however, the OPENQUERY method is not completely clean.
    Kalman Toth Database & OLAP Architect
    Free T-SQL Scripts
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • How to return multiple record with Oracle Native Web Service?

    Dear all,
    I would like to know that the oracle native web service can be able to return multiple records to client or not?
    I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)
    Thank and Regards,
    Zenoni

    I successfully developed the oracle native web service for returning single record but the next challenge is to develop web service in order to return multiple record (like Employees data base on each department)You could return a list (multiple values/records) in XML format (using XMLType or CLOB), or CSV, or JSON, or whatever.
    function get_employees (p_department_id in number) return clob
    as
    begin
      return 'your_xml_string_here';
    end get_employees;It would be up to the client (the caller of the web service) to extract the values from whatever format you decide upon, of course.
    - Morten
    http://ora-00001.blogspot.com

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

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

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

  • How to SELECT ALL records of a TABLE VIEW in the BSP page

    Hi All,
    In the BSP portal, I am displaying some data(multple records) in the form of a table using the BSP TAG <htmlb:tableView>. I wrote the logic in the 'VIEW' of the BSP application which will be triggered by the controller. I have used the attribute selectionMode = "MULTISELECT" to have a Check Box to select a row.
    My requirement is to have a button/checkbox on the first column of the header of the table view. By clicking on this, it should select/desect all the records of the table. Could someone please help me how to do this? What attribute I should use in the tableview to get the button in the header row of the table and how to select all the records of the table.?
    Please provide your valuable inputs.
    Thanks & Regards,
    Paddu.

    Select all / Deselect all functionality when onRowSelection is there

  • How to insert new record into oracle table from GridView in VS2005.

    I need to insert records into Oracle10g table from VS2005 GridView using the Insert Method in Business Logic Class. The Update and Delete Methods are working fine. What's the best way out?

    How is it "not possible"?
    Either modify the Class for the new fields, or give the new fields default values (if applicable). If the type of an existing column has changed, then only the first option is available.
    Where's the problem?

  • How to Restore deleted records in other table in oracle database 10g...

    Hi All,
    i want to restore deleted records of a particular table in other table
    suppose:
    i perform a query
    delete from emp
    where deptno =30;
    now i wont to restore deptno=30 records in other table, let say in emp1 table
    can any one let me know how to do it?
    Thanks..

    This is what flashback query is for:
    orclz> conn scott/tiger
    Connected.
    orclz> select count(*) from emp;
      COUNT(*)
            14
    orclz> delete from emp where deptno=30;
    6 rows deleted.
    orclz> commit;
    Commit complete.
    orclz> create table deleted30 as select * from emp as of timestamp(systimestamp - 5/1440) where deptno=30;
    Table created.
    orclz> select count(*) from deleted30;
      COUNT(*)
             6
    orclz>

Maybe you are looking for

  • Solution: iTunes for Windows installation interrupted

    Hi everyone. From my experience... If you are running Windows XP Professional and have updated to Service Pack 2, you will not be able to install iTunes+QuickTime. You will need to un-install Service Pack 2 and then install iTunes+QuickTime. You can

  • Invisible the Empty Row

    Hello Experts, How can we make an Empty Row Invisible in ALV webdynpro table. Thanks, Bsreddy.

  • Search Entire Robohelp Forum?

    Is it possible to search the entire Robohelp forum, or do I have to enter my search term into each category individually? Usually one never knows which category help might turn up in!

  • Cannot enable Entourage as default email client in SL

    Help, this is driving me bonkers! I want to use MS Entourage as my default email client and I set it as the default program via "preferences' in Mail.app, however, every time I try to email a document via Preview it opens Mail.app. Same goes for when

  • Party Account not displayed

    Dear All, After Saving the billing document, If I see the accounting document, The customer party account is not displayed. Instead I see a G/L account in place of my customer account. Calculations are correct but cant see the customer account. Need