SQL & PL/SQL :: How To Use If Exist Condition In Oracle
Oct 11, 2012
i am using one if exist condition in sql server that is like this.
if exists(select 1 from ShiftEmployee where Empid=@EmpID and Month=@month and year=@year)
begin
some value is passing here...
end
how to use the same in oracle?
View 4 Replies
ADVERTISEMENT
Dec 7, 2010
Given two tables in a 1:N relationship, I want to retrieve, for each parent row, any child row which either satisfies some condition cond1 or, if no child rows matching cond1 exist, which satisfies another condition cond2.
I can easily write such a query using NOT EXISTS, but I am forced to repeat the condition cond1. This is inconvenient, as the repeated condition is quite long (involving other tables as well), and I would like to write it only once.
For example (using the HR schema included in Oracle 10g XE): I want to retrieve, for each department, all the "new" employees (hired after a certain date) or, if no "new" employees exist, the department manager.
SELECT d.department_id,
d.department_name,
d.manager_id,
e.employee_id,
e.first_name,
e.last_name,
[code].....
View 3 Replies
View Related
Nov 20, 2012
In my 11g Oracle i have the following issue:
create table TEST
(
COL_DATE DATE
)
partition by range (COL_DATE)
(
partition TEST2012 values less than (TO_DATE(' 2013-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
[Code]....
when i execute this i receive the following error:
ORA-02149: Specified partition does not exist?
View 2 Replies
View Related
Nov 21, 2011
I have created this store procedure:
create or replace PROCEDURE INSERT_TESTTABLE
(
PrimaryKey IN NUMBER
,One IN VARCHAR2
,Two IN VARCHAR2
,Three IN VARCHAR2
,Four IN VARCHAR2
[code].......
And I get this error: Error(15,13): PL/SQL: ORA-00942: table or view does not exist
View 1 Replies
View Related
Apr 7, 2012
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
connected as- / as sysdba
Connected to an idle instance.
SQL> startup
ORA-01261: Parameter db_recovery_file_dest destination string cannot be translated
ORA-01263: Name given for file destination directory is invalid
OSD-04018: Unable to access the specified directory or device.
O/S-Error: (OS 2) The system cannot find the file specified.
SQL>
ORACLE_HOME is - E:\oracle\product\10.2.0\db_2
ORACLE_SID is - orcl11
I'm using Oracle 10.2.0 in windows 7.When i installed oralce it worked properly for 1 week, now throwing an error ora-01034 and ora-27101.
I just perform CRUD Operations with database as a java dev by connecting via MYEclipse, but it is not at all allowing me to connect.
View 1 Replies
View Related
Jun 12, 2010
ORACLE was working perfectly on Windows 7 since Jan 2010. A couple of days ago I ran a procedure which was to update a table with 1000 columns. The procedure worked fine till it created a few thousand records and then it slowed down terribly. I closed the SQL Plus command line tool (CTRL C) and tried to restart and then tried to logon to get the following errors-
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Then I used the Start Database tool (net start OracleTNSListener), but it showed "System 5 error". So after researching online I created Admin profile for WINDOWS 7 and logged in as an administrator. In the INIT.ORA file I increasd the SGA_TARGET to 5G and PGA to 3G. After doing that the above service is running but I'm still getting the ORA-01034 and ORA-27101.
Using cmd prompt in Windows and entering commands sqlplus -> Username: " / as sysdba" gives an insufficient privileges error.
View 19 Replies
View Related
Feb 8, 2013
I have to enable oracle advance compression for existing table which PARTITION BY RANGE then SUBPARTITION BY HASH.
ORacle version: 11.2.0.2.0
View 5 Replies
View Related
Aug 27, 2013
I have more than 100 records in CSV format. I have to import these records to a particular table which already contains data. I have to do a multiple update at a time, based on the condition . ie., if field1 is '1' then update field2 as 'A0001' and if field1 is '5' then update field2 as 'A0007' . The values are not in an order. Is it possible.
View 1 Replies
View Related
Sep 24, 2013
i am continuously inserting data to oracle database after some time like 2 hours oracle disconnects,it creates erros like
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Process ID: 0
Session ID: 0 Serial number: 0
after restarting the database with shutdown immediate ans startup if i start inserting records it will show erros like
ORA-01653: unable to extend table SYSTEM.GLT_PROT_TRAFFIC_SUM_VOIP by 8192 in tablespace GLCOMM
but i have created the Tablespace with BigFile Auto Extend and max size unlimited, i am having 400GB disk space created Redo logs with 15gb,i have tried serveral times reinstalling the oracle but problem is not solved.
same problem is happenging with small datafiles also,
operating system: windows server 2008 R2 standard
oracle server : 11g
oracle client : 64 bit
View 14 Replies
View Related
May 18, 2012
Sometimes our db server goes in hanging condition. It does not save any transaction & user waits for long. When I restart, it starts working fine.What should I do, I mean regarding diagnosis & performance tuning.
View 1 Replies
View Related
Apr 23, 2013
i installed oracle XE and odac tool kit for asp.net in my pc.when i am trying to run InstallOracleProfile.sql i am getting
ORA-01917: user or role 'ORA_ASPNET_PROF_FULLACCESS' does not exist.
View 2 Replies
View Related
Feb 3, 2012
i wrote a program to that takes tablename as input parameter and returns true or false based on table exist or not
the below code works differently when table has data and when table does not have data ? how to improve the below code to make sure my function always retuns true if table exists and false if does not exist regardless of 0 records or more than one record
CREATE OR REPLACE FUNCTION is_tab_present_g (pi_tab_name IN VARCHAR2)
RETURN BOOLEAN
IS
row_cnt NUMBER := 0;
sql_stm VARCHAR2 (4000);
l_tab_name VARCHAR2 (4000);
[Code]....
my verification block
BEGIN
if is_tab_present_g('chk_pk') then
dbms_output.put_line('yessssss');
execute immediate 'drop table chk_pk cascade constraints';
else
dbms_output.put_line('nooo');
end if;
END;
/
View 8 Replies
View Related
Mar 31, 2010
I've been trying to write some code to add a column if it does not exist as the code will be run numerous times and will be parameterized in other software to run across multiple tables.
Here is what I have made so far:
DECLARE
COLEXISTS integer;
vCmdStr varchar2(4000);
[Code]....
I can't figure out where the invalid character is.
View 3 Replies
View Related
Nov 25, 2010
In Oracle11g (R1 and R2) we can create the user in +ASM instance just like normal oracle database. But If the user already exist I get an error
CREATE USER test IDENTIFIED BY test
*
ERROR at line 1:
ORA-01920: user name 'TEST' conflicts with another user or role name
So, I would like to know if there is any data dictionary view which can tell me if the user already exist or not.
View 5 Replies
View Related
Nov 22, 2011
finding the difference between IN and EXIST.
View 15 Replies
View Related
Jul 28, 2012
I need to put amount '0' if the row exist but has no amount in my "where " conditions. the orginal commad is :
select t.aaa, count (t.bbb), sum (t.ccc) from nrb t where t.vvv IN ('3','4','5','6','D','E','F') and t.ddd like '50%' and t.eee >= TO_DATE('2012/03/21','YYYY/MM/DD') and t.eee <= TO_DATE('2012/07/21','YYYY/MM/DD') group by t.aaa order by t.aaa
and the result is : "result" tab in excel atached file.i need this result: "result 2" tab in excel atached file.
View 8 Replies
View Related
Aug 27, 2010
I created a stored procedure(A) in user1@db1. This stored procedure will insert data from db1 to tables in user2@db2 using synonyms created in user1@db1 referencing table at user2@db2.
In the stored procedure (A),
insert into synonym select seq_xx.nextval from table@db1;
Then I will execute (A) in user2@db1. Execute right on (A) is given to user2@db1.Select and insert grants on db2 tables are given to user1@db1. Seq is created in db1. Compilation is successful, however when i execute (A) it has an error of
ORA-02289: sequence does not exist
ORA-02063: preceding line from db1
ORA-02063: preceding 2 lines from db2
View 6 Replies
View Related
Jan 18, 2013
delete table if exist
How do we write this code in oracle / sqlplus
View 4 Replies
View Related
Apr 3, 2012
I am trying to do a impdp using a network link and it fails with the ORA-31626: job does not exist.It worked with a different database on the same server. The network link is there, data pump directory exists, the read and write privileges are granted to the oracle user.There are no other data pump jobs running:
SQL> select JOB_NAME,STATE from DBA_DATAPUMP_JOBS;
no rows selected
My database details:
BANNER
----------------------------------------------------------------
Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
PL/SQL Release 10.2.0.4.0 - Production
CORE 10.2.0.4.0 Production
TNS for Linux: Version 10.2.0.4.0 - Production
NLSRTL Version 10.2.0.4.0 - Production
The whole error is listed below:
omdx16dd$ impdp oracle@xtst080 SCHEMAS=BRM REMAP_SCHEMA=BRM:MBR_SLN CONTENT=METADATA_ONLY DIRECTORY=DATA_PUMP_DIR NETWORK_LINK=po02
Import: Release 10.2.0.4.0 - 64bit Production on Tuesday, 03 April, 2012 17:20:33
Copyright © 2003, 2007, Oracle. All rights reserved.Password:
Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bit Production
With the Partitioning, Data Mining and Real Application Testing options
ORA-31626: job does not exist
ORA-00942: table or view does not exist
ORA-00942: table or view does not exist
[code]...
View 1 Replies
View Related
Apr 19, 2011
Can there be an impact on performance if below two index exists on the same table:
t_idx(col1,col2, nvl(col7,col6));
t_idx1(col1,col2,nvl(col6,col7));
View 5 Replies
View Related
Mar 21, 2013
I listed invalid object, but when compile object, say that not exist.
SQL> SELECT OBJECT_NAME, OBJECT_TYPE FROM DBA_OBJECTS WHERE STATUS='INVALID' AND OBJECT_NAME ='PCK_PIR_NFEL_MILLENIUM' AND OWNER='PIRAMIDE'
OBJECT_NAME OBJECT_TYPE
--------------------------------- --------------------
PCK_PIR_NFEL_MILLENIUM PACKAGE
SQL> ALTER PACKAGE PCK_PIR_NFEL_MILLENIUM COMPILE;
ALTER PACKAGE PCK_PIR_NFEL_MILLENIUM COMPILE
*
ERROR at line 1:
ORA-04043: object PCK_PIR_NFEL_MILLENIUM does not exist
View 2 Replies
View Related
Feb 10, 2011
I am running Oracle 10g on my machine. I have create an ER diagram in Toad Data Modeler, which includes all the keys, contraints etc.I have generated a DDL script which I want to biuld my tables with in Oracle.I have loaded the DDL script using SQL*Plus Worksheet and there are no problems.then tryed to insert some test data into my tables and I keep getting an error code of:
ORA-00942, table or view does not exist.Now I know the tables have been created and also by verifying this with the data dictionary using
select table_name
from user_tables;
TABLE_NAME
=========
Table1
Table2
Table3
.
.
etc
It then displays all 20 of my tables, as above. I am using a Visual Basic front end and I can see all 20 tables listed there also, with attribute names for each table.Also I get the following by typing:
select owner, object_type from
all objects where object name = 'Customer';
OWNER OBJECT_TYPE
------------------ -----------------
SYSADMIN TABLE
View 4 Replies
View Related
Apr 25, 2007
I created a table by doing so:
create table Playlist (Artist string, Album string, Track int, Song string, Genre string);
But I get the following error message when trying to perform a query:
SQL> select artist
2 from playlist;
from playlist
*
ERROR at line 2:
ORA-00942: table or view does not exist
I entered data in for the artist, so why doesn't it work?
View 4 Replies
View Related
Oct 30, 2012
I have two tables.
First one is
STAFF
======
STAFFNUM NAME
======== ====
1 A
2 B
3 C
SUBJECT
=======
SUBCODE SUBNAME LECTURER
======= ======= ========
A1 ABC 1
A2 EFG 2
A3 HIJ 1
I did the following query
SELECT STAFF.STAFFNUM, STAFF.NAME, SUBJECT.LECTURER
FROM STAFF,SUBJECT
WHERE STAFF.STAFFNUM NOT IN SUBJECT.LECTURER
It will show me..
B and C is not teaching A1.
A and C is not Teaching A2.
B and C is not teaching A3.
This is not what I want.
What I want is to show who is not teaching any subjects.So the expected result is only C coming out.
View 10 Replies
View Related
May 26, 2011
I just created a role as
CREATE ROLE XXXX;
Then tried to grant a privilege, but getting error as below:
grant alter on schema.table_name to XXXX;
ORA-01917: user or role 'MACH_ALTER_ROAMXDB' does not exist
View 4 Replies
View Related
Jul 11, 2011
When I create a Materialized view using:
CREATE MATERIALIZED VIEW LOAD.M_VW_ABN_PROD_921
[color=red][i]REFRESH FORCE ON DEMAND START WITH sysdate+0
NEXT (TRUNC(SYSDATE+1) + 9.5/24)[/i][/color]AS
SELECT
...............
......................
it creates a DBMS_JOB for me with the required interval.
But now my requirement is that I want to create a job on the existing MV.
Now I tried the code mentioned in the previous post to schedule the job.
This job does not work. When I tried to execute it manually using:
DBMS_IJOB.RUN(12345) as sys user is throws the follwing error.
Error listed in the alert.log file is as below:
ORA-12012: error on auto execute of job 17497
ORA-23404: refresh group "CLARITY"."M_MV_INBASKET_ANALYSIS"
does not exist
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.DBMS_REFRESH", line 23
ORA-06512: at "SYS.DBMS_REFRESH", line 195
ORA-06512: at line 1
Sun Jul 10 20:07:51 2011
View 5 Replies
View Related
May 13, 2011
I am trying to run the following code. The issue i am having is when running it in a function or procedure. (the SELECT statement works on it's own - so why doesn't it would in a procedure?)
SELECT LAST_DDL_TIME from SYS.dba_objects
WHERE object_type='TABLE'
AND OBJECT_NAME = 'CONT_ASSESSMENT'
i get an error saying "PL/SQL: ORA-00942: table or view does not exist"..I a quite new to oracle / SQL.
View 1 Replies
View Related
Jun 17, 2011
I'm updating a big table with an other one (see topic
[URL]........
I was wondering if I could do it without using the WHERE EXISTS condition. Let me explain better:
create table TEST
(
ENT_SIG VARCHAR2(10),
EMP_ID VARCHAR2(10),
DATE_START DATE,
DATE_END DATE
);
create table TEST2
(
ENT_SIG VARCHAR2(10),
EMP_ID VARCHAR2(10),
DATE_START DATE,
DATE_END DATE
);
insert into TEST (ENT_SIG, EMP_ID, DATE_START, DATE_END)
values ('014', '120', TO_DATE('20080101','YYYYMMDD'), TO_DATE('20080131','YYYYMMDD'));
insert into TEST (ENT_SIG, EMP_ID, DATE_START, DATE_END)
values ('014', '121', TO_DATE('20080201','YYYYMMDD'), TO_DATE('20080228','YYYYMMDD'));
[code].....
I'm asking if there's a way to do this:
update test a
set (date_Start, date_end) = (select date_start, date_end
from test2 b
where b.emp_id = a.emp_id
[code].......
Without using the WHERE EXISTS. I don't want to make two accesses to table2, I would like instead to do something like "If subquery returns a row, use it, else keep what you have in destination table".
Is there a way to do it without entering test2 twice?
View 10 Replies
View Related
Mar 13, 2012
FRM-41827:Group does not exist.
I am getting the above error in Oracle Forms as I am using it in Oracle Apps 11.5.10.2 as a custom form... how to resolve the above error....
View 4 Replies
View Related
Oct 12, 2010
I got some records in the table between the sign / Some of these records are separated by / And I would like to get something like:
If exist / inside the string then display as lines as string between /
For instance:
select handset_brand, handset_model
from the_table;
display : handset_brand: Siemens
handset_model: A35 / A36 / A40 / B35N
I need to get 4 lines:
handset_brand: Siemens
handset_model: A35
handset_brand: Siemens
handset_model: A36
handset_brand: Siemens
handset_model: A40
handset_brand: Siemens
handset_model: B35N
View 31 Replies
View Related