rows with the same value
HelloI have this request:
Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;
By request I see the lines where the handle columns have the same values?
Thank you.
Hello
First thing is that your question is very abstract, we can not know which data table you is central to the present moment.
Select b.db_name, a.handle from bp a, dbinc b where a.db_key = b.db_key;
By request I see the lines where the handle columns have the same values?
What you mean you 'same' values with what data need to be compared to 'the same '.
Fact it is same or some values.
-Pavan Kumar N
Tags: Database
Similar Questions
-
Grouping of consecutive rows with the same value?
Hello
I have a table in which are three columns:
ROWID is a primary key with a unique ID columnROWID SHOPNAME 1 SHOP_C 2 SHOP_A 3 SHOP_C 4 SHOP_C 5 SHOP_A 6 SHOP_A 7 SHOP_C 8 SHOP_B 9 SHOP_B 10 SHOP_E 11 SHOP_A 12 SHOP_D 13 SHOP_D 14 SHOP_F 15 SHOP_G 16 SHOP_F 17 SHOP_C 18 SHOP_C 19 SHOP_C 20 SHOP_C
Shopname is varchar2 column
I want to make groupings of each value 'shopname""order by ROWID"such that when there are consecutive lines of the same group shopname remains same and as soon as there is a different value in shopname column for the next line changes to"group ".
My desired output is with the 3rd column of groups as follows:
I want be done via Analytics, so that I can partition by clause for different stores in different citiesROWID SHOPNAME Groups 1 SHOP_C 1 2 SHOP_A 2 3 SHOP_C 3 ------> same grouping because Shop name is same 4 SHOP_C 3 ------> same grouping because shop name is same 5 SHOP_A 4 ----> different shopname so group changed. 6 SHOP_A 4 ----> same group as above because shopname is same 7 SHOP_C 5 8 SHOP_B 6 9 SHOP_B 6 10 SHOP_E 7 11 SHOP_A 8 12 SHOP_D 9 13 SHOP_D 9 14 SHOP_F 10 15 SHOP_G 11 16 SHOP_F 12 17 SHOP_C 13 18 SHOP_C 13 19 SHOP_C 13 20 SHOP_C 13
concerning
Ramis.with data(row_id, shop) as ( select 1, 'SHOP_C' from dual union all select 2, 'SHOP_A' from dual union all select 3, 'SHOP_C' from dual union all select 4, 'SHOP_C' from dual union all select 5, 'SHOP_A' from dual union all select 6, 'SHOP_A' from dual union all select 7, 'SHOP_C' from dual union all select 8, 'SHOP_B' from dual union all select 9, 'SHOP_B' from dual union all select 10, 'SHOP_E' from dual union all select 11, 'SHOP_A' from dual union all select 12, 'SHOP_D' from dual union all select 13, 'SHOP_D' from dual union all select 14, 'SHOP_F' from dual union all select 15, 'SHOP_G' from dual union all select 16, 'SHOP_F' from dual union all select 17, 'SHOP_C' from dual union all select 18, 'SHOP_C' from dual union all select 19, 'SHOP_C' from dual union all select 20, 'SHOP_C' from dual ), get_data as ( select row_id, shop, lag(shop) over (order by row_id) prev_shop from data ) select row_id, shop, sum(case when shop = prev_shop then 0 else 1 end ) over (order by row_id) grps from get_data; ROW_ID SHOP GRPS ------ ------ ---- 1 SHOP_C 1 2 SHOP_A 2 3 SHOP_C 3 4 SHOP_C 3 5 SHOP_A 4 6 SHOP_A 4 7 SHOP_C 5 8 SHOP_B 6 9 SHOP_B 6 10 SHOP_E 7 11 SHOP_A 8 12 SHOP_D 9 13 SHOP_D 9 14 SHOP_F 10 15 SHOP_G 11 16 SHOP_F 12 17 SHOP_C 13 18 SHOP_C 13 19 SHOP_C 13 20 SHOP_C 13 20 rows selected
-
With one of several rows with the same value for the same ID
Hello
I have this request:
SELECT
Count (case when EXISTS ())
SELECT *.
FROM business_log bl, su topic
WHERE su.ID_SUBJECT = s.ID_SUBJECT
and bl.id_subject = su.id_subject
AND bl.value = 'resolved '.
)
then 1 end another null) num_solved
OF THE subject
It is possible that a subject is more than once 'resolved' in the table BUSINESS_LOG
I want to count only one line solved for a topic.
I need to use only under RESERVE the table in the main query due to other counts.
Thank you very much.
Concerning
Milos
Post edited by: 2796614
in the examples before we talked abount 'Resolved' instead of 'resolved' as in your last example... to let you know, how it is stored.
I had advice is not to use SEPARATE.
So what... the evidence that any other question is faster than anything goes business_log, filter lines and can count distinct keys...
separate within a group function is not the same thing as do select distinct...
HTH
-
An update on an index column with the same value generates an index to the top
An update on an index column with the same value generates an update of the index?
Thank youIn addition to my previous answer, see also
http://orainternals.WordPress.com/2010/11/04/does-an-update-statement-modify-the-row-if-the-update-modifies-the-column-to-same-value/
Riyaj Shamsudeen has this to say:
"+ We have an index on this column v1 and we update this column indexed too." Oracle was updating the indexed column? N ° if the values match the level of the indexed column, then the code of RDBMS isn't up-to-date index, a feature for optimization again. Only the row of table is updated, and the index is not updated. + "Hemant K Collette
-
Photos with the same values of position...
I have a picture with the edited/customized position values (scale, rotation, inclination, perspective, disort, warp)... I have some photos that will be on the different layers and I want that they have the same values as the first (it's stupid to do the same thing with 10 photos...) I tried to duplicate the layers and replacement is contained, but values are lost, so the photos appear in the normal position...
So how can guys, I do this?
For this to work properly, all images must be of the same size and resolution.
- Integrate the file of the first image.
- Layer > Smart object > convert to smart object
- Edit > free transform and establish the size, position and orientation... .OK
- Cmd + J to create a layer of dupe
- Layer > Smart Object > replace content
- Choose the following image > replace
Repeat steps 4-6
-
Is it possible that I can select an object or objects that have a value of mixed CMYK or Grayscale, and then select a Spot color and it will keep the same value of midtones as before?
For example, I have an object that is C: 0 M: 0 Y: 0 k: 20 and I select Reflex Blue. What is happening is it change my object to 100% Reflex Blue. Is there a way to change to automaitically Reflex Blue 20%?
Another example, I have 3 objects, one is 20 k: the second is 40 k: and the third is KC: 85. I want to select all the objects in three at the same time, select Yellow PANTONE and get them to change yellow PANTONE 20, 40 yellow PANTONE and PANTONE yellow 85.
Is there a way to do it or I will always have to manually edit each element?
Thanks for the help.
Select the elements to recolor
Edit > edit colors > redefine > follow my screenshots
I love clicking this button under the entitlement, one place for everything that you color reduction settings.
Use tinted scale. Exact will give you 100% of the color. The exact word is confusing here, this means that the color of the destination (100% of everything that the color you choose), not a version tinged scale.
Unfortunately I do not know how to get the exact values of blacks to convert the exact values of spot color. Scale of hues will you get you get you close enough for what you need. In my example that a black 89% converts a 84% of the place, so no exact but alteast I have a range of shades, and sometimes the results are better than accurate, depends on your art.
Here are my before and after.
-
update other items with the same value when when the column contains Y
If you notice the table above which im trying to Edifier is updated the errorred column with 'Y' if the po and invoice are the same and have a 'Y' on the wrong column.CREATE TABLE TEST ( "QUATINTY" NUMBER(17,2), "AMOUNT" NUMBER(17,2), "ERRORRED" VARCHAR2(16 BYTE), "PO" VARCHAR2(12 BYTE), "LINE" VARCHAR2(10 BYTE), "SEQ" VARCHAR2(14 BYTE), "INVOICE" VARCHAR2(16 BYTE) ) Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('123',5,50,'Y','1','1','inv1'); Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('123',5,50,null,'1','2','inv1'); Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('125',5,50,null,'1','1','inv2'); Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('125',4,50,null,'1','2','inv2');
in other words, I should finish with "Y" in the column for INV1 errorred.
Can someone point me in the right direction, I can't for the life of me figuered it out.Hello
Here's one way:
UPDATE test SET errorred = 'Y' WHERE NVL (errorred, 'N') != 'Y' AND (po, invoice) IN ( SELECT po, invoice FROM test WHERE errorred = 'Y' ) ;
This requires that the po and invoice are not NULL. If a column can be NULL, then the solution might be a little messier, according to the results you want, but only a little. Post some sample data (with null values) which shows what types of situations, you need manage, and the results of the SAMPLES.
-
Bind variables (how replace the placeholders with the same value?)
Hello, I have a code like this:
The variable v_query contains:procedure getAllTasks(o_cursor in out PKG_APPLICATION.rc, in_filter_project_id in T_FCT_TASK.project_id%type default -1, in_filter_scope_id in T_FCT_TASK.scope_id%type default -1, in_filter_user_creator_id in T_FCT_TASK.user_creator_id%type default -1, in_filter_priority_id in T_HST_TASK.priority_id%type default -1, in_filter_status_id in T_HST_TASK.status_id%type default -1, in_filter_user_responsible_id in T_HST_TASK.user_responsible_id%type default -1, in_pagination_first in integer, in_pagination_last in integer) is v_query varchar2(4000) := v_query_allTasks || v_query_whereFilter; begin PKG_APPLICATION.setPagination(v_query); PKG_LOG.debug('query: ' || v_query, PCK); open o_cursor for v_query using in_filter_project_id, in_filter_scope_id, in_filter_user_creator_id, in_filter_priority_id, in_filter_status_id, in_filter_user_responsible_id, in_pagination_last, in_pagination_first; end;
Note that placeholders: 1: 2,...: 5 appears 2 times in the query.SELECT * FROM (SELECT A.*, ROWNUM AS RNUM FROM ( SELECT task_id, project_id, project_name, scope_id, scope_name, user_creator_id, user_creator_login, title, description, priority_id, priority_name, status_id, status_name, user_responsible_id, user_responsible_login, due_date, last_modified_by_id, last_modified_by_login, last_modified FROM V_FCT_TASK WHERE project_id = decode(:1, -1, project_id, :1) and scope_id = decode(:2, -1, scope_id, :2) and user_creator_id = decode(:3, -1, user_creator_id, :3) and priority_id = decode(:4, -1, priority_id, :4) and status_id = decode(:5, -1, status_id, :5) and user_responsible_id = decode(:6, -1, user_responsible_id, :6) ) A WHERE ROWNUM <= :LAST) WHERE :FIRST <= RNUM
Is there a more elegant way to say that *: 1 * must be replaced by in_filter_project_id, *: 2 * by in_filter_scope_id without having twice in the USING clause these variables? If this is not the case, why the placeholders have name, if you can only refer to their position (order)?
Thanks for all replies.Hi Adam,.
text taken from http://download.oracle.com/docs/cd/B10501_01/appdev.920/a96624/11_dynam.htm
Duplicate use of Placeholders
Placeholders in a dynamic SQL statement associated with the arguments of bind in the USING clause of position, and not by name. Thus, if the same placeholder appears two times or more in the SQL statement, each appearance must correspond to a bind argument in the USING clause. For example, if the dynamic string
sql_stmt := 'INSERT INTO payroll VALUES (:x, :x, :y, :x)';
you could code the corresponding USING clause as follows:
EXECUTE IMMEDIATE sql_stmt USING a, a, b, a;
However, only the unique placeholders in a dynamic PL/SQL block are associated with bind arguments in the USING clause of position. Thus, if the same placeholder appears two times or more in a PL/SQL block, all appearances correspond to a single argument to bind in the USING clause. In the example below, the first unique placeholder (x) is associated with the first bind argument (one). Similarly, the second unique space reserved (y) is associated with the second argument to bind (b).
DECLARE a NUMBER := 4; b NUMBER := 7; BEGIN plsql_block := 'BEGIN calc_stats(:x, :x, :y, :x); END;' EXECUTE IMMEDIATE plsql_block USING a, b; ... END;
Hope this helps
Christian Balz -
Hello
I have the following table:
create the table pp_status (ppid number (10), ppdescr varchar2 (20),)
(1) number, varchar2 (4)) bordered;
The ppid is the primary key.
where: the ppid Gets the values of a sequence, status may have values (0, 1, 2) and bordered of... years.
Thus, some values of line may be as follows:
insert into pp_status values(1,'XX',0,'2009');
insert into pp_status values(2,'XXY',0,'2010');
insert into pp_status values(3,'XXT',1,'2009');
.....
Now, I want to impose a business rule in which declaratively:
If and only if both lines have values of shell (as in row 1, 3 in the example above lines) but different data values in the neck of status (and specifically the values 0 and 1 (not 2), as in the lines of the sample 1 and 3) then the second row (that is, the third row in the whole of the sample) is permitted , otherwise not. For example, the following lines:
insert into pp_status values(3,'XXT',2,'2009'); {because of the whole first line was inserted}
insert into pp_status values(3,'XXT',0,'2009'); {because of the whole first line was inserted}
should not be allowed...
Is it possible to achieve without writing code... I mean the declaratively.
Note: I use DB10g v.2
Thank you
SIMSIM,
It's an interesting challenge, which requires two unique indexes to solve declaratively:
SQL> create table pp_status(ppid number(10),ppdescr varchar2(20), 2 status number(1) check (status in (0,1,2)),firstyear varchar2(4)); Tabel is aangemaakt. SQL> create unique index ui1 on pp_status (firstyear,decode(status,2,0,status)) 2 / Index is aangemaakt. SQL> create unique index ui2 on pp_status (firstyear,decode(status,2,1,status)) 2 / Index is aangemaakt. SQL> insert into pp_status values(1,'XX',0,'2009'); 1 rij is aangemaakt. SQL> insert into pp_status values(2,'XXY',0,'2010'); 1 rij is aangemaakt. SQL> commit 2 / Commit is voltooid. SQL> insert into pp_status values(3,'XXT',2,'2009'); insert into pp_status values(3,'XXT',2,'2009') * FOUT in regel 1: .ORA-00001: Schending van UNIQUE-beperking (RWIJK.UI1). SQL> insert into pp_status values(3,'XXT',0,'2009'); insert into pp_status values(3,'XXT',0,'2009') * FOUT in regel 1: .ORA-00001: Schending van UNIQUE-beperking (RWIJK.UI1). SQL> insert into pp_status values(3,'XXT',1,'2009'); 1 rij is aangemaakt.
Kind regards
Rob.PS: why the hell proclaim the year varchar2 (4) instead of number 4?
-
Update of column with the same value of the column
Hello
I have a scenario like below:
SRC TAR RSRC FLG
EN101 1001 1001 Y1002 EN101 N
1003 EN101 NSince then, my flag is there for the first record, I have identical RSRC of the CBC. Now, I need RSRC 1001 value for 2 other records as the value of these recordings is N and the target is EN101.
All of the suggestions.
Thank you
merge into your_table t
a_l'_aide_de)
Select
tar
min (rsrc) rsrc
from your_table
where flg = 'Y '.
Group of tar
) u
on (t.tar = u.tar)
when matched
update the value t.rsrc = u.rsrc
where t.rsrc is null
-
get the index of the same values in table
Hi guys,.
I'm trying to get the index of array elements with the same value but it can solve mine.
my case is:
array1 = [1,2,3,4]; <-here are the names of the pages, always in the order of CSA (these table I used only to check the results of my work, probably will not be for you but maybe...)
array2 = [1,1,2,2,2,3,4,4,4]; <-these numbers are random, but always in the CSA order (these are the names of pages for items in table 3)
array3 = [a, b, g, i, f, e, c, h, d]; <-these are all the values of the elements I want to work with later. number of articles is still the same as in array2, their indexes are corresponding.
array4 = [];
I need to remove array3 everything, but one of each issue of array2 (as I will remove duplicates) or push to array4 an article of array3 for each number of the array array2 (as I'm going to ignore duplicates)
don't know is my desc is clear enough, but the result I get is:
ex. [a, g, e, c]
above example for each number of array2 array3 items, but do not have to be first, can be second or third if etc exist, but have to be alone.
I thought that if I get duplicate values, the index in the array array2 and delete this index in array3 will get what I want, but can not solve.
You will appreciate all help.
Thank you
Try something like this:
var array2 = [1,1,2,2,2,3,4,4,4]; var array3 = ["a","b","g","i","f","e","c","h","d"]; var tempArray = []; var resultArray = []; var n , x ; for(var n=array2.length-1;n>=0;n--) { var string = ""+array2[n]; tempArray[string] = array3[n]; } for(x in tempArray) { resultArray.push(tempArray[x]); } resultArray.reverse(); // a,g,e,c
Hope, that helps.
Uwe
-
GL CCID have the same values for Segment
Is it possible that two different code_combination_id in the same GL_Code_Combination table has the same values for segment.
It is, when I run the accounts payable balance report trial of the responsibility of the PA, its follow-up of the transactions ID associated with only 1 and not both.
But, here, for the same Chart_of_Accounts_Id, we can see that there are two Code_combination_id entries, with the same values for segment.
Can you please let me know if this is possible?
For example: I'm running the following queries and Segment1, Segment2, Segment3, Segment4, 12855 CCId values Segment5 is the same as Segment1, Segment2, Segment5, Segment4, Segment3 to 13402.
Select CODE_COMBINATION_ID, CHART_OF_ACCOUNTS_ID,
SEGMENT1, SEGMENT2 SEGMENT3, SEGMENT4, ENABLED_FLAG, SEGMENT5,
* of the GL_CODE_COMBINATIONS where CODE_COMBINATION_ID = 12855
Select CODE_COMBINATION_ID, CHART_OF_ACCOUNTS_ID,
SEGMENT1, SEGMENT2 SEGMENT3, SEGMENT4, ENABLED_FLAG, SEGMENT5,
* of the GL_CODE_COMBINATIONS where CODE_COMBINATION_ID = 13402
CCID - Segment1, Segment2, Segment3, Segment4, Segment5
-----------------------------------------------------------------------------------------------
12855 01 000 2220 00000 000
13402 01 000 2220 00000 000
I hope you understand.
Thank you
BobHi Bob,
Can you please check the id of chart of accounts for the two combinations...
Concerning
MuthuPublished by: Muthu on April 30, 2013 02:10
-
Mr President.
My worm jdev is 12.2.1
How to enter two rows at the same time with different default values that only the first line to use see?
Suppose I have a table with four fields as below
"DEBIT" VARCHAR2(7) , "DRNAME" VARCHAR2(50), "CREDIT" VARCHAR2(7) , "CRNAME" VARCHAR2(50),
Now I want that when I click on a button (create an insert) to create the first line with the default values below
So if I click on the button and then validate the second row with different values is also inserted on commit.
The value of the second row are like the picture below
But the second row should be invisible. It could be achieved by adding vc in the vo.
The difficult part in my question is therefore, to add the second row with the new default values.
Because I already added default values in the first row.
Now how to add second time default values.
Concerning
Mr President
I change the code given by expensive Sameh Nassar and get my results.
Thanks once again dear Sameh Nassar .
My code to get my goal is
First line of code is
protected void doDML(int operation, TransactionEvent e) { if(operation != DML_DELETE) { setAmount(getPurqty().multiply(getUnitpurprice())); } if (operation == DML_INSERT ) { System.out.println("I am in Insert with vid= " + getVid()); insertSecondRowInDatabase(getVid(),getLineitem(),"6010010","SALES TAX PAYABLE", (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } if(operation == DML_UPDATE) { System.out.println("I am in Update with vid= " + getVid()); updateSecondRowInDatabase(getVid(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } super.doDML(operation, e); } private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4, Object value5) { PreparedStatement stat = null; try { String sql = "Insert into vdet (VID,LINEITEM,DEBIT,DRNAME,AMOUNT) values " + "('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "','" + value5 + "')"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } } private void updateSecondRowInDatabase(Object value1, Object value5) { PreparedStatement stat = null; try { String sql = "update vdet set AMOUNT='"+ value5+"' where VID='" + value1 + "'"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
Second line code is inside a bean method
public void addNewPurchaseVoucher(ActionEvent actionEvent) { // Add event code here... BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator"); RowSetIterator rsi = dciter.getRowSetIterator(); Row lastRow = rsi.last(); int lastRowIndex = rsi.getRangeIndexOf(lastRow); Row newRow = rsi.createRow(); newRow.setNewRowState(Row.STATUS_NEW); rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow); rsi.setCurrentRow(newRow); BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator"); RowSetIterator rsi1 = dciter1.getRowSetIterator(); Row lastRow1 = rsi1.last(); int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1); Row newRow1 = rsi1.createRow(); newRow1.setNewRowState(Row.STATUS_NEW); rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1); rsi1.setCurrentRow(newRow1); }
And final saveUpdate method is
public void saveUpdateButton(ActionEvent actionEvent) { // Add event code here... BindingContainer bindingsBC = BindingContext.getCurrent().getCurrentBindingsEntry(); OperationBinding commit = bindingsBC.getOperationBinding("Commit"); commit.execute(); OperationBinding operationBinding = BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit"); operationBinding.execute(); DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("VdetView1Iterator");// write iterator name from pageDef. iter.getViewObject().executeQuery(); }
Thanks for all the cooperation to obtain the desired results.
Concerning
-
update to column values (false) in a copy of the same table with the correct values
Database is 10gr 2 - had a situation last night where someone changed inadvertently values of column on a couple of hundred thousand records with an incorrect value first thing in the morning and never let me know later in the day. My undo retention was not large enough to create a copy of the table as it was 7 hours comes back with a "insert in table_2 select * from table_1 to timestamp...» "query, so I restored the backup previous nights to another machine and it picked up at 07:00 (just before the hour, he made the change), created a dblink since the production database and created a copy of the table of the restored database.
My first thought was to simply update the table of production with the correct values of the correct copy, using something like this:
Update mnt.workorders
Set approvalstat = (select b.approvalstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
where exists (select *)
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi)
It wasn't the exact syntax, but you get the idea, I wanted to put the incorrect values in x columns in the tables of production with the correct values of the copy of the table of the restored backup. Anyway, it was (or seem to) works, but I look at the process through OEM it was estimated 100 + hours with full table scans, so I killed him. I found myself just inserting (copy) the lines added to the production since the table copy by doing a select statement of the production table where < col_with_datestamp > is > = 07:00, truncate the table of production, then re insert the rows from now to correct the copy.
Do a post-mortem today, I replay the scenario on the copy that I restored, trying to figure out a cleaner, a quicker way to do it, if the need arise again. I went and randomly changed some values in a column number (called "comappstat") in a copy of the table of production, and then thought that I would try the following resets the values of the correct table:
Update (select a.comappstat, b.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi - this is a PK column
and a.comappstat! = b.comappstat)
Set b.comappstat = a.comappstat
Although I thought that the syntax is correct, I get an "ORA-00904: 'A'. '. ' COMAPPSTAT': invalid identifier ' to run this, I was trying to guess where the syntax was wrong here, then thought that perhaps having the subquery returns a single line would be cleaner and faster anyway, so I gave up on that and instead tried this:
Update mnt.workorders_copy
Set comappstat = (select distinct)
a.comappstat
mnt.workorders a, mnt.workorders_copy b
where a.workordersoi = b.workordersoi
and a.comappstat! = b.comappstat)
where a.comappstat! = b.comappstat
and a.workordersoi = b.workordersoi
The subquery executed on its own returns a single value 9, which is the correct value of the column in the table of the prod, and I want to replace the incorrect a '12' (I've updated the copy to change the value of the column comappstat to 12 everywhere where it was 9) However when I run the query again I get this error :
ERROR on line 8:
ORA-00904: "B". "" WORKORDERSOI ": invalid identifier
First of all, I don't see why the update statement does not work (it's probably obvious, but I'm not)
Secondly, it is the best approach for updating a column (or columns) that are incorrect, with the columns in the same table which are correct, or is there a better way?
I would sooner update the table rather than delete or truncate then re insert, as it was a trigger for insert/update I had to disable it on the notice re and truncate the table unusable a demand so I was re insert.
Thank youHello
First of all, after post 79, you need to know how to format your code.
Your last request reads as follows:
UPDATE mnt.workorders_copy SET comappstat = ( SELECT DISTINCT a.comappstat FROM mnt.workorders a , mnt.workorders_copy b WHERE a.workordersoi = b.workordersoi AND a.comappstat != b.comappstat ) WHERE a.comappstat != b.comappstat AND a.workordersoi = b.workordersoi
This will not work for several reasons:
The sub query allows you to define a and b and outside the breakets you can't refer to a or b.
There is no link between the mnt.workorders_copy and the the update and the request of void.If you do this you should have something like this:
UPDATE mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE SET A.comappstat = ( SELECT B.comappstat FROM mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) WHERE EXISTS ( SELECT B.comappstat FROM mnt.workorders_copy B WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat )
Speed is not so good that you run the query to sub for each row in mnt.workorders
Note it is condition in where. You need other wise, you will update the unchanged to null values.I wouold do it like this:
UPDATE ( SELECT A.workordersoi ,A.comappstat ,B.comappstat comappstat_OLD FROM mnt.workorders A -- THIS IS THE TABLE YOU WANT TO UPDATE ,mnt.workorders_copy B -- THIS IS THE TABLE WITH THE CORRECT (OLD) VALUES WHERE a.workordersoi = b.workordersoi -- THIS MUST BE THE KEY AND a.comappstat != b.comappstat ) C SET C.comappstat = comappstat_OLD ;
This way you can test the subquery first and know exectly what will be updated.
This was not a sub query that is executed for each line preformance should be better.Kind regards
Peter
-
Guest with 2 rows on the same data
Hello..
I got the task to compare the data of 2 months.
I want to choose these months in a command prompt with 2 rows of type drop-down list which get on the same data.
(I don't want to use a multi-select-box, because I write the values in variables).
the problem is that guests get the same value and do not have the correct variables, when I push the go button.
anyone has a solution for my problem.
or an idea how to solve the demand?
GreetzHello. Do not use is between. Use separate guests. You can then define each variable.
Try this in the dash prompt (in the form of changing column):
Months of:
cases where 1 = 2 then "at other TIMES. End CALENDAR_MONTH_DESC
Presentation set variable pv_month_fromYou add the second line of the month:
Months to:
cases where 1 = 2 then "at other TIMES. End CALENDAR_MONTH_DESC
Presentation set variable pv_month_toIn responses set manually filter filter:
"DimTable.month_desc_column between ' @{pv_month_from}' and ' @{pv_month_to}"Concerning
Goran
http://108obiee.blogspot.com
Maybe you are looking for
-
My new tab of the page was created in google for a year. Now, it suddenly started the default page, despite the fact that it is set on google about opening: config. I reset and rebooted, and still, it opens by default.
-
ICloud is player takes storage from my hard drive on my iMac or not? How will I know?
-
Compaq c500: memory no upgrade no good compaq C
People from forum good day. I have another question, that I can't understand, but I have my suspicions. I upgraded a compaq c500 P T2080 double XP to win 7 x 32. It came with 2 GB ram. I tried to put in 1 gig to do 3, then 2 + 2 to 4. In both cases,
-
Problem with the connection to USB6008 OR LabWindows
Hello world I make a program in LabWindows and so far, I've had two instruments running without any problem. But I try to add a USB6008 OR the program. I downloaded something called "NIDAQmxBase" and has added a file called "NIDAQmxBase.h" but I can´
-
System drive do not defragment
The player 'System' does not defrag when I run Win7 Disk Defragmenter. Any suggestions on how I can get the system drive to defragment. He is currently 14% of fragmentation.