column values with the same key value addition
Dear professionals,I created the table like this:
create table acc_test (
id number,
col1 varchar2(20),
col2 number,
col3 number);
insert into acc_test (id,col1,col2,col3) values ('1','ttt','10','15');
insert into acc_test (id,col1,col2,col3) values ('1','aba','5','0');
insert into acc_test (id,col1,col2,col3) values ('2','abc','12','7');
insert into acc_test (id,col1,col2,col3) values ('3','ddd','6','15');
insert into acc_test (id,col1,col2,col3) values ('3','df','4','15');
insert into acc_test (id,col1,col2,col3) values ('4','kl','10','15');
How to write a query for this data set:ID COL1 COL2 COL3
---------------------- -------------------- ---------------------- -----
1 ttt 15 (10+5) 15 (15+0)
2 abc 12 7
3 ddd 10 (6+4) 30 (15+15)
4 kl 10 15
THX in advance,Adnan
You can use this query:
SQL> SELECT id,col1,SUM(col2) OVER (PARTITION BY id) col2
2 ,SUM(col3) OVER (PARTITION BY id) col3
3 FROM acc_test ;
ID COL1 COL2 COL3
---------- -------------------- ---------- ----------
1 ttt 15 15
1 aba 15 15
2 abc 12 7
3 ddd 10 30
3 df 10 30
4 kl 10 15
6 rows selected.
However, if you notice that you can find that the two lines as
ID COL1 COL2 COL3
------- -------------------- ---------- ----------
1 ttt 15 15
1 aba 15 15
are present in the result set. Now, he must explain that you want to remove, and why.
If you say, it is not important, then with the data of your second posting, it's even easier!
SQL> SELECT id,col1,SUM(col2)
2 ,SUM(col3)
3 FROM acc_test
4 GROUP BY id,col1
5 ORDER BY 1 ;
ID COL1 SUM(COL2) SUM(COL3)
---------- -------------------- ---------- ----------
1 ttt 15 15
2 abc 12 7
3 ddd 10 30
4 kl 10 15
Published by: Johan on November 24, 2010 16:48
Tags: Database
Similar Questions
-
First New - VM: an element with the same key has already been added.
I get a strange error that I have seen a few other posts, but with no resolution (or at least one that I can find). When you try to create a new virtual machine using the cmdlet New - VM, I get the error "an item with the same key has already been added."Now, here's the key that I've not seen many others to mention. This ONLY happens on the first attempt for each new connection with Connect-VIServer. I can create as many of the same machines that I want after that first mistake with the same settings (new name of course). If I disconnect and reconnect again, the error appears for the first time.
Normally with PowerShell, I have just to catch the error and be on my way. However, in this case I use the parameter - RunAsync, so that I can capture the task that is returned in a variable. From there, I use Wait-task until the virtual machine is complete before moving on with the script. Everything works fine when the error occurs, but when it happens that the object of the task is not returned and the rest of her vomit script errors.
I am running the latest version of PowerCLI and I tried this on PowerShell v2.0 and v3.0 and get the same results. I tried different models and guests without success. I also tried this with and without assistance - AllLinked on Connect-VIServer-bound mode. I should mention that I am cloning model, by specifying a spec customization and host cluster data store. Again, the only common denominator repeatable here is that this ONLY happens on the first attempt to use New - VM session to vCenter.
Any ideas or suggestions?
If this is useful at all, here are the details of the output on the exception:
PS C:\ > $Error [0]
New - VM: 05/06/2013-09:49:22 new-VM an element with the same key has already been added.
On line: 1 char: 11
+ $VMTask = new-VM-name "NEWTEST20" - model 'Template' - OS...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:)) [new-VM], VimException)
+ FullyQualifiedErrorId: Core_BaseCmdlet_UnknownError, VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVMPS C:\ > $Error [0]. Exception | Select *.
ErrorId: Core_BaseCmdlet_UnknownError
ErrorCategory: NotSpecified
TargetObject:
RecommendedAction:
SessionId:
Login ID: /VIServer=USERNAME@SERVER:443/
Severity: error
Message: 05/06/2013-09:49:22 new-VM an element with the same key has already been added.
Data: {ParameterValues}
InnerException: System.ArgumentException: an item with the same key has already been added.
to System.Collections.Generic.Dictionary'2.Insert (TKey key, TValue value, Boolean add)
at VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.PopulateTaskDescriptionDict
ionary()
at VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.GetTaskDescription (String
taskDescriptionId)
at VMware.VimAutomation.ViCore.Impl.V1.Task.TaskImpl.Create (ManagedObjectReference moRef,
Customer VimClient, accessories 2 dictionary, extensionData object)
to VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl. < GetTaskListForCli
ENT > d__7.MoveNext)
System.Collections.Generic.List to ' 1.InsertRange (Int32 index, 1 IEnumerable collection)
at VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.GetTaskList (IEnume
uidList Maple 1, IEnumerable 1 connectionUidList)
to VMware.VimAutomation.Sdk.Impl.V1.Task.CoreTaskServiceImpl.GetTaskList (IEnumerable 1 uidList,
IEnumerable 1 connectionUidList)
to VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskCore (Nullable State 1,)
IList 1 connectionUidList)
to VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTask (Nullable State 1,)
CmdletTaskInfoProvider cmdletTaskInfoProvider)
at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskById (String uid,
CmdletTaskInfoProvider cmdletTaskInfoProvider)
VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.NewVM (model TemplateInterop,
VMHostInterop vmHost, string name, resourceContainer, FolderInterop location VIContainerInterop,.
StorageResourceInterop data store, Nullable 1 diskStorageFormat, OSCustomizationSpecInterop
customization, Boolean, Boolean, string 1 Nullable description isRequestedAsync allowNested
Nullable, 1 haIsolationResponse, Nullable 1 drsAutomationLevel, haRestartPriority, [AdvancedOption]
options)
to VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM.DoWork (customer VIAutomation, moList list 1)
at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.DoWork (VIConnection connection,
MoList list 1)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.DoWorkEx (VIConnection connection,
MoList list 1)
to
VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ConnectionDispatchHelper.ExecuteRunlist (dictionary 2
runlist, DoWorkDelegate doWorkDelegate, UidDispatchHelper uidDispatchHelper, result of list 1)
TargetSite:
StackTrace:
HelpLink:
Source:PS C:\ > $Error [0]. Exception.InnerException | Select *.
Message: An element with the same key has already been added.
ParamName:
Data: {ConnectionId}
InnerException:
TargetSite: Void Insert (TKey, TValue, Boolean)
StackTrace: At System.Collections.Generic.Dictionary'2.Insert (TKey key, TValue value, Boolean add)
to
VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.PopulateTaskDescriptionDictionary)
at VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.GetTaskDescription (String
taskDescriptionId)
at VMware.VimAutomation.ViCore.Impl.V1.Task.TaskImpl.Create (ManagedObjectReference moRef,
Customer VimClient, accessories 2 dictionary, extensionData object)
to VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl. < GetTaskListForClient
> d__7.MoveNext)
System.Collections.Generic.List to ' 1.InsertRange (Int32 index, 1 IEnumerable collection)
to
VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.GetTaskList (IEnumerable 1)
uidList, IEnumerable 1 connectionUidList)
to VMware.VimAutomation.Sdk.Impl.V1.Task.CoreTaskServiceImpl.GetTaskList (IEnumerable 1 uidList,
IEnumerable 1 connectionUidList)
to VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskCore (Nullable State 1,)
IList 1 connectionUidList)
to VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTask (Nullable State 1,)
CmdletTaskInfoProvider cmdletTaskInfoProvider)
at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskById (String uid,
CmdletTaskInfoProvider cmdletTaskInfoProvider)
VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.NewVM (model TemplateInterop,
VMHostInterop vmHost, string name, resourceContainer, FolderInterop location VIContainerInterop,.
StorageResourceInterop data store, Nullable 1 diskStorageFormat, OSCustomizationSpecInterop
customization, Boolean, Boolean, string 1 Nullable description isRequestedAsync allowNested
Nullable, 1 haIsolationResponse, Nullable 1 drsAutomationLevel, haRestartPriority, [AdvancedOption]
options)
to VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM.DoWork (customer VIAutomation, moList list 1)
at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.DoWork (VIConnection connection,
MoList list 1)
at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.DoWorkEx (VIConnection connection,
MoList list 1)
to
VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ConnectionDispatchHelper.ExecuteRunlist (dictionary 2
runlist, DoWorkDelegate doWorkDelegate, UidDispatchHelper uidDispatchHelper, result of list 1)
HelpLink:
Source: mscorlibI was informed that this is actually a "known" bug and a fix has already been planned for the release of the future code. After getting the access to a beta version, it does not seem to be fixed in the next release.
-
Windows Vista 64-bit version purchased, can 32 bits be installed with the same key?
Configure a computer for a friend using the version 64-bit of Windows Vista, not knowing its processor's crashing issues with 64 bit... would it not possible to rebuild and get a copy of 32-bit by using the same key via download or something? (I'll killdisk his computer so I'm sure it will not be saved, but I'm not sure.)
Thanks for the replies!
* original title - 64-bit version of Windows Vista purchased, has not work.__Can I install 32 bit with the same key? (Another was deleted, so it's is more approved I think). *
Hello
1. you have a 64-bit processor on your computer?
2 have you installed the correct drivers 64 bit?When you bought Windows Vista, if it came with two versions of the operating system, a 32-bit installation DVD and an installation DVD 64 bits, then you would be able to use the
same product key. Even if the 32-bit version should work with a 64-bit version of Windows, chances are the 64-bit version will perform better, because it was designed for a
64-bit version of Windows.Kind regards
Afzal Taher - Microsoft technical support.
Visit our Microsoft answers feedback Forum and let us know what you think. -
1 What is OA in the license tag
2. is it possible to install the OS [Home premium] 64-bit with the same key.Hi adil13,
Adding to reply TrekDozer,
1 original Equipment Manufacturer (OEM) Activation is also known under the name of OA. It's basically OEM activation of basic input/output system (BIOS) - which means that they have already activated and you don't need to enter the key and activate yourself.
2. you will only be able to activate a copy of Windows 7 with the number of product key used for 64-bit or 32-bit version at the same time, not both. It will allow only a copy installed with him to be activated. If you try to do it on both versions 32/64-bit, you will probably get the message that your product key is already in use or The Windows 7 product key you typed is invalid for activation .
I hope this helps!
Kind regards
Gokul - Microsoft Support -
How many times can I activate my Windows with the same key?
My laptop comes with an HHD. I just upgraded to a SSD, reinstalled Windows 7 and activated. Then I discovered that the SSD is defective, and I need to replace the more quickly. Can I activate my system with the same key in a short period, say a month?
Yes, you can, you may need to use the activation of the phone well:
How to activate Windows 7 manually (activate by phone)
1) click Start and in the search for box type: slui.exe 4
(2) press the ENTER"" key.
(3) select your "country" in the list.
(4) choose the option "activate phone".
(5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
(6) explain your problem clearly to the support person.
http://support.Microsoft.com/kb/950929/en-us -
Add-PSSnapin: an element with the same key has already been added
When you run Add-PSSnapin, I get the above error. This seems to happen if I try to add the snap a second time, but when this happens, none of the power CLI commands are then available up to what the server is restarted.
Add-PSSnapin: an element with the same key has already been added.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
+ Add-PSSnapin $SnapinName;
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: NotSpecified: (:)) [Add-PSSnapin], ArgumentExcept)
ion
+ FullyQualifiedErrorId: System.ArgumentException, Microsoft.PowerShell.Co
mmands. AddPSSnapinCommand
Failure of the attempts to remove the snap-in at this point with:
Remove-PSSnapin: no Windows PowerShell snap-ins for the model
"VmWare.VimAutomation.Core" were found. Check the pattern and then try the
command again.
At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
+ Remove-PSSnapin $SnapinName;
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo: InvalidArgument: (VmWare.VimAutomation.Core:Stri
NG) [Remove-PSSnapin], PSArgumentException
+ FullyQualifiedErrorId: NoPSSnapInsFound, Microsoft.PowerShell.Commands.R
emovePSSnapinCommand
I already tried to uninstall the dll and put it back, that makes no difference
$dllpath = "C:\Program Files (x 86) \Vmware\Infrastructure\vSphere PowerCLI\VMWare.VimAutomation.VICore.Cmdlets.dll.
$SnapinName = "VmWare.VimAutomation.Core".
#get the path to instalutil
$path = [System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory();
#create an alise for installtuil
set-alias installutil (resolve-path (join-path $path 'installutil.exe'));
#uninstall snap
InstallUtil /u $dllpath;
InstallUtil $dllpath;
I tried appdomain unloading, then adding the snap-in with the same result:
$appdomain = [AppDomain]: CurrentDomain
$appdomain. # Of unloading | Out-Null
Add-PSSnapin "VMware.VimAutomation.Core".
$appdomain. Load
Everything simply jump beyond the error is not good because it is impossible to find the following commands:
Add-PSSnapin "VMware.VimAutomation.Core" - ErrorAction SilentlyContinue
Get - VM $VirtualMachine
The term 'Get - VM' is not recognized as the name of a cmdlet, function, script file, or an executable program. Check the spelling of the name, or if a path has been included, make sure the path is correct, and then try again.
Any help to fix this would be greatly appreciated.
Thank you
OK, I was kind of what went wrong here.
The snap has been loaded from a powershell module. When the module is removed and added again, the snap ceases to function, but also can not be added again.
If the snap is loaded first outside the module everything works fine until you try never to remove or add snap-in module.
-
PowerCLI - an element with the same key has already been added ERROR
Hello
I opened a case with VMware on a problem using PowerCLI. And pretty well, they said that they do not support scripts... But the error is not related to any script. It is related to the first command I run against one of our Vcenter and we have 6 of them.
Everything worked well until we went from 4.1 to 5.1
I can connect to our VCenter fine, but the first command always give an error and fail to the powercli but the task still occur in vCenter.
When it gets ugly, is we have several powershell script to maintain and automate our environment but now these script fail.
Example, we have a script to deploy the VM model and then configure the appropriate hardware configuration and add Notes and custom attributes. But the script fails after that deployment so the rest will not run. It will be possible that deploy us to the first virtual machine.
So for 'Band-aid' question, I added a line to my script to start a virtual dummy machine, to make sure that what is in the script will work fine.
Error:
PowerCLI C:\Program Files\VMware\Infrastructure\vSphere PowerCLI > start-vm vm - Server-m46
Start-VM: 2013/06/26 11:57:05 Start-VM an element with the same key has already been added.
Online: 1 character: 9 + start-vm < < < <-vm server-m46 + CategoryInfo: NotSpecified: (:)) [start-VM], ViError + FullyQualifiedErrorId: Client20_VMServiceImpl_StartVM_ViError, VMware.VimAutomation.ViCore.Cmdlets.Commands.StartVM)
As far as I know, done to the PowerCLI VMware supports.
I don't think they support the client script debugging, but the product PowerCLI itself is supported.
I created a few calls myself in the past.
What you see is a known problem, there are a few discussions in this community who has something similar.
-
An element with the same key has already been added
Hi all
I see a strange problem when you try to add a new disk to a virtual computer via powershell
I use the following commands:
Add-PSSnapin VMware.VimAutomation.Core
to connect-viserver-Server $MyVC
$server = "MyServer".
$vm = get - vm $server
$NewDisk = new-disk-hard - VM CapacityGB - $DiskSize - StorageFormat $StorageFormat $VM
When I run it, the drive is added, but what follows is cast in the output:
New hard drive: 24/06/2013-11:04:22 New-harddisk An element with the same key has already been added. On line: 1 char: 11
+ $NewDisk = new-disk-hard - VM $VM CapacityGB - $DiskSize - StorageFormat $StorageForm...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:)) [new-harddisk], ViError) + FullyQualifiedErrorId: Client20_VirtualDeviceServiceImpl_NewVirtualHardDisk_ReconfigError, VMware.VimAutomation. ViCore.Cmdlets.Commands.VirtualDevice.NewHardDisk
When I restarted the command in the same pssession and then it is executed without error.
Has anyone seen this behavior before?
This could be a bug?
I searched for this error, but this seems like something very generic...
Thanks in advance!
Filip
Hi Filip,
This looks like the same problem as already reported in first New - VM: an element with the same key has already been added.
-
How to prevent multiple objects with the same key being stored?
Hello
I use of DPL and I want to know if we have any way of preventing multiple objects with the same primary key is stored in the database or not.
Thank youHello
Primary keys are unique - there may be multiple objects with the same key. Did you look in the javadoc for the PrimaryIndex and methods put ()?
-mark
-
Windows 8 re-activation with the same key
I have a Vaio with windows 8 unique language(x64). I thought to format the laptop with the same OS and enter the product key. There will be no problem to accept the product key? I'm doing so that I can speed up my laptop.
This isn't how you reinstall a preinstalled copy of Windows 8.
You must use the built in recovery partition:
Table of contents:
- Dell Factory Image Restore
1.
Dell Factory Image RestoreCaution: Please note that this process will erase your hard drive, including your data, then re-install the previous backup file. This process, once started, cannot be interrupted. If you try to stop the process (for example, by turning off your system), your computer may not start and could cause a loss of data. Dell Backup and Recovery can recover the operating system or the backup of the recovery partition as well. To recover the operating system from the recovery partition, follow these steps:
- Plug the power adapter.
- Point to the right corner of the screen to make charms barappear.
- Click settings.
Click the stop button, press on the
then click restart in the options provided.
The system reboots, login and click on the problems.
Click the Dell backup and restore .
The system restarts and returns to the top, click Next in the screen Dell backup and recovery.
The system would be checked to see if the chip repair option can solve the problem, click Next once this is done.
We will ask to select the backup to use, click the picture factory option or select one of the backups. Click Next.
You will be asked to save your files, if required to do so by selecting the option Yes, save my personal files (Make sure to have a backup external hard drive very practice.) or select No, erase my files.
The system goes ahead and ends at the restoration of the operating system. Click restart when you are prompted.
Follow the on-screen instructions to install the system with windows.
-
As it says in the title I did a clean install on the same pc and this time when I try and its saying its invalid key product keys?
Skip entering your product key Windows 7 and complete the installation.
When you reach the desktop, click Start, right-click on computer
Click on properties
Scroll down to the Windows Activation
Click the link x days before activation.
Click on the link that says: "show me other ways to activate.
Enter the product key
Click next
Select the Activation of the phone
Click Next when you enter your key page
Select your country
Click Next, call the number listed
Be sure to explain your situation to the Appeals Officer.
Provide the installation generated when ID requested by the call agent
They give a confirmation ID in return, enter it
Click next to complete the activation.
However, the requirements for the media upgrade is that you have an operating system already eligible such as Windows XP or Vista installed to use it. Since the Windows 7 end user license agreement.
15 UPDATES. To use upgrade software, you must first be licensed for the software that is eligible for the upgrade. After the upgrade, this agreement takes the place of the agreement for the software that you upgraded. After upgrade, you can no longer use the software that you upgraded.
So, if you are always denied, you will just have to reinstall Windows XP or Vista and let it do the verification of eligibility.
--------------
or
How to activate Windows 7 manually (activate by phone)
1) click Start and in the search for box type: slui.exe 4
(2) press the ENTER"" key.
(3) select your "country" in the list.
(4) choose the option "activate phone".
(5) stay on the phone (do not select/press all options) and wait for a person to help you with the activation.
(6) explain your problem clearly to the support person.
http://support.Microsoft.com/kb/950929/en-us -
I messed up my pc while tinkering with disk partitions. I need to get windows 7 to work again on the same machine.
Note that if you save all the important things, it will be lost after the reset.
Your computer is equipped with a recovery instead of disk partition...
This is how the recovery partition is accessible to most popular brands...
For Dell, press CTRL + F11 directly after switching on the device
For HP, press F11 directly after switching on the device
For LG, press F11 directly after switching on the device
For Toshiba, press and hold "0" BEFORE and during the power upward
For Acer, press and hold ALT + F10, as soon as you see the logo
For Asus, press F9, as soon as you see the Asus logo.
For Samsung, press F4 to the power upward...
For Fujitsu, press the F8 key directly after the power
Advent, restart your computer. Then, press F10 repeatedly until the message "Starting system recovery"
Sony VAIO, reboot and press "F8" or "F10" repeatedly until the screen "Advanced Boot Options".
You may need to try several times to get everything above to work. If after several attempts, you have no chance, or the machine indicates that there is no recovery partition, your only option is to contact the computer manufacturer and ask for the model recovery discs...
After the reset, you should get all the updates from Windows Update EXCEPT for hardware devices. Then, you install a good antivirus. ONLY AFTER you have done this, if you replace the stuff of backups or install anything else.
-
Cursor of two or more with the same key value
Is it possible to have a slider (c1) that has a key value that can be used in another cursor (c2)?
See the example below:
/ * Sum of all economies where the amount is 50,000 or more * /.
CURSOR c1 IS
Select cusno, sum (savings)
deposits
Cusno group
After having sum (savings) > = 50000;
/ * All customers in the system * /.
CURSOR c2
Select firstname, lastname, cusno, address, telephone
of the customer;
This, I would like to put in a file: all customer (from c2) information with economies falling into the first slider (c1).
Is this possible?
1 with cust_dep like)
2 SELECT CUSNO, SUM (savings) DEPOSITS BY CUSNO GROUP TOTALS)
3. SELECT c.firstname
4, c.lastname
5, c.cusno
6, c.address
7, c.phone
8, d.totals
9. customer'S c
10, cust_dep d
11 WHERE c.cusno = d.cusno
12 AND d.totals > = 50000
13 * ORDER BY c.cusno ASC
SQL > /.
FIRSTNAME LASTNAME CUSNO
--------------- --------------- ----------
ADDRESS PHONE TOTALS
-------------------------------------------------- --------------- ----------
John Doe 1
123 main St. Anytown, USA 12345-123-456-7890 50000
John Smith 3
456 main St. Anytown, USA 12345 132-546-7890 58000
SQL >
SQL >
-
How to remove data in three tables at once with the same key.
I am new to Oracle ADF, I have a requirement like these, I have three tables such as employee salaries, teams of all these have a common EmpNo as common attribute, I have the search form these returns all employees related to this search query, when I click on the button Delete the particular employee data should delete all tables of the three based on the EmpNo.
Any help is appreciated...(1) the easiest way is to mark the constraints of foreign key to WAGES employees and TEAMS of EMPLOYEES like ON DELETE CASCADE. The DB server then removes the necessary lines each time you remove a line from the employee.
(2) another way is to implement a Before delete e-DB trigger on the EMPLOYEES table, where you can remove the related rows in other tables (have in mind that if you have foreign keys you can get an Exception Table mutation, so this approach is perhaps not very good).
(3) an ADF is to implement a custom EntityImpl class for the Employee entity and substitute the remove() method where you can find the related entities of TeamMember and salary (via EntityAssoc accessors) and call remove() methods too.
(4) another way of the ADF is to implement a custom EntityImpl class for the Employee entity and override the doDML() method where you can remove the lines needed in SALARIES and TEAMS through JDBC calls tables whenever a DELETE operation is performed on the Employee of the underlying entity.
Dimitar
-
update of table with similar registration information using the same key
Version: 11.1.0.7.0
We have large table probably 30 M records
-test code table follows
create table people)
person_id number,
first name varchar2 (50).
middle_name varchar2 (50).
last_name varchar2 (50)
);
insert into persons (person_id, first_name, last_name, middle_name) values (1, 'JOHN', 'A', 'DOE');
insert into people (person_id, first_name, last_name, middle_name) values (1, 'JOHN', ","DOE");
insert into persons (person_id, first_name, last_name, middle_name) values (1, 'JOHN', 'ADAM', 'DOE');
insert into persons (person_id, first_name, last_name, middle_name) values (2, 'JOHN', ' C ', 'DOE');
insert into people (person_id, first_name, last_name, middle_name) values (2, 'JOHN', ","DOE");
insert into people (person_id, first_name, last_name, middle_name) values (3, 'JOHN', ","MOE");
insert into persons (person_id, first_name, last_name, middle_name) values (3, 'JOHN', 'FRANK', 'MOE');
I am trying to write more efficient code to take the middle name of the most complete and updated all records with the same KEY (person_id) with her.
Expected result:
1, JOHN, ADAM, DOE
1, JOHN, ADAM, DOE
1, JOHN, ADAM, DOE
2, JOHN, C., DOE
2, JOHN, C., DOE
3, JOHN, FRANK, MOE
3, JOHN, FRANK, MOE
Hello
Here is an example of the use of the aggregate LAST instead of the function ROW_NUMBER analytic function:
MERGE INTO dst people
WITH THE HELP OF)
WITH got_longest_middle_name AS
(
SELECT person_id
, MIN (middle_name) DUNGEON (DENSE_RANK LAST ORDER OF LENGTH (REPLACE (middle_name, '.')))
AS longest_middle_name
AMONG the people
WHERE middle_name IS NOT NULL
GROUP BY person_id
)
SELECT person_id
longest_middle_name
Got_longest_middle_name c - c is for candidates
WHERE DOES NOT EXIST)
SELECT 1
AMONG the people
WHERE person_id = c.person_id
AND c.longest_middle_name NOT AS REPLACE (middle_name, '.'). '%'
)
) src
WE (dst.person_id = src.person_id)
WHEN MATCHED THEN UPDATE
SET dst.middle_name = src.longest_middle_name
WHERE dst.middle_name <> src.longest_middle_name
OR dst.middle_name IS NULL
;
I suspect that this may be a little faster, but try it on your system with your data to make sure.
Maybe you are looking for
-
I have MAC OS X 10.4.11 and downloaded 7 from FireFox. It has replaced my old version, but I can't run it on 10.4.11. Now, I'm no. FireFox and I prefer Safari. What can I do to recover the old version?
-
As I downloaded the latest version - Firefox 6.0, I have some serious slow loading of the page. Nothing has changed in my PC or network configuration and in the past had a very fast loading everything, even the streaming of videos, etc.. The only thi
-
Satellite A30 RAM memory upgrade
Hello.I have a question about my Toshiba Satellite A30 memory.I want to spend my memory (256 DDR 333 Mhz PC2700 SoDiMM installed chip). If I add to the original 256 MB 512 MB chip the two will work together and is a SoDIMM DDR 512 with a frequency of
-
Acronym for "mx" DAQmx and ELVISmx
My Google-fu, fu reference book and forum-search-fu have me totally failed... I'm sure this has been answered during the passage of NOR-DAQ for DAQmx, but electronic references that have long since disappeared to bit - rot or in the mists of time. Th
-
How can I be faster than milliseconds on windows 7?
Hello I'm using Labview 2011 SP1 on windows 7 32bits. I encounter something strange that I can't explain. My program run so fast that I do not understand why? In my program, a while loop runs more than 1000000 times during the approximativley. 2500ms