Updated several lines with different values

Hello!
I have a problem. I need to update more than 1000 lines with different values. How can I do?
For exsample I have table:
ID; color, date,
1 red
2 green
3 white

I need to update the date field.

Update table
Set date = '01.02.03'
where id = 1

Update table
Set date = '01.03.03'
where id = 2


Maybe it's how to update multiple rows in a single request?

Sorry for my bad English.
Thank you!
Advertisement

Hello

You can try this

UPDATE TABLE SET DATE = CASE
                    WHEN ID = 1 THEN TO_DATE('01-02-03','DD-MM-RR')
                    WHEN ID = 2 THEN TO_DATE('01-03-03','DD-MM-RR')
                    END

see you soon

VT

Tags: Database

Similar Questions

  • Update a field with different values of several tables

    Hello

    I have a table named AAA with 2 fields id and structure.
    And then I have other 3 tables with 2 fields id1 and structure1 id2, table1 and table2, id3 and structure3 to table3 organized.2.

    The number of AAA id is equal to the sum of the IDS of table1, table2, table3: #id = #id1 + id2 # + #id3).

    I want to update the structure of AAA table with values as well as field:
    where AAA.id = table1.id1-> AAA.structure = table1.structure1
    where AAA.id = table2.id2-> AAA.structure = table2.structure2
    where AAA.id = table3.id3-> AAA.structure = table3.structure3

    Can someone help me?

    I have Oracle11gR2.

    Thank you in advance.

    Oops...

    update  AAA
    set structure = (select structure1 from table1 where aaa.id = table1.id1)
    where aaa.id in (select id1 from table1)
    
  • question of xsd. several records with different values.

    I need help in the creation of xsd.

    My data from the file will be as Fallows.

    Sample data file

    AB xxxx yyyy zzz ttttt

    BBB hhh ddd ddd

    BBB hhh ddd ddd

    BBB hhh ddd ddd

    BC xxxx yyyy zzz ttttt

    CCC hhh ddd ddd

    CCC hhh ddd ddd

    CCC hhh ddd ddd

    CD xxxx yyyy zzz ttttt

    Hhh ddd ddd DDD

    Hhh ddd ddd DDD

    Hhh ddd ddd DDD

    My xsd is as Fallows:


    < xsd: element name = "Root Element" >

    < xsd: complexType >

    < xsd: SEQUENCE >

    < xsd: element name = "Element" type = "tns: mainelement" minOccurs = "0" maxOccurs = "unbounded" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < / xsd: element >

    < xsd: complexType name = "mainelement" >

    < xsd: SEQUENCE >

    < xsd: element name = "Header" type = "tns:HeaderType" maxOccurs = "1" / >

    < xsd: element name = "lineitem1" type = "tns:lineitemrecord1" minOccurs = "0" maxOccurs = "unbounded" nxsd:lookAhead = "0" nxsd:lookFor = "" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < xsd: complexType name = "HeaderTyep" >

    < xsd: SEQUENCE >

    < xsd: element name = "HeaderData" type = "xsd: String" nxsd:style = "fixedLength.

    nxsd:length = "2528" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    < xsd: complexType name = "lineitemrecord1" >

    < xsd: SEQUENCE >

    < xsd: element name = "RecordData" type = "xsd: String" nxsd:style = "fixedLength" nxsd:length = "161" / >

    < / xsd: SEQUENCE >

    < / xsd: complexType >

    How can differentiate the values in the starting header field by [AB, BC, CD] and record data fields starting with [bbb, ccc, ddd]

    I can't use nxsd: lookahead and nxd:lookFor.

    Required inputs to process the file. What alteration is suitable for the xsd to run.

    Is there a parent - child relationship kind of thing in your file structure?

    Row containing sales, purchases etc. is the parent and the tracking records are the child records, until we meet any record type 'Bill of sales, purchases',? In addition, tried to use "conditionValue" and "startsWith" and it did not work... Is it?

  • reuse of filters with different values

    We have a usage scenario where the same filters will have to be applied several times with different values. Looking the javadocs, it seems like there is no way to change the values of pre-packaged filters (EqualsFilter, GreaterFilter etc.). Is that correct or is there a way to do it? I see that if we use CohQL, we can use bind variables to do this. However, the use cases we should rather just more complex extractors ReflectionFilters.

    In addition, there no performance impact by using CohQL against java constructs directly?

    Thank you
    Manju.

    Hi Manju,

    While it is true that you cannot change values in the built in filters, even if you could it wouldn't make you save a lot on the construction of a new filter every time. I guess that if you build a very large number of filters, then you're going to create more garbage, but that shouldn't be a problem either. Some of the more specialized filters also contain State so that you do not want to resuse them.

    The main performance issue I know with CohQL which is only creates extractors of reflection so won't enjoy all serialized POF values you have. If you have indexed each value you want to query on using the same extractors relflection then it would help, but again, this means that everything you deserialization of the values for the query or insert to update the index.

    Kind regards
    JK

  • two rows of delete with different values

    Hello

    I wouldn't lines with the same id and have values of E and F 10258932.

    I would like the following data:
    A        B  C      D     E N
    -------- -- ------ ----- - -
    10258927 1  103,35 0
    10258929 3  284,85 89,52 E N
    10258929 4  323,85 89,52 E N
    10258930 5  478,80 91,53 E N
    10258931 6  436,67 78,09 E N
    But I have the following lines:
    SQL> with my_table as
      2  (
      3  select '10258927' a, '1'  b, '103,35'  c, '0'      d,   NULL  e from dual union all    
      4  select '10258928' a, '2'  b, '0'       c, '15,19'  d,  'E'    e from dual union all
      5  select '10258929' a, '3'  b, '284,85'  c, '89,52'  d,  'E'    e from dual union all
      6  select '10258929' a, '4'  b, '323,85'  c, '89,52'  d,  'E'    e from dual union all
      7  select '10258930' a, '5'  b, '478,80'  c, '91,53'  d,  'E'    e from dual union all
      8  select '10258931' a, '6'  b, '436,67'  c, '78,09'  d,  'E'    e from dual union all
      9  select '10258932' a, '7'  b, '784,88'  c, '23,19'  d,  'E'    e from dual union all
     10  select '10258932' a, '8'  b, '100,88'  c, '11,11'  d,  'E'    e from dual union all
     11  select '10258932' a, '9'  b, '300,88'  c, '22,22'  d,  'F'    e from dual union all
     12  select '10258932' a, '10' b, '468,25'  c, '78,33'  d,  'F'    e from dual)
     13  select a, b, c, d, e, no_ds from
     14  (
     15    select a, b, c, d, e,
     16           case when c > 0 and e != 'F'
     17                then 'N'
     18           end no_ds
     19    from my_table)
     20  where no_ds = 'N' or e is null
     21  order by 1
     22  /
    
    A        B  C      D     E N
    -------- -- ------ ----- - -
    10258927 1  103,35 0
    10258929 3  284,85 89,52 E N
    10258929 4  323,85 89,52 E N
    10258930 5  478,80 91,53 E N
    10258931 6  436,67 78,09 E N
    10258932 7  784,88 23,19 E N
    10258932 8  100,88 11,11 E N
    
    7 Zeilen ausgewählt.
    
    SQL> 
    Does anyone have an idea?

    Oh, I read the title again once: 'remove double lines with different values.
    If it means that he is not specifically E and F values, but only if there is more than one distinct value, then you can do the following:

    with my_table as
    (
    select '10258927' a, '1'  b, '103,35'  c, '0'      d,   NULL  e from dual union all
    select '10258928' a, '2'  b, '0'       c, '15,19'  d,  'E'    e from dual union all
    select '10258929' a, '3'  b, '284,85'  c, '89,52'  d,  'E'    e from dual union all
    select '10258929' a, '4'  b, '323,85'  c, '89,52'  d,  'E'    e from dual union all
    select '10258930' a, '5'  b, '478,80'  c, '91,53'  d,  'E'    e from dual union all
    select '10258931' a, '6'  b, '436,67'  c, '78,09'  d,  'E'    e from dual union all
    select '10258932' a, '7'  b, '784,88'  c, '23,19'  d,  'E'    e from dual union all
    select '10258932' a, '8'  b, '100,88'  c, '11,11'  d,  'E'    e from dual union all
    select '10258932' a, '9'  b, '300,88'  c, '22,22'  d,  'F'    e from dual union all
    select '10258932' a, '10' b, '468,25'  c, '78,33'  d,  'F'    e from dual
    )
    --
    -- end-of-test-data
    --
    select a, b, c, d, e,
           num_distinct_values
    from
    (
      select a, b, c, d, e,
             count(distinct e) over (partition by a) num_distinct_values
      from my_table)
    where num_distinct_values <= 1
    order by 1
    / 
    

    The county notes how the distinct non-null values in column e for each one.
    Where clause then selects those with count = 0 (this is where e = null) and count = 1.
    If the number is greater than 1, different values exist for this id.

    Choose what fits your condition ;-)

  • DAQmx create track (I-current-Basic) 8 channels with different values of Shunt resistance

    Hello

    I want to measure 8 current channels with different values of Shunt resistance.

    Problem: The channel create DAQmx (HAVE current Basic) specifies that a value of Shunt resistance.

    How can I set the value of Shunt resistance for each channel individually?

    Concerning

    Marcel

    Hi Marcel_C,

    Take a look to get attached.

    Best regards

    Mencef

  • How to display the line empty as a line with null values

    Hi all

    Pls advise me if it is possible to use a single query statement to display
    Empty row (i.e. not a single return line) as a line with null values.

    For example,.

    Select the names of names_mst whose name = "sgasfgs".

    Result:
    Names of
    =====
    < null >

    Hello
    If you desire to join external to double, as shown below, you still get at least a line of production

    SELECT  nm.names
    FROM            dual
    LEFT OUTER JOIN names_mst   nm  ON nm.name='sgasfgs';
    
  • Pulling on the first line with a value of repetition

    Hello
    We use the Oracle 11.1.

    We have a table of postal codes.

    We have several lines for each zip code because we have different areas that use the same zip code.

    We want to reduce the lines of a line by zip code. But they said use they want to keep the fields that differ (neighborhood of the exodus).

    Then they said "Just take the first value of each."

    This code reduces the postcodes of a line by postal code, but as you can see I replaced the field with the name of the field values.
    SELECT distinct  ZIPCODE, CITY, STATE, COUNTY, AREACODE, 'CITYTYPE', CITYALIASABBREVIATION, 'CITYALIASNAME', LATITUDE, LONGITUDE, TIMEZONE, ELEVATION, COUNTYFIPS, DAYLIGHTSAVING, PREFERREDLASTLINEKEY, CLASSIFICATIONCODE,
               MULTICOUNTY, STATEFIPS, 'CITYSTATEKEY', 'CITYALIASCODE', 'PRIMARYRECORD', CITYMIXEDCASE, 'CITYALIASMIXEDCASE', STATEANSI, COUNTYANSI
        FROM   zip_code
    GROUP BY   ZIPCODE, CITY, STATE, COUNTY, AREACODE, CITYTYPE, CITYALIASABBREVIATION, LATITUDE, LONGITUDE, TIMEZONE, ELEVATION, COUNTYFIPS, DAYLIGHTSAVING, PREFERREDLASTLINEKEY, CLASSIFICATIONCODE, MULTICOUNTY, STATEFIPS,
               CITYALIASCODE, PRIMARYRECORD, CITYMIXEDCASE, STATEANSI, COUNTYANSI
    order by zipcode; 
    How should I take either one record per postal code with the first value in these fields or

    How should I take the first record for each zip code?

    either way works for me.

    Thank you

    Hello

    This is called a Query Top - N , and this is a way to do it:

    WITH     got_r_num     AS
    (
         SELECT     z.*
         ,     ROW_NUMBER () OVER ( PARTITION BY  zipcode
                                   ORDER BY          city
                             ,                ...   -- add tie-breakers here
                           )      AS r_num
         FROM    zip_code
    )
    SELECT     *     -- or list all columns except r_num
    FROM     got_r_num
    WHERE     r_num     = 1
    ;
    

    You can simply use MIN or MAX on the columns, as the line with the name of the minimum city do not lowest have area code or the longitude. The above method preserves the first line of each zip code intact, where the 'first': the first in order of aphabetic by the name of the city. If it is not unique, then you may want breakage to the analytical ORDER BY clause.

    If you are deleting rows, you can use this in a NOT IN subquery. If you copy lines to a new table, you can use the query above in an INSERT statement.

    Published by: Frank Kulash, March 18, 2011 12:40

    I just see Polywog response:

    Pollywog wrote:
    You can use the rank or rownumber function...

    If I understand the problem, you don't want to use RANK in this particular case. When there is equality, GRADE will assign 1 to all the contenders. I think the whole point of this thread is that you exactly want a #1 in each zip code, which is what ROW_NUMBER, but not RANK, guarantees.

  • Insert several lines with dynamic data

    Hello
    When I do an insert into a table that has several lines of dynamic information. on
    a page, it inserts all rows that are dynamically filled. I want only what he
    to insert the lines that I choose the initials on. How can I do? Let's say I
    have 5 items that are displayed on a page and I want to insert only original
    the first 2 because the last 3 are left blank, how should I do this? I tried
    implementation of an if statement that says:

    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    Then make the insertion in the table

    < cfelse >
    < / cfif >

    I have this game were also up in a loop that says:

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"

    Here is the code for just the insertion. I also have a code here
    Update another table. I got this to work, so I just try to get the insertion
    works fine for the moment. I can not use this where the query statement:
    Where ItemID = #id # because I'm trying to insert into the table of approval, not
    the items table. The table is just updated with some other info. in
    a few other input boxes.

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"
    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    < cfquery Datasource = '#application. DataSource #">"
    Insert into accreditation (APV_ItemID,
    APV_ECID,
    Document_Type,
    Approval_Initials)

    Values (' #Evaluate ("form.) (' ItemID # help # ") #',
    ' #Evaluate ("form. ("ECID # help #") #',
    < cfif isDefined (form '. ') ("Help of # PNR_Doc_Type # ') and
    "form. "Help of # PNR_Doc_Type #" NEQ "" > "".
    ' #Evaluate ("form. ("Help of # PNR_Doc_Type # ') #',
    < cfelse >
    NULL,
    < / cfif >

    < cfif isDefined (form '. ') ("Help of # PNR_Approval_Initials # ') and
    "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".
    ' #Evaluate ("form. (Aide de # PNR_Approval_Initials #») #
    < cfelse >
    Null value
    (< / cfif >)

    < / cfquery >

    < / cfif >
    < / cfloop >

    On the page display, just a table of dynamic info. Here are the 4
    things that I have on this page that needs to be inserted to the database.

    < input type = "hidden" name = "' ECID #ItemID #" value = "#ECID #" > "
    < input type = "hidden" name = "' ItemID #ItemID #" value = "#ItemID #" > "
    < input type = "hidden" name = "" PNR_Doc_Type #ItemID # ' value = "PNR Req" > "

    < td align = "center" >
    < cfif Approval_Initials is not "" > "".
    #Approval_Initials #.
    < cfelse >

    < select name = "PNR_Approval_Initials #ItemID #" >
    < option value = "" > select initials < / option >
    < cfloop query = "ShowInitials" >
    < Cfif Engineer_Initials EQ 1 >
    < option value = "#Initials #" > #Initials # < / option >
    < / cfif >
    < / cfloop >
    < / select >

    < / cfif >
    < table >

    Can someone help me please on just the insertion in the database so that it
    will insert on the lines that I chose the initials on and not others? Thank you.

    Andy

    You almost managed, but I see that you have commented.

    (" The help of # PNR_Approval_Initials # ') AND form ["PNR_Approval_Initials # help #" ""] NEQ "" >

    Do things here

  • Several channels with different frequencies

    Hello

    I use card NI USB-6221.

    The C API using, I need to generate 6 digital output channels, with frequencies of diffrenet and Heavy duty.

    To be more precise, the 2 are totally identical, but I need them to be reversed, and the other 4 are similar to another, but should be shifted in time (I.e. There is a delay between each of the channels).

    I used the 2 channels of CO that the USB-6221 takes charge for the first two signals, and it works very well (the two signals are synchronized and are reversed).

    Now I need an additional 4 channels for the other vague square.

    I saw an articale NOR by JohnP web site with the title:

    Generate multiple channels of digital output with different frequencies and Heavy Duty

    The following example shows how to create and generate a digital with the non-regeneration wave form so that you can change the frequency and the duty cycle on the fly with the M Series DAQ hardware X.  The example uses output digital rather than counters to achieve this, so if you need more output than the available counters, it would be a good option (Note: on the materials of the M series an external sample clock must be provided, this may be caused by one of the counters if you want).

    that seems to be exactly what I need, but the examples are for LabView which I did not.

    Can someone explain how to do this with the C functions?

    Best regards

    Danny.

    Hey Danny,

    The important thing to note is that you can clock of arbitrary digital waveform (up to 1 MHz on the 6221).  The real data acquisition programming is pretty easy once you have the waveform.  My Example LV used LabVIEW Base generating function VIand then converted to a digital waveform to generate the signal from each channel.

    The functions of LV helped tremendously with to achieve the waveforms to be updated on the fly (the basic function generator keeps track of phase for you).

    If you do not need to be updated on the fly, then the construction of the waveform in C should not be too bad.  For example:

    P0.0 [1 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0] * 1

    P0.1 [0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 0 0 0 0] * 2

    P0.2 [0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1] * 4

    P0.3 [1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1] * 8

    [9 9 9 9 9 3 3 3 3 3 6 6 6 6 6 12 12 12 12 12]

    The table above U8 would give you 4 output waveform of 50% duty cycle at Fs/20, shifted 90 degrees to eachother.  The lines would be p0.0 by p0.3 (the bit rate of the U8 corresponds to what line goes high).

    Best regards

  • Update records double with different data

    Hi all

    I have a specific problem of migration. Data from a large table were migrated in another table, but the data for the destination column are absent due to some problems (which are not specific to this topic).

    Currently I am updating the data for the missing column in the new table.

    The problem is due to the current data in the newtable, there the duplicate lines and I have not found a way to make a map of lines so that the data for the missing column can be updated.

    create the table ancienne_table

    (

    fileNo varchar (10),

    folder varchar (10),

    fileType varchar (10),

    col_1 varchar (10),

    col_2 varchar (10),

    col_3 varchar (10),

    col_4 varchar (10)

    );

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('ABC', "Folder1", "Type1", '111', '111', ' 111', null);

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('ABC', "Folder1", "Type2", '111', '111', ' 111', null);

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('GHI', 'Folder3', 'Type3', '333', '333', ' 333 ', ' 333');

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('JKL', 'Folder4', 'Type3', '444', '444', ' 444 ', ' 444');

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('MNO', 'Folder5', 'Type4', '555', '555', ' 555 ', ' 555');

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('PQR', 'Folder6', 'Type4', '666', '666', ' 666 ', ' 666');

    INSERT INTO ancienne_table (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('STU', 'Folder7', 'Type5', '777', '777', ' 777 ', ' 777')

    create table NewTable

    (

    fileNo varchar (10),

    folder varchar (10),

    fileType varchar (10),

    col_1 varchar (10),

    col_2 varchar (10),

    col_3 varchar (10),

    col_4 varchar (10)

    );

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('ABC', "Folder1", null, ' 111 ', '111' ', 111', null);

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('ABC', "Folder1", null, ' 111 ', '111' ', 111', null);

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('GHI', 'Folder3', null, '333 ', '333', '333' 333');

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('JKL', 'Folder4', null, '444 ', '444', '444' 444');

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('MNO', 'Folder5', null, '555 ', '555', '555' 555');

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('PQR', 'Folder6', null, '666 ', '666', '666' 666');

    INSERT INTO NewTable (fileNo, folder, file type, COL_1, COL_2, COL_3, COL_4) VALUES ('STU', 'Folder7', null, '777 ', '777', '777' 777')


    Select * from ancienne_table;

    FILENO FILETYPE COL_1, COL_2 COL_3 COL_4 FOLDER

    ---------- ---------- ---------- ---------- ---------- ---------- ----------

    Type1 Folder1 ABC 111 111 111

    Type2 Folder1 ABC 111 111 111

    IGS Folder3 Type3 333 333 333 333

    JKL Folder4 Type3 444 444 444 444

    Folder5 Type4 555 555 555 555 MNO

    nPQR Type4 of Folder6 666 666 666 666

    STU Folder7 777 777 777 777 Type5

    Select * from NewTable.

    FILENO FILETYPE COL_1, COL_2 COL_3 COL_4 FOLDER

    ---------- ---------- ---------- ---------- ---------- ---------- ----------

    Folder1 ABC 111 111 111

    Folder1 ABC 111 111 111

    IGS Folder3 333 333 333 333

    JKL Folder4 444 444 444 444

    Folder5 555 555 555 555 MNO

    PQR Folder6 666 666 666 666

    STU Folder7 777 777 777 777

    When you try to update the column of file type for all records-

    Update NewTable set FileType = (select FileType from ancienne_table where Fileno = newtable.fileNo and folder = NewTable. File);


    It would work fine for all other cases with the exception of the first two that are currently double.

    It won't work of course because it would give - "row subquery returns more rows" error because of these duplicate records.

    I'm trying to update the file type column to the first two rows with values 'Type1' and 'Type2 '.

    Out of these two files, it won't matter whose recording of newtable is updated with 'Type1' and you get 'Type2 '.

    Please help with ideas around update duplicate records with the ancienne_table-specific data into newtable.

    Him below will work... You can update using ROWID, but the lines are duplicated. Must therefore first to define any id for these two lines replicated using row_number and then correspond with rn for the IDENTIFIER specified.

    MERGE INTO NewTable nt help

    (WITH qry1 AS

    (SELECT ot. File type,

    ot.fileNo,

    OT. Folder,

    ROW_NUMBER() ON rn (PARTITION BY ot.fileNo, ot.folder ORDER BY 'A') - you can get the line number based on any order

    Of ancienne_table ot

    ),

    qry2 AS

    (SELECT nt. File type,

    nt.fileNo,

    NT. Folder,

    ROW_NUMBER() over (PARTITION BY nt.fileNo, nt.folder ORDER BY 'A') rn,-you can get the line number based on any order

    NT. ROWID rd

    OF NewTable nt

    )

    SELECT q1.filetype,

    Q2.Rd

    OF qry1 q1

    JOIN qry2 q2

    ON q1. Folder = q2. Folder

    AND q1.fileNo = q2.fileNo

    AND q1.rn = q2.rn

    AND q2. FileType IS NOTHING - if necessary add this condition

    ) q1 ON (nt. ROWID = q1.rd)

    WHEN MATCHED THEN

    Updated the VALUE of filetype = q1.filetype;

  • Return only the columns with different values.

    Hi all

    I am trying to solve a seemingly trivial problem but can't seem to get any clear answer anywhere in any forum. Consider a single table with 5 columns and only two lines:
    row_id           first_name         last_name        age            gender
    1                    John                  doe               27             M
    1                    Jane                  doe               27              F  
    Assume that there is no primary key or any other constraint. Also assume that there are only and only two lines of this table. So I need basically a query that, overall above lines, would return first name and sex, because they are only different columns in two lines, as well as their values. Even if I can get sort of column names that are different and that would be enough that I can easily access the values later. It is also important to remember that I may not know the names of the columns in the columns, so basically, somehow, I use user_tab_columns in the process.

    Any help appreciated.

    Published by: 894302 on May 1, 2013 10:35

    Hello

    894302 wrote:
    The exact release could be just a varchar variable that lists all the columns that have different values with each column name separated by commas. We'll call the query you want as a QUERY. So, if I do something like

    Select the REQUEST of double; Output should be: 'first_name, equality of the sexes. Is this possible?

    In this case:

    SELECT     RTRIM ( DECODE (a.row_id,     b.row_id,     NULL, 'row_id,')     ||
                    DECODE (a.first_name, b.first_name, NULL, 'first_name,') ||
              DECODE (a.last_name,  b.last_name,  NULL, 'last_name,')  ||
              DECODE (a.age,        b.age,          NULL, 'age,')      ||
              DECODE (a.gender,     b.gender,     NULL, 'gender,')
               , ','
               )          AS different_columns
    FROM     rhit_table_x  a
    JOIN     rhit_table_x  b  ON  a.ROWID     < b.ROWID
    ;
    

    Output:

    DIFFERENT_COLUMNS
    ---------------------------------------
    first_name,gender
    

    This assumes that you have really a table, then you can use ROWID to distinguish the lines, since there is no primary key.
    If this isn't the case, you first assign ROW_NUMBER in a subquery.

  • Need to update several lines in a multi-line table in another

    I came to the conclusion that I can't do that because of the absence of a unique key that is related, but maybe you can help me with a solution. I tried all of the solutions posted here, but they do not work in my scenario. I have codes in a table that is a list of codes to the related market which they should be used for. I have a second table of customers who do not have the code assigned to them until they are sent to an advertisement. This table has the market_id for each customer and the table of codes has the market_id associated with each code. I want to update the customer table with one of the associated with the market_id mergecodes - but between the two tables you isn't a unique key to connect. I thought I could just update the records which had corresponding market_ids, but nothing works. In the two tables below, I want to be able to update t3tm.mergecode with one of the mergecodes that has the same market_id ("Austin") in t3mc. It does not matter that it is associated with a particular customer.

    {code}

    create table T3mc (use of mergecode varchar (10), market_id varchar (25), week number, varchar2 (5));

    Insert into T3mc values ('A8976","Austin", 2,");
    Insert into T3mc values ('A8988","Austin", 2,");
    Insert into T3mc values ("A9900", "Houston", 2, ");
    commit;

    create table T3tm (name varchar (20), market_id varchar (25), mergecode varchar (10), identification number);

    insert into T3tm Values ('Smith', 'Austin' ", 1);
    insert into T3tm Values ("Jones", "Austin", ", 2);
    commit;
    {code}

    {code}
    Select * from T3mc;
    MARKET_ID, WEEK, USED, MERGECODE
    Austin 2 A8976 (null)
    Austin 2 A8988 (null)
    Houston 3 A9900 (null)
    Select * from T3tm;

    LAST_NAME, MARKET_ID, MERGECODE ID
    Austin Smith (null) 1
    Austin Jones (null) 2
    {code}

    ti3r wrote:
    In the two tables below, I want to be able to update t3tm.mergecode with one of the mergecodes that has the same market_id ("Austin") in t3mc. It does not matter that it is associated with a particular customer.

    {code}
    update of T3tm one
    Set mergecode =)
    Select mergecode
    of T3mc b
    where b.market_id = a.market_id
    and rownum = 1
    )
    where market_id in)
    Select market_id
    of T3mc
    )
    /

    2 lines to date.

    SQL > select *.
    2 of T3tm
    3.

    LAST_NAME MARKET_ID MERGECODE ID
    -------------------- ------------------------- ---------- ----------
    Austin A8976 Smith 1
    Austin A8976 Jones 2

    SQL >
    {code}

    SY.

  • Get several lines with the request - please help

    Hello

    I have query that gives me the output below.
    select distinct a.*,cu1.usr_key,cu1.first_nm,cu1.last_nm
    from(
          select ng.grp_key, ng.grp_nm , gt.grp_typ_nm, stts.nm as grp_sts, ng.expiry_date, ng.updt_dttm, stts.stts_key
          from new_group ng, user_group ug, group_type gt, status stts
          where ug.grp_key = ng.grp_key and ng.grp_typ_key = gt.grp_typ_key and 
          ng.stts_key = stts.stts_key and
          ug.usr_grp_rl_typ_key = 1 and 
          lower(ng.grp_nm) like 'test foe%'
          union 
          select ng.grp_key, ng.grp_nm , gt.grp_typ_nm, sts.nm as grp_sts, ng.expiry_date, ng.updt_dttm, sts.stts_key
          from new_group ng, group_type gt, status sts
          where ng.grp_typ_key = gt.grp_typ_key and ng.stts_key = sts.stts_key and 
          lower(ng.grp_nm) like 'test foe%')a, common_user cu1, user_group ug1
    where cu1.stts_key = a.stts_key and cu1.usr_key = ug1.usr_key and ug1.usr_grp_rl_typ_key = 1 and ug1.grp_key(+) = a.grp_key;
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 09.38.34 29742 Sam Saed
    18345 enemy test remove Group organization DELETED 9 February 12 09.38.34 AM 3 29643 dummyName514 dummy
    18345 enemy test remove Group organization DELETED February 9, 12 09.38.34 AM 3 28917 TestMObileUser Gujral
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 27284 Rocky jegou 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28920 Bhavani Gujral 09.38.34
    18345 enemy test remove Group organization DELETED 9 February 12 09.38.34 AM 3 29645 dummyFName516 dummy
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 27316 Karthik Gilani 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28147 Bowl David Mathews 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 09.38.34 29731 Sam Saed
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28919 Madhu mango 09.38.34

    For a group 18345, there are 10 users and this is the reason why I get a multiple user records.

    I can't avoid these last three columns, because I have to show these values in the application.

    In my opinion, the UNION is at the origin of the problem. Can I replace the UNION here? Please share your ideas on this.

    Thank you
    Rambeau

    Published by: ouali on February 9, 2012 22:35

    Hello

    because I have to show these values in the application.

    What is your problem then? If you simply issue a SELECT statement to application code or send the data back to REF CURSOR, it will be quite OK to have several lines. That's what the SELECT statements are for: to return sets of results with several lines.
    So, could not explain your problem more in detail please? If you get an error somewhere, provide the code causing the error and the error message (it is probably ORA-001422 exact extraction returns several lines somewhere in PL: / SQL, isn't it? then post here).

    In my opinion, the UNION is at the origin of the problem. Can I replace the UNION here? Please share your ideas on this.

    Us don't know not the answer to this question, because no one here knows your needs (what you need).

  • How can I update several lines based on the comparison of the fields table 1 and 2

    I create the following SQL to test what I found a method to update the records where the fields below the game, but what ends up happening is that the update functions works the first time and then basically updates everything to null. I don't understand what I'm doing wrong. New to this.

    UPDATE SLS_HDR B
    DEFINE (B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
    B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
    B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
    B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT, B.UPDATED_DT)
    (SELECT =
    A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
    A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
    A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2, A.PLAN_DEL_DT, A.TXTA, A.TXTB,
    A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT, A.PAY_CONTACT, A.ORD_AMT, SYSDATE
    Of
    SLS_HDR_TEMP HAS
    WHERE
    A.FIN_COMP = B.FIN_COMP AND
    A.LOG_COMP = B.LOG_COMP AND
    A.ORD_NO = B.ORD_NO AND
    A.TRANS_DT = B.TRANS_DT AND
    A.BP_TYPE = B.BP_TYPE AND
    A.STATUS <>B.STATUS);

    Can someone advise?
    Thank you

    Published by: 903292 on December 19, 2011 13:15

    you don't have a where clause in your update so no-matched lines will be updated with null values

    UPDATE SLS_HDR B
    SET ( B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
    B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
    B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
    B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT )
    = (
              SELECT
              A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
              A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
              A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
              A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE
              FROM
              SLS_HDR_TEMP A
              WHERE
              A.FIN_COMP = B.FIN_COMP AND
              A.LOG_COMP = B.LOG_COMP AND
              A.ORD_NO = B.ORD_NO AND
              A.TRANS_DT = B.TRANS_DT AND
              A.BP_TYPE = B.BP_TYPE AND
              A.STATUS= B.STATUS
         )
    WHERE EXISTS
    (
         select null from SLS_HDR_TEMP A
         WHERE
         A.FIN_COMP = B.FIN_COMP AND
         A.LOG_COMP = B.LOG_COMP AND
         A.ORD_NO = B.ORD_NO AND
         A.TRANS_DT = B.TRANS_DT AND
         A.BP_TYPE = B.BP_TYPE AND
         A.STATUS= B.STATUS
    )
    

    OR using Merge

    Merge into SLS_HDR B
    using SLS_HDR_TEMP A
    on (A.FIN_COMP = B.FIN_COMP AND
    A.LOG_COMP = B.LOG_COMP AND
    A.ORD_NO = B.ORD_NO AND
    A.TRANS_DT = B.TRANS_DT AND
    A.BP_TYPE = B.BP_TYPE AND
    A.STATUS= B.STATUS)
    when matched then update set (B.ORD_DT, B.SHIP_ADD_CD, B.INV_ADD_CD, B.LOB, B.STATUS,
    B.ORD_TYPE, B.HDR_ROUTE, B.PRICE_LIST, B.CUST_ORDER, B.REF_A, B.REF_B,
    B.ORD_REF, B.ORD_DISC, B.SREP, B.SREP2, B.PLAN_DEL_DT, B.TXTA, B.TXTB,
    B.INV_CONTACT, B.SHIP_CONTACT, B.SOLD_CONTACT, B.PAY_CONTACT, B.ORD_AMT,B.UPDATED_DT ) = (A.ORD_DT, A.SHIP_ADD_CD, A.INV_ADD_CD, A.LOB, A.STATUS,
    A.ORD_TYPE, A.HDR_ROUTE, A.PRICE_LIST, A.CUST_ORDER, A.REF_A, A.REF_B,
    A.ORD_REF, A.ORD_DISC, A.SREP, A.SREP2,A.PLAN_DEL_DT, A.TXTA, A.TXTB,
    A.INV_CONTACT, A.SHIP_CONTACT, A.SOLD_CONTACT,A.PAY_CONTACT, A.ORD_AMT, SYSDATE)
    

    HTH...

    Thank you

Maybe you are looking for