Update table based on values from other table

Hi,
I am trying to update one table based on the values of another table. Since you can't use From in update statements, how do you execute this?
For example i have to tables, Table A and Table B. I want to update a column or columns in Table A based on another value in Table B:
So if the column in Table B was 1 then column in Table A would be Yes, if Table B was 2, then Table A would be Yes, if Table B was 3 then Table A would be N/A and so on...
Any help would be appreciated.
thanks,
scott

SQL> select * from t1;
ID ST
1
2
3
SQL> select * from t2;
NO
1
2
3
4
SQL> update t1 set status=(select decode(no,1,'Y',2,'N','NA') from t2 where t1.id=t2.no);
3 rows updated.
SQL> select * from t1;
ID ST
1 Y
2 N
3 NA
Daljit Singh

Similar Messages

  • Deleting rows from table based on value from other table

    Hello Members,
    I am struck to solve the issue said below using query. Would appreciate any suggestions...
    I have two tables having same structures. I want to delete the rows from TableA ( master table ) with the values from TableB ( subset of TableA). The idea is to remove the duplicate values from tableA. The data to be removed are present in TableB. Catch here is TableB holds one row less than TableA, for example
    Table A
    Name Value
    Test 1
    Test 1
    Test 1
    Hello 2
    Good 3
    TableB
    Name Value
    Test 1
    Test 1
    The goal here is to remove the two entries from TableB ('Test') from TableA, finally leaving TableA as
    Table A
    Name Value
    Test 1
    Hello 2
    Good 3
    I tried below queries
    1. delete from TestA a where rowid = any (select rowid from TESTA b where b.Name = a.Name and a.Name in ( select Name from TestB ));
    Any suggestions..
    We need TableB. The problem I mentioned above is part of process. TableB contains the duplicate values which should be deleted from TableA. So that we know what all values we have deleted from TableA. On deleted TableA if I later insert the value from TableB I should be getting the original TableA...
    Thanks in advance

    drop table table_a;
    drop table table_b;
    create table  table_b as
    select 'Test' name, 1 value from dual union all
    select 'Test' ,1 from dual;
    create table table_a as
    select 'Test' name, 1 value from dual union all
    select 'Test' ,1 from dual union all
    select 'Test' ,1 from dual union all
    select 'Hello' ,2 from dual union all
    select 'Good', 3 from dual;
    /* Formatted on 11/23/2011 1:53:12 PM (QP5 v5.149.1003.31008) */
    DELETE FROM table_a
          WHERE ROWID IN (SELECT rid
                            FROM (SELECT ROWID rid,
                                         ROW_NUMBER ()
                                         OVER (PARTITION BY name, VALUE
                                               ORDER BY NULL)
                                            rn
                                    FROM table_a a
                                   WHERE EXISTS
                                            (SELECT 1
                                               FROM table_b b
                                              WHERE a.name = b.name
                                                    AND a.VALUE = b.VALUE))
                           WHERE rn > 1);
    select * from table_a
    NAME     VALUE
    Test     1
    Hello     2
    Good     3Edited by: pollywog on Nov 23, 2011 1:55 PM

  • How to select rows based on values from other table?

    I need to select all rows from TABLE1 whose time column is NOT between fromTime and toTime from TABLE2.
    For example, those table contain following rows:
    TABLE1
    |id |time |...
    |1 | 10 |...
    |2 | 20 |...
    |... | ... |...
    TABLE2
    |fromTime|toTime|
    | 3 | 6 |
    | 10 | 16 |
    | 20 | 25 |
    So, in the case above the first and second rows shouldn't be returned by the query since 10<=10<=16 AND 20<=20<25.

    Try
    -- code #1
    SELECT id, time
    from TABLE1 as T1
    where not exists (SELECT * from TABLE2 as T2
    where T1.time between T2.fromTime and T2.toTime);
    José Diz     Belo Horizonte, MG - Brasil

  • Update one table based on condition from another table using date ranges

    Hello!
    I have two tables:
    DateRange (consists of ranges of dates):
    StartDate            FinishDate
            Condition
    2014-01-02
          2014-01-03           true
    2014-01-03     
     2014-01-13          
    false
    2014-01-13      
    2014-01-14           true
    Calendar (consists of three-year dates):
    CalendarDate    IsParental
    2014-01-01
    2014-01-02
    2014-01-03
    2014-01-04
    2014-01-05
    2014-01-06
    2014-01-07
    2014-01-08
    2014-01-09
    2014-01-10
    I want to update table Calendar by setting  IsParental=1
      for those dates that are contained in table DateRange between
    StartDate and FinishDate AND Condition  IS TRUE.
    The query without loop should look similar to this but it works wrong:
    UPDATE
    Calendar
    SET IsParental = 1
     WHERE
    CalendarDate   BETWEEN
    (SELECT
    StartDate 
    FROM  DateRange
    WHERE Calendar.  CalendarDate   = DateRange. StartDate
               AND   
    (SELECT StartDate 
    FROM  DateRange
    WHERE Calendar.  CalendarDate   = DateRange. FinishDate
    AND Condition
     IS TRUE
    Is it possible to do without loop? Thank you for help!
    Anastasia

    Hi
    Please post DDL+DML next time :-)
    -- This is the DDL! create the database structure
    create table DateRange(
    StartDate DATE,
    FinishDate DATE,
    Condition BIT
    GO
    create table Calendar(
    CalendarDate DATE,
    IsParental BIT
    GO
    -- This is the DML (insert some sample data)
    insert DateRange
    values
    ('2014-01-02', '2014-01-03', 1),
    ('2014-01-03', '2014-01-13', 0),
    ('2014-01-13', '2014-01-14', 1)
    GO
    insert Calendar(CalendarDate)
    values
    ('2014-01-01'),
    ('2014-01-02'),
    ('2014-01-03'),
    ('2014-01-04'),
    ('2014-01-05'),
    ('2014-01-06'),
    ('2014-01-07'),
    ('2014-01-08'),
    ('2014-01-09'),
    ('2014-01-10')
    select * from DateRange
    select * from Calendar
    GO
    -- This is the solution
    select CalendarDate
    from Calendar C
    where EXISTS (
    select C.CalendarDate
    FROM DateRange D
    where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
    UPDATE Calendar
    SET IsParental = 1
    from Calendar C
    where EXISTS (
    select C.CalendarDate
    FROM DateRange D
    where C.CalendarDate between D.StartDate and D.FinishDate and D.Condition = 1
    [Personal Site] [Blog] [Facebook]

  • Ain't getting it: insert into table by determing value from another table

    I have a table (PERCENTILE_CHART) with percentiles and test scores for different tests:
    Structure:
    Percentile, Reading_Test, Writing_Test
    Data:
    30,400,520
    31,450,560
    97,630,750
    98,630,780
    99,640,800
    The data is currently in ascending order by Percentile.
    If a person took the Reading test and scored 630 he or she would be in the 98th (not 97th) percentile of the class taking that test.
    I wrote a statement to return the percentile:
    select Percentile
    from ( select ROWNUM, PERCENTILE
    from PERCENTILE_CHART
    where READING_TEST <= '650'
    order by READING_TEST desc)
    where ROWNUM < 2 order by PERCENTILE desc;
    This select works and is able to determine the highest percentile for a score.
    Ok, now I want to process all the records in a STUDENT table which have
    test scores and insert them in a new table along with the percents, normalizing the data in the process.
    Have this:
    STUDENT:
    Student_Name,Student_ID,
    John Smith,121,Reading,98,Writing,90
    Maggie Smithe,122,Reading,95,Writing,96
    And needs to be moved to into SCORES with the percentiles, so I get this:
    SCORES:
    Student_Name,Student_ID,Test_Name,Percentile
    121,Reading,98
    121,Writing,90
    122,Reading,95
    122,Writing,96
    This is were I get confused. How do I insert the data into the SCORES table with the percentile? I think calling a function in package is the way to do it:
    function oua_Test_Percentile_f (
    p_Test_Name in char,
    p_Test_Value in char)
    return char as
    -- Declare variables
    c_Return_PTile char(2);
    begin
    select PERCENTILE into c_Return_PTile
    from (select ROWNUM, PERCENTILE
    from PERCENTILE_CHART
    where p_Test_Name <= '&p_Value'
    order by p_Test_Nmae desc)
    where ROWNUM < 2 order by PERCENTILE desc;
    return c_Return_PTile;
    end;
    But this function doesn't return the percentile even though it is based on my working select mentioned earlier. It returns a blank for all tests.
    And even if it is working how do I then populate the SCORES table?

    You may want to use analytical functions so that you can determine the percentile across all of the different scores:
    SQL> with
    2 PERCENTILE_CHART as
    3 (
    4 select 30 PERCENTILE, 400 READING_TEST, 520 WRITING_TEST from dual union all
    5 select 31 PERCENTILE, 450 READING_TEST, 560 WRITING_TEST from dual union all
    6 select 97 PERCENTILE, 630 READING_TEST, 750 WRITING_TEST from dual union all
    7 select 98 PERCENTILE, 630 READING_TEST, 780 WRITING_TEST from dual union all
    8 select 99 PERCENTILE, 640 READING_TEST, 800 WRITING_TEST from dual
    9 )
    10 select
    11 max(percentile) over (partition by reading_test) HIGHEST_READING,
    12 max(percentile) over (partition by writing_test) HIGHEST_WRITING,
    13 percentile_chart.*
    14 from
    15 percentile_chart
    16 /
    HIGHEST_READING HIGHEST_WRITING PERCENTILE READING_TEST WRITING_TEST
    30 30 30 400 520
    31 31 31 450 560
    98 97 97 630 750
    98 98 98 630 780
    99 99 99 640 800
    SQL>
    I wasn't exactly sure how you wantd to coorelate this to the student records though; the student table had only two column name headings but there were four rows listed as examples and had fewer rows than in the percentile_chart table...
    If you join the student table to the able query it might be what you are looking for.
    You can create another table based on the output of your query by doing:
    create table scores
    as select * from
    (insert your query here)
    /

  • Table to store values from af:table

    hi ,
    i have a requirement where in a customer enters data row by row. it is desired that the data should get stored in the database not row by row but only after the client has finished filling all the rows. once the client has pressed the commit or save button, all the rows must get disabled.He or she should not be further able to modify the order details. Could you please suggest a way?
    and one more question
    can we create a temporary table(or either buffer) which holds the values of another table.so that once the table is committed, the values will go to this temporary table and then go to database.

    Hi,
    if you use ADF Business Components then this is handled for you automatically. The only remaining thing to do is
    once the client has pressed the commit or save button, all the rows must get disabled
    In this case set a EL expression on the readOnly property of the input text field and e.g. check if the primary key field is populated (in this case you return true). The EL can check e.g. #{row.pkAttr.inputValue != null}
    Frank

  • Update column based on values of same table

    I have table T1 with 4 columns 'col1','col2','col3','col4', 'col5','col6' as follows
    Col1     Col2     Col3     Col4     Col5     Col6
    1111     City1     C     AA     DDD     A1
    2222     City 1          DD     HHH     A1
    3333     City2     B     EE     OOO     
    4444     City 1     B     JJ     SSS     A1
    5555     City2     C     KK     VVV     
    6666     City2          RR     QQQ     
    7777     City2     B     XX     BBB     
    I have already updated Column 6with value ‘A1’ where Column 2 is ‘City1’.
    Now I want to update col 6 where col2 is ‘S’ with following conditions
    If Col 3 = ‘B’ then Col6 should be = col4
    else it should be = col5

    SET col6=DECODE(col3,'B',col4,col5)
    WHERE col2='S'

  • Best way to select from 2 tables, based on sum from detail table

    I have a "customer order line detail" table from which I want to report
    Order Number
    Customer Number
    Part Number
    Line Value { which is Unit Qty * (Unit price - discount%) }
    But only for orders which are above £1500.
    And lines which are not "Cancelled"
    I have access to an API which returns the total order value for the order.
    I am currently using this in my criteria, eg:
    select order_no, customer_no, part_no, round(unit_qty *(unit_price - unit_price *(discount/100)),2) Line_value
    from customer_detail
    where
    status != 'Cancelled'
    and
    Customer_Order_API.Get_Total_Sale_Price__(order_no)>=1500
    The API contains the following:
    SELECT SUM(ROUND((qty * price_conv_factor * unit_price), rounding_) -
    ROUND((qty * price_conv_factor * unit_price) -
    ((qty * price_conv_factor * unit_price) * ((1 - discount / 100) * (1 - order_discount / 100))), 2))
    FROM customer_detail
    WHERE order_no = order_no_
    AND state != 'Cancelled'
    AND line_item_no <= 0
    (that uses a price conversion factor that I don't use, since it's always 1)
    My query runs so slowly, because it is getting the order value for every line of the order, is it possible to improve?
    Thanks

    Thanks for the suggestion, it was close to what I needed.
    I ended up with this:
    select order_no,  name, ref_id, c_salesman_sub_division, line_value, catalog_desc
    from
    (SELECT coj.customer_no, coj.order_no, ifsapp.customer_info_api.GET_NAME(customer_no) name, coj.ref_id,
           coj.c_salesman_sub_division, ROUND((coj.buy_qty_due * coj.
           price_conv_factor) * coj.sale_unit_price, 2) - ROUND((coj.buy_qty_due *
           coj.price_conv_factor) * coj.sale_unit_price - ((coj.buy_qty_due * coj.
           price_conv_factor) * coj.sale_unit_price) * ((1 - coj.discount / 100) *
           (1 - coj.order_discount / 100)), 2) line_value, coj.catalog_desc,
    SUM( ROUND((coj.buy_qty_due * coj.
           price_conv_factor) * coj.sale_unit_price, 2) - ROUND((coj.buy_qty_due *
           coj.price_conv_factor) * coj.sale_unit_price - ((coj.buy_qty_due * coj.
           price_conv_factor) * coj.sale_unit_price) * ((1 - coj.discount / 100) *
           (1 - coj.order_discount / 100)), 2)) OVER (PARTITION BY Coj.ORDER_NO) AS SUM_ORDER
        FROM ifsapp.customer_order_join coj
        WHERE coj.order_no = coj.order_no
          AND TRUNC(coj.date_entered) = NVL(TO_DATE('25/01/2007', 'DD/MM/YYYY'),
              TRUNC(SYSDATE))
          AND coj.authorize_code = 'UKMEDM'
          AND coj.line_item_no >= 0
          AND coj.ref_id <> 'SAMP'
          AND coj.state <> 'Cancelled'
    where sum_order >=1500
        ORDER BY ref_id, c_salesman_sub_division, customer_no, order_no
    /[pre]
    But I have realised the problem with this.  Not sure if I made it clear, to myself even, but I need to include
    order lines added on a particular day (that are not cancelled)
    for orders which total >= £1500.
    If one line of an order is added for £900 but the rest of the order is £2000 then that line should be shown.
    My SQL only shows lines added for the day >= 1500.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • How to fetch a data form root table based on values of dependent table?

    My Dependent Table.
    EmpId
    projectId
    Object Name
    Object Type
    Object Description
    My Root Table:
    projectId
    Project Name
    Project Description
    Project Duration
    Project Manager
    starting date
    the above are my 2 tables . if search with an object name i should get the name of all the projects related to that . how do i achieve this SAPUI5

    REPORT YCHATEST .
    tables : mara.
    data : begin of itab occurs 0.
              include STRUCTURE mara.
    data: end of itab.
    select * from mara into table itab where matnr like 'S%'.

  • Deleting from a table based on values in a second table

    Is it possible to DELETE from (or for that matter do an UPDATE to) a table based on values in another table? I have gone through the online documentation but can't seem to find anything. I'm trying to delete rows from table A where A.field1 = B.field1 and B.field2 = 'X'. (B being the second table)

    It is done using subqueries in the where clause.
    delete from A
    where A.field1 in (select B.field1 from B where B.field2 = 'X');
    delete from A
    where exists (select 'x' from B where B.field1 = A.field1 and B.field2 = 'X');
    delete from A
    where A.rowid in (select A.ROWID from from A, B where B.field1 = A.field1 and B.field2 = 'X');
    And many other varieties. Eg. more specialised:
    delete from A
    where A.txdate < (select B.prune_date FROM B where B.field1 = A.field1 and B.field2 = 'X')
    and A.txstate in (select S.txstate from S where S.prodlass=a.prodclass and s.deletable='Y');

  • Update from other table

    I want to update one table with values from another table. The code I have written looks like
    update reservations r
    set start_date = (select start_date from sap_update su where su.reservation_id = r.reservationid),
    end_date = (select end_date from sap_update su where su.reservation_id = r.reservationid),
    impressions_rsvd = (select impressions_rsvd from sap_update su where su.reservation_id = r.reservationid),
    sapid = (select sapid from sap_update su where su.reservation_id = r.reservationid),
    state = (select reservation_state from sap_update su where su.reservation_id = r.reservationid);
    which results in me being told that start_date cannot be set to null.
    the intent is to match up records in the reservations table with those in the SAP_UPDATE table (on the reservationid column) and copy the data in corresponding rows from the sap_update to the reservations table.
    In passing, I personally find that the more complex inserts and updates are just as nasty as any select query. But all the books I've come across tend to skip over this aspect rather sharply. Are there any good resources on this? I'm also hampered by having rather more SQL Server experience - which seems to have a different handle on updates.
    Thanks for your help in anticipation!
    Iain

    If your subquery is not returning anyrow (i.e. no matching record in Sap_Update table for the given ReservationID), and you don't want to change existing value then in that case you can change it to:
    update reservations r
    set start_date = (select nvl(su.start_date, r.start_date) from sap_update su
       where su.reservation_id = r.reservationid),
    end_date = (select end_date from sap_update su
       where su.reservation_id = r.reservationid),
    impressions_rsvd = (select impressions_rsvd from sap_update su
       where su.reservation_id = r.reservationid),
    sapid = (select sapid from sap_update su
       where su.reservation_id = r.reservationid),
    state = (select reservation_state from sap_update su
       where su.reservation_id = r.reservationid);In similar fashion you can change your other subqueries too. Another suggestion, you can rewrite your query to:
    update reservations r
    set (start_date, end_date, impressions_rsvd, sapid, state   ) =
    (select nvl(su.start_date, r.start_date), end_date , impressions_rsvd, sapid, state
    from sap_update su
       where su.reservation_id = r.reservationid)
    ;Thanks,
    Dharmesh Patel

  • Redirecting to different pages based on value from table linked from report

    Hi,
    I wanted to navigate to different pages from a report link based on a value from the table on which the report is built. I was able to link to particular page without any problem.
    But, I wanted to link to different pages based on value in the table. Please let me know how can I do this?
    Thanks,

    kaminey wrote:
    Hi,
    I wanted to navigate to different pages from a report link based on a value from the table on which the report is built. I was able to link to particular page without any problem.
    But, I wanted to link to different pages based on value in the table. Please let me know how can I do this?APEX version?
    Is this a standard or interactive report?
    How does the value from the table determine the target page used in the link? Is it a page number? Or the result of some computation or process?
    When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s) (making particular distinction as to whether a "report" is a standard report, an interactive report, or in fact an "updateable report" (i.e. a tabular form)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.

  • Can retrieve value from one table, but not the other (exception thrown)

    Hi
    I hope some friendly soul can help me out here. I have a local Access database file. I am able to get a value from all tables except for one, which throws this error: "System.NullReferenceException:
    Object reference has not been specified to an object".
    The rather simple lines of code when working is this:
    Dim email As Object
    value = MyDataSet.Tables("Table")(0)(1).ToString
    Msgbox(email)
    However, when simply changing from "Table" to "AnotherTable", the exception is thrown. I
    have seriously no idea why. I've made sure the datatypes are the same and that the values are not NULL.
    What gives?

    Hello,
    Going with your last reply, you should be accessing data via the strong typed classes that get generated.
    Example using Microsoft Northwind database accessing the customers table in a MS-Access database. Note the check for Rows, we could even go farther if we are questioning issue with the data via try-catch statements writing errors to the IDE Output window.
    I would highly recommend never referencing rows without first checking if there are rows and secondly never reference columns by ordinal index, always use the column name. One example with ordinal positioning, suppose someone did SomeDataTable.Columns("SomeColName").SetOrdinal(3)
    and you expect the ordinal position to be 1 ? things will crash-n-burn. Food for thought :-)
    Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.CustomersTableAdapter.Fill(Me.MainDataSet.Customers)
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    If MainDataSet.Customers.Rows IsNot Nothing Then
    Dim FirstCompanyName As String = MainDataSet.Customers.FirstOrDefault.CompanyName
    MessageBox.Show(FirstCompanyName)
    Else
    MessageBox.Show("No rows in customer table")
    End If
    End Sub
    End Class
    In this case we get the first record from below in Button1 Click
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • CE function to get distinct values from Column table

    Hi All,
    Could you please let me know the appropriate CE function to get the distinct values from column table.
    IT_WORK = SELECT DISTINCT AUFNR FROM :IT_WO_DETAILS;
    Thank you.

    Hi,
    If you have 10g, you can use Model( with model performance is better than connect by )
    Solution
    ========================================================================
    WITH t AS
    (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 1234.567432, 1234.567432, 0989.726332'
    txt
    FROM DUAL)
    SELECT DISTINCT TRIM(CHAINE)
    FROM T
    MODEL
    RETURN UPDATED ROWS
    DIMENSION BY (0 POSITION)
    MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    RULES
    (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    =========================================================================
    Demo
    =======================================================================
    SQL> WITH t AS
    2 (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 123
    4.567432, 1234.567432, 0989.726332'
    3 txt
    4 FROM DUAL)
    5 SELECT DISTINCT TRIM(CHAINE)
    6 FROM T
    7 MODEL
    8 RETURN UPDATED ROWS
    9 DIMENSION BY (0 POSITION)
    10 MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    11 RULES
    12 (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    13 CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    TRIM(CHAINE)
    3453.736379
    1234.567432
    0989.726332
    SQL>
    ========================================================================

  • How to retrieve 2 values from a table in a LOV

    Hi
    I'm pretty new to APEX. I try to retrieve two values from a table using a LOV. I have a table named DEBIT with then columns SITE, NAME and KEY
    I want to display NAME to the user in a list. When the user select an item from the list, I want to retrieve the data of the SITE and KEY column of this item in order to launch an SQL command based on this two values.
    How to retrieve thes two values whant the user chooses an item from the list ?
    I apologize for my english, being french.
    Regards.
    Christian

    Christian,
    From what I understood about your requirement, you want a 'select list with submit' which displays "NAME" and based on the value selected, you want to get the corresponding values for "SITE" and "KEY" from the table.
    <b>Step 1: Create a select list with submit, say P1_MYSELECT </b><br><br>
    Use something like this in the dynamic list of values for the select list: <br>
    SELECT NAME display_value, NAME return_value
    FROM DEBIT<br><br>
    <b>Step 2: Create a page process of type PL/SQL block. Also create 2 hidden items P1_KEY and P1_SITE. </b><br><br>
    In the PL/sQL, write something like:
    DECLARE
      v_key DEBIT.KEY%TYPE;
      v_site DEBIT.SITE%TYPE;
      CURSOR v_cur_myvals IS
              SELECT KEY, SITE
              FROM DEBIT
              WHERE NAME = :P1_MYSELECT;
    BEGIN
      OPEN v_cur_myvals;
      LOOP
              FETCH v_cur_myvals
              INTO  v_key,v_site;
              EXIT WHEN v_cur_myvals%NOTFOUND;
    :P1_KEY := v_key;   
    :P1_SITE := v_site; 
      END LOOP;
      CLOSE v_cur_myvals;
    END; <br><br>
    Then you can use these values for whatever purpose you need to.
    Hope this helps.

Maybe you are looking for

  • Get a insert session value for SQL query at report

    Hi friends I created a global temp table and procedure to support web search form. and a search result report. The procudure gets search result from multip tables and insert into temp table --recordsearch. I can get value from temp table  by call pro

  • When i m open any link in new tab its shows nothing its browse and showing blank page

    for eg when i search some thing in google search many link of websites are showing in list when i click any link to open with new tab it showing blank page

  • I have a video ipod with a problem

    i just got my ipod and i had uploaded a lot of songs and two music videos with songs. Well now the songs with the music videos and the two music videos are gone. I bought them from itunes but i cant find any of the FAQs for that. Everything else is f

  • Cisco VT Advantage with IP Communicator

    Trying to use VTA with Communicator 2.0(1). When I click on the Video Icon on Communicator, the following message appears "Cisco Video Advantage version 2.0(1) is required to work with Communicator 2.0(1). I can't find VTA 2.0(1) on Cisco's site. Is

  • Building shared library

    I am a new user to Mac and I am trying to build a shared library using gcc. However, I am getting errors when creating a execuatble. My system info. is: [email protected] <810> gcc --version i686-apple-darwin8-gcc-4.0.1 (GCC) 4.0.1 (Apple Computer, I