Updated value for bubble value in other rows
Hello everyone, I have a table with structure below. Each user is allowed to have atmost three values (i.e. 1,2,3) for sort_id and this validation is done from the front end application. Now I need a stored procedure where if a user has 1, sort_id 2 and it enters a value plus 1 existing values should be updated as 2.3. Finally, the input value must be inserted and user will now have 3 rows. The same way if they specify 2, the other two will have 1 and 3. If they specify 3, the other two will be 1 and 2.
CREATE TABLE sort_test (usr_id Varchar2(10), sort_id NUMBER(2)); INSERT INTO sort_test VALUES('JOHN',1); INSERT INTO sort_test VALUES('JOHN',2); INSERT INTO sort_test VALUES('JOHN',3); INSERT INTO sort_test VALUES('MILLER',1); INSERT INTO sort_test VALUES('MILLER',2); SELECT * FROM sort_test;
In the above example if MILLER between value 1 again then existing values should be changed to 2.3.
Try the below
CREATE OR REPLACE PROCEDURE proc_sort (p_usr_id sort_test.usr_id%TYPE,
p_sort_id sort_test.sort_id%TYPE
)
AS
v_cnt NUMBER;
BEGIN
SELECT COUNT (*) IN v_cnt
OF sort_test
WHERE usr_id = p_usr_id
AND sort_id = p_sort_id;
IF v_cnt > = 1 THEN
Setting a DAY sort_test st SET sort_id = (SELECT sort_id1 FROM (SELECT usr_id,
sort_id,
CASE WHEN p_sort_id = 1 THEN DECODE (ROW_NUMBER () OVER (PARTITION BY usr_id ORDER BY sort_id), 1,2, 3)
WHEN p_sort_id = 2 THEN DECODE (ROW_NUMBER () OVER (PARTITION BY usr_id ORDER BY sort_id), 1, 1, 3)
WHEN p_sort_id = 3 THEN DECODE (ROW_NUMBER () OVER (PARTITION BY usr_id ORDER BY sort_id), 1, 1, 2).
END AS sort_id1
OF sort_test st1
WHERE usr_id = p_usr_id) qry1
WHERE st.usr_id = qry1.usr_id
AND qry1.sort_id = st.sort_id)
WHERE usr_id = p_usr_id;
INSERT INTO sort_test VALUES (p_usr_id, p_sort_id);
ON THE OTHER
INSERT INTO sort_test VALUES (p_usr_id, p_sort_id);
END IF;
COMMIT;
EXCEPTION
WHILE OTHERS THEN
LIFT;
Proc_sort END;
Tags: Database
Similar Questions
-
How to update columns with the value of other lines in the same table
Hello
I use Oracle 11.2, I'd use SQL statements to update a column based on values in other rows in the same table. Here are the details:
create table TB_test (number 4 myId, crtTs date, date of MDPU);
insert into tb_test (1, to_date ('20110101', 'YYYYMMDD'), null);
insert into tb_test (1, to_date ('20110201', 'YYYYMMDD'), null);
insert into tb_test (1, to_date ('20110301', 'YYYYMMDD'), null);
insert into tb_test (2, to_date ('20110901', 'YYYYMMDD'), null);
insert into tb_test (2, to_date ('20110902', 'YYYYMMDD'), null);
After you run the SQL code, I would like to have the following result:
1, 20110101, 20110201
1, 20110201, 20110301
1, 20110301, null
2, 20110901, 20110902
2, 20110902, null
Thanks for your suggestion.I guess you need this, otherwise please explain logic correctly:
SQL> merge into tb_test t 2 using ( 3 select rowid as rid 4 , lead(crtts) over(partition by myid order by crtts) as updts 5 from tb_test 6 ) v 7 on (t.rowid = v.rid) 8 when matched then update 9 set t.updts = v.updts 10 ; 5 rows merged. SQL> select * from tb_test order by 1,2; MYID CRTTS UPDTS ---------- --------- --------- 1 01-JAN-11 01-FEB-11 1 01-FEB-11 01-MAR-11 1 01-MAR-11 2 01-SEP-11 02-SEP-11 2 02-SEP-11
-
request to retrieve the value of the column and use in the other rows of the table
Hi all
I have a table where I maintain pairs name / value of a particular job. Now, I would like to see some of the values of the rows passed to other rows in a table for example
create job_name_value
(
VARCHAR2 (100) job_name,.
name varchar2 (100),
value varchar2 (100)
);
job_name name value TRGJOB % FPATH / USR/LOCAL/TRGJOB TRGJOB % FDATE CALDATE + 1 TRGJOB $FNAME1% %FPATH.mywatchfile1.%FDATE TRGJOB FNAME2% %FPATH.mywathcfile2.%FDATE TRGJOB % FNAME3 %FPATH.mywatchfile3.%FDATE can we write a sql query to produce output as below the objective is to use the value of fdate and fpath in the remaining lines. If there is no fdate and fpath then value should return such what or we need to use the stored procedure to achieve
/ usr/local/trgjob/mywatchfile1. CALDATE + 1
/ usr/local/trgjob/mywatchfile2. CALDATE + 1
/ usr/local/trgjob/mywatchfile3. CALDATE + 1
Hello
Since it cannot be '% FDATTE' or '% FPATH' (or both) then you need to replace each of them separately. If the other does not, there 'replacement' will do nothing, but this will not affect the result of the other.
Here's a way to do it:
SELECT REPLACE (REPLACE (n.value
'% FPATH.'
p.value | '/'
)
, '% FDATE '.
d.value
) AS output_value
OF job_name_value n
LEFT OUTER JOIN job_name_value p ON p.name = '% f '.
LEFT OUTER JOIN job_name_value d ON p.name = '% FDATE '.
WHERE n.name AS '\%FNAME%' ESCAPE ' \'
;
I hope that answers your question.
If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.
Report when the above query is to give erroneous results and explain, using specific examples, how to get the correct results of data provided in these places. If you change the query at all, your postal code.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: https://forums.oracle.com/message/9362002#9362002
-
How to get the updated values of the loops while they are running
Hello
I am trouble with a very basic problem, how to access the updated values of the "loop FOR" during operation? Basically, the VI I is currently working on two sub vis calls each sub VI has a loop for, and the two screws may or may not work for the same number of iterations. My goal is to read the values in each terminal within the loop of two sub VIs, in primary VI. I tried to do this using Global Variables, but in main VI it will display only the last iteration of the two value sub live. Could someone please tell me whrere I go wrong? Is there any other/better way to do this.
I appreciate any input on this issue.
Pass a reference of the main VI control to the Sub screws. See attached example.
-
How to get 3table of values in the row of acronym in 11g
Hi all
I have 3 tables,
In all ck_no tables is common.Tab1 Ck_no amt 1 2000 Tab2 Ck_no Line amt 1 1 1000 1 2 1000 Tab3 Ck_no Line sub amt 1 1 1 500 1 1 2 500 1 2 1 100 1 2 2 200 1 2 3 700
Since the 3 tables above, I need the output in the following format,
Can someone help me in this?Amt1 amt2 amt3 amt4 amt5 amt6 amt7 amt8 amt 9 2000 1000 1000 500 500 500 100 200 700
Thank you
Kind regards
Gurujothi
Published by: Gurujothi on July 9, 2012 20:46
Published by: Gurujothi on July 9, 2012 20:47Gurujothi wrote:
I know how to get the values in a row for a single column,
...
but I get the error,Too Many values
How do I change this?
Please post your data in the example, the expected results of these data and explain the logic so that we can understand how the data relate to each other.
In your original post, it is not clear how amt4, amt5 abd amt6 therefore show them all 500 when there are only two 500 values in the source data.
SQL> ed Wrote file afiedt.buf 1 with Tab1 as (select 1 as ck_no, 2000 as amt from dual) 2 ,Tab2 as (select 1 as ck_no, 1 as line, 1000 as amt from dual union all 3 select 1, 2, 1000 from dual) 4 ,Tab3 as (select 1 as ck_no, 1 as line, 1 as sub, 500 as amt from dual union all 5 select 1, 1, 2, 500 from dual union all 6 select 1, 2, 1, 100 from dual union all 7 select 1, 2, 2, 200 from dual union all 8 select 1, 2, 3, 700 from dual) 9 -- 10 -- END OF TEST DATA 11 -- 12 select ck_no 13 ,max(decode(rn,1,amt)) as amt1 14 ,max(decode(rn,2,amt)) as amt2 15 ,max(decode(rn,3,amt)) as amt3 16 ,max(decode(rn,4,amt)) as amt4 17 ,max(decode(rn,5,amt)) as amt5 18 ,max(decode(rn,6,amt)) as amt6 19 ,max(decode(rn,7,amt)) as amt7 20 ,max(decode(rn,8,amt)) as amt8 21 ,max(decode(rn,9,amt)) as amt9 22 from ( 23 select ck_no, amt, row_number() over (partition by ck_no order by ord, line, sub) as rn 24 from ( 25 select 0 as ord, ck_no, 0 as line, 0 as sub, amt from tab1 union all 26 select 1 as ord, ck_no, line, 0 as sub, amt from tab2 union all 27 select 2 as ord, ck_no, line, sub, amt from tab3 28 ) 29 ) 30* group by ck_no SQL> / CK_NO AMT1 AMT2 AMT3 AMT4 AMT5 AMT6 AMT7 AMT8 AMT9 ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- 1 2000 1000 1000 500 500 100 200 700
-
Updated value Mananger as empty in the person's file all import the csv data
Updated value Mananger as empty in the person's file to import everything based on a value in the csv file csv data
Your model looks good. Subcode is may not be not necessary. below would be the solution to meet the requirement.
1. to your rule mapping for importing data, keep it but remove the mapping to UID_PersonHead
2 2 modifier change over mapping rules, delete all but keep PK (isKey) and map the domain manager to UID_PersonHead
3. add conversion script in the field of cartography to UID_PersonHead, as
If Manager (e.g., empID) exists in person and IsInactive = False Then
Value = $Manager$
On the other
Ignore UPDATE
EndIF
4. ensure in 2nd rule of mapping only update checked, add should be DISABLED
5 finishes 2nd mapping XML to generate a new script
6. update your data import process to add another step to update with the new script manager
HTH
-
Hope someone can tell what I'm doing wrong.
I'm still on 5.5 and trying to get the load data for ESXi hosts (via connected to the orchestrator Server vcenter) to decide on which host is the best target for vmotion-action.
As I could not find any workflow builtin or efforts to get data to load, I tried to dig myself via a script.
- find all hosts
- for each reading of the host.summary.quickStats.overallCpuUsage host
I have values, but they are static and do not get updated.
If I use perl-sdk and perform the same actions to vcenter I get updated for each esxi host values.
Browse objects via the web on the server vcenter watch also updated these values.
If only my orchestrator workflow seems to be wrong.
I do not suspect that the workflow in orchestrator performs a query only the inventory and not the living objects. It is much faster than doing the same thing with perl-sdk.
My little script (which could be run in a single Scriptable task with no impression one journal entry/exit). Problem can be seen by newspaper printing. Total used MHz does not change in my environment.
--------------------------------CUT
var host = System.getModule("com.vmware.library.vc.host").getAllHostSystems ();
var tothz = 0;
for {(i in hosts)
var cpu_used =. summary.quickStats.overallCpuUsage of hosts [i];
tothz = tothz + cpu_used;
}
System.log ("tothz:"+ tothz ");
--------------------------------CUT
Q1: I am doing something stupid in my script?
Q2: I have to do some extra steps to get the updated values?
Q3: Is there a better way to find/load-performance data for ESXi hosts?
Stupid enough to write the sollution myself
It is possible to force an update of the inventory values for objects that are important to your script/workflow.
It can be done by the following function in a script.
VcPlugin.refreshObjects (object-to-update - in - stock)
So for my specific problem, I could solve it with a single additional line.
--------------------------------CUT
var host = System.getModule("com.vmware.library.vc.host").getAllHostSystems ();
var tothz = 0;
for {(i in hosts)
VcPlugin.refreshObjects (the hosts [i]) / *.< my="" new="" line="">
var cpu_used =. summary.quickStats.overallCpuUsage of hosts [i];
tothz = tothz + cpu_used;
}
System.log ("tothz:"+ tothz ");
--------------------------------CUT
This seems to force an update of the inventory values before I use them.
It will certainly slow down my script a little, but it's part of the game.
-
Hello
I have a table table1 with the columns a, b, c and d
I get some results this table using this query:
SELECT
a,
b,
sum (case when c = 'F' then '1' other '0' end) 'c_data. "
sum (case when d = s 'then ' 1' other end '0') "d_data".
Of
Table1:
WHERE
a = 'a value '.
GROUP BY
b
My result will be like this:
a d_data of c_data to b
ABCD efg 1 1
Fund fjd 1 0
DFD fd 0 0
Now I need a 5th column, which should look like this: -.
a b c_data d_data Total
ABCD efg 1 1 2
Fund 1 0 1 fjd
DFD fd 0 0 0
Please someone change and give me the above query?Double wire.
sum of the values in a rowPlease close.
-
How to get the values of the rows in a column only?
How to get all the values in the rows of a column.
for example, a query gives result as:
123
234
233
12121
all in different lines. But I want the result like this:
123,234,233, 12121.All in a single row and a single column.
How is that possible?SELECT rtrim (xmlagg (xmlelement (e, column_name |))) (') .extract('//text () '), ',') from table_name
-
Windows Update fails for XP and Office 2003 security updates others are OK. Error message is 0x800F0102.
Start with these troubleshooting steps and post returns with the requested info and arises from the troubleshooting.
Clean boot your PC, and then run Windows Update.
Reset the Windows Update components
Perform operations of KB883825
-
Repeat parent node values in all rows of the child
In the xml editor, how we could repeat the parent values in all rows of the child in Model Builder if there is more than one query in the sql report.
Try
.. ./m_assembly?=""?>
or post the output example
-
SQL Help: convert values in two rows in a line
Hello
I am using Oracle 11.2, I want to get the values in different rows in the Tb_a table and insert them into the TB_b table as suite:
create a Tb_a (number (5) id, init_dt date, upd_dt date, addr varchar2 (32));
create a Tb_b (number (5) id, date upd_dt, addr varchar2 (32), dated hist_dt);
insert into Tb_a values (101, to_date('ddmmyyyy','21/08/1990'), to_date('ddmmyyyy','22/08/1990'), "address1");
insert into Tb_a values (101, to_date ('ddmmyyyy', 21 August 1991 '), to_date ('ddmmyyyy', 22 August 1991 '), "address2");
insert into Tb_a values (101, to_date('ddmmyyyy','21/08/1992'), to_date('ddmmyyyy','22/08/1992'), "address3");
insert into Tb_a values (102, to_date('ddmmyyyy','24/08/1990'), to_date('ddmmyyyy','25/08/1990'), 'address_address');
I would like to have data in TB_b as follows.
101, 22 August 1990 ","address1", August 21, 1991"
101, August 22, 1991 ","address2", August 21, 1992 '"
101, August 22, 1992 ', 'address3', null
102, 25 August 1990 ', 'address_address', null
Suggest on the SQL to perform the conversion of Tb_a to Tb_b?
Thank you939569 wrote:
I wish that each line of TB_b has the same value to the ID of the column, upd_dt and addr as Tb_a and the next value in the crt_dt of the Tb_a column.Or table has a column called crt_dt. Do you mean init_dt?
This rule applies to the same ID only. How can I use LEAD on different ID, not the whole picture?
Inlcude
PARTITION BY id
in the analytical clause, like this:
INSERT INTO tb_b ( id , upd_dt , addr , hist_dt ) SELECT id , init_dt , addr , LEAD (init_dt) OVER ( PARTITION BY id ORDER BY init_dt ) FROM tb_a;
-
just always fails and keeps coming back as an essential update, how to exit the loop
Hi Flybywire,
· You receive an error message?
· How you try to install the update for Windows Vista (KB975560) security?
Do the following to display the Windows updates history for the error code.
a. click Start, type Update in the Start search box.
b. in the list of results, click Windows Update.
(c) in the left pane, click view update history.
Follow the steps below to solve the problem:
Method 1: Download the update manually from the Download Center and check if you are able to install it.
Update security for Windows Vista (KB975560)
Method 2: I you suggest to perform the clean boot and then try to install it.
How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
http://support.Microsoft.com/kb/929135
Note: After troubleshooting, be sure to set the computer to start as usual as mentioned in step 7 in the above article.
Hope this information helps.
-
Whenever I am asked that there are updates available for download for all the CS6 Associates programs including still, I get the following message.
Update reminder CS6
There was an error of installation of this update. Quit and try again later. Error code: U44M1I210. Quit and try again once makes no difference. Is anyone able to help please?
Very well.
For CS6, the page I linked has this to explore the Setup logs:
Troubleshoot installation with the log files. CS5, CS5.5, CS6
Much updates you see are related items that may not be necessary (e. g. files camera raw).
As a reminder, on PC, the latest version is 6.0.2. On Mac, 6.0.1. If you have this version, you don't need to update.
-
Update Windows for windows 7 x 64, updates failed
I have 27 updates to windows to do, and I get error update failed when you try to install. The reason why I have so many updates is that I had windows vista and I tried to update and it caused problems with my internet connection wireless, and I didn't have the time to deal with it, so I stopped updating. Then I upgraded to Windows 7.
Errors:
Code 800736B 3.
I tried to install separately as well as in a group, but it downloads, come to the part of the installation and then I get the error. I tried to reboot update and deletion of temporary files, nothing. These are the updates, I'm trying to install:
A security update cumulative for the stop bits ActiveX for Windows 7 for x 64-based systems (KB978262)
"" for IE 8 for windows 7 x 64... KB980182
"" for media center ' "KB977863
Update security for Windows 7 for x 64-based systems (KB971468)
««KB975560»»
««KB978542»»
««KB978601»»
««KB979309»»
««KB979683»»
««KB980232»»
««KB981332»»Updated for the display of IE8 for Windows compatibility list 7 x 64 based... KB982632Update for the client for windows 7 for rights management services... KB979099Update for Windows 7 for x 64-based... KB975496""KB976264.««KB976662»»««KB977074»»««KB978637»»««KB980408»»««KB981793»»Office Live add 1.5Update3d windows defender - KB915597 definitionA security updates for Microsoft office Excel, System (x 3), OneNote-> KB978382, KB976321 KB978380, KB980729 KB981715any help you can give me would be great.It wasn't a wise thing to do. See...
Cleaning a compromised system
http://TechNet.Microsoft.com/en-us/library/cc700813.aspxPersonal data backup (which none should be considered 100% reliable at this point) then format the HARD disk and do a clean install of Windows. Please note that a repair installation (upgrade AKA on-site) will NOT fix it!
HOW to do a clean install of Win7: see "using the custom installation option" and formatting the hard drive section ofhttp://windows.microsoft.com/en-us/windows7/Installing-and-reinstalling-Windows-7
Once installed the clean, you will have the equivalent of a "new computer" in order to take care of everything on the next page before connecting the machine to the internet or one local network (i.e. other computers) otherwise and before using a flash drive or the SD card that is not brand new, or has not been freshly formatted:
4 steps to help protect your new computer before going online
http://www.Microsoft.com/security/pypc.aspxNB: The free trial Norton which is preinstalled on the computer when you bought will be reinstalled (but invalid) when Windows is reinstalled. You MUST uninstall the trial for free and download/run theNorton removal tool before installing updates and before installing your new anti-virus application.
If you need help, please start a new thread in this forum: http://social.answers.microsoft.com/Forums/en-US/w7repair/threads
Good luck!
~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft
Maybe you are looking for
-
Given that I have updated to IOS 9.3.1 my iBooks PDF documents are uploaded to the cloud so that they can be shared on multiple devices, however when I rename a PDF, it comes back to the original name every time iBooks is updated. Anyone who has si
-
Is it possible to not have the computer restart after updates until you tell him? This is on a Dell with Vista Home OS laptop
-
Ability of Pavillion Slimline s5610y Bluetooth
Pavillion Slimline s5610y has the Bluetooth capability, or do I need an adapter?
-
access denied error code ox80070005
Managers of Vista premium account me denied access to back up my computer? I'm the Manager. I gives me error code ox80070005 why?
-
Unable to access files that are engraved on DVD as Live file system
Original title: I burned my files on a DVD as LIVE file system. When I return to access they are not Using Vista Home Premium. Burned many DVDs this year. Burn the content of several files on DVD for backup. (use the DIRECT file format). Today, I put