2.
How to delete records in join sql query in oracle.
DELETE
from role_resource_privilege
where exists (select rrp.*
FROM role_resource_privilege rrp
LEFT JOIN role r
ON r.role_id = rrp.role_id
LEFT JOIN resource_privilege rp
ON rp.resource_id = rrp.resource_id
AND rp.privilege_id = rrp.privilege_id
where rp.resource_id is null
OR r.role_id IS NULL);
Sunday, November 18, 2012
How to delete records in join sql query in oracle.
ORA-01779: cannot modify a column which maps to a non key-preserved table
Oracle issue :
------------------
ORA-01779: cannot modify a column which maps to a non key-preserved table
Reason :
update (
select ur.sysadmin FROM user_role ur
INNER JOIN user_profile up
ON up.user_id = ur.user_id
INNER JOIN role r
ON r.role_id = ur.role_id
WHERE ur.sysadmin = 1
and ( up.sysadmin = 0
or r.sysadmin = 0 )) t
SET t.sysadmin = 0;
Because inline view returns 0 rows and oracle could figure out records to be updated.
Solution :
update user_role usr set usr.sysadmin = 0
where exists (
select ur.* FROM user_role ur
INNER JOIN user_profile up
ON up.user_id = ur.user_id
INNER JOIN role r
ON r.role_id = ur.role_id
WHERE ur.sysadmin = 1
and ( up.sysadmin = 0
or r.sysadmin = 0 ));
We can also use merge statement to update rows in join
merge INTO resource_master c USING resource_master p ON (p.resource_id = c.parent_id)
WHEN matched THEN
UPDATE SET c.active = 0;
Why do we need 64 bit JVM
Why do we need 64 bit JVM: ---------------------------- The primary reason would be if you wanted to write an app capable of using a large amount of memory (e.g. over 4GB, or whatever the per-process limit on your operating system is). 1. When we need to handle more memory ptentially more than 4G. 2. Note, however, that due to the larger adresses (32-bit is 4 bytes, 64-bit is 8 bytes) a 64-bit JVM will require more memory than a 32-bit JVM for the same task. 3. The Java compiler produces byte code which is same whether you use the 32-bit or 64-bit JDK and plan to use the 32-bit or 64-bit JRE. 4. One way to use a 64-bit JVM efficiently is to use the -XX:+UseCompressedOops which uses 32-bit references in a way which can still access 32 GB of memory. It can do this because every object in the Sun/Oracle JVM is allocated on a 8-byte boundary (i.e. the lower 3 bits of the address are 000) By shifting the bits of the 32-bit reference, it can access 4GB * 8 or 32 GB in total. It has been suggested that this should be the default for Java 7. Support for 32-bit programs Programs written and compiled for a 32-bit JVM will work without re-compilation. However any native libraries used will not. A 64-bit JVM can only load 64-bit native libraries. http://software.intel.com/en-us/blogs/2011/07/07/all-about-64-bit-programming-in-one-place/ http://java.dzone.com/articles/java-all-about-64-bit
Subscribe to:
Comments (Atom)
