IF EXISTS (Select) - Enter Into Table One Period At A Time?

Apr 21, 2011

I am trying to break down a row of data that has nine periods that I want to enter into a table one period at a time. I am trying to use "IF EXISTS ( SELECT * FROM TABLENAME WHERE FIELD1 IS NOT NULL) THEN" through all nine fields. It keeps returning lines that have a null column as well as not null columns. if there is a better way of doing this. Here is an example of what I am trying to do:

IF EXISTS (SELECT * FROM TABLE_NAME WHERE LAST_DT9 IS NOT NULL) THEN
SELECT NUMBER, 1COL9, 2COL9, 3COL9, FIRST_DT9, LAST_DT9, 4COL9
FROM TABLE_NAME;
ELSE IF EXISTS (SELECT * FROM TABLE_NAME WHERE LAST_DT8 IS NOT NULL) THEN

[code]...

View 1 Replies


ADVERTISEMENT

PL/SQL :: Select Exists On Time

Sep 17, 2013

I have this sample:
the column data1 is datetime datatype  with
t as (   select 'SMITH' nom,to_date('21/09/2013 07:30:00') data1
from dual union all   select 'ALLEN',to_date('21/09/2013 07:40:00')
from dual union all   -- select 'WARD',to_date('21/09/2013 07:50:00')
from dual union all   
select 'JONES',to_date('21/09/2013 08:00:00')
from dual union all   

[Code]..

How can I write a select to check that If I input 10 minutes to nom 'ALLEN' it's ok because the time 07:40 + 10 minutes = 07:50 the row not exists, (the next)but If input 20 it exists because the sum = 08:00 and row  isn't free , indeed, there is 'JONES'?

View 4 Replies View Related

SQL & PL/SQL :: Select Data From Test-1 Table Where ID Values In Table Exists In 2?

Aug 31, 2010

I have the below data in table test_1.

select * from test_1
IDNameTotal
-----------
1A100
2B100
3C100
4D100

test_2 table contains the concatination of ID's with comma seperated. Actually in this table ID column is of datatype varchar2.
select * from test_2
ID
----
1,2,3

My requirement is to select the data from test_1 table where the id values in this table exists in test_2 table. I tried with the belowselect statement, but could not get any data.

SELECT * FROM test_1 WHERE to_char(id) IN (SELECT id FROM test_2)

create table test_1 (id number, name varchar2(100), total number)
create table test_2(id varchar2(100))
insert into test_1 values (1,'A',100)
insert into test_1 values (2,'B',100)
insert into test_1 values (3,'C',100)
insert into test_1 values (4,'D',100)

View 4 Replies View Related

SQL & PL/SQL :: Dividing The Time Period Into Weeks

Dec 14, 2011

I need to divide the given time period into weeks from Monday to Sunday .There should not be overlapping of two months, for a week.Every month should start from First day of that month to next Sunday .Same thing can be done by following PL/SQL block . let me know if there is any simple way by using query instead of block .

declare
pid_from_date date := '01-JAN-11';
pid_to_date date := '31-dec-11';
ln_number number := 0;
ld_from_date date;
ld_to_date date;
begin

[Code]....

View 5 Replies View Related

SQL & PL/SQL :: Select Columns Of 3 Tables In Such A Way That Period Column Should Be In Group By Function

Aug 16, 2011

i want to select columns of 3 tables in such a way that period column should be in the group by function.

create view allocated_budgets_detail as
select ba.ba_fin_year, ba.ba_start_date, ba.ba_end_date, ba.ba_rev_no,
bh.bh_budget_code,
bd.bd_period,
bb.bb_entered_amount
from budget_header bh, budget_allocation ba, budget_distribution bd, budget_balance bb
where bh.bh_budget_id = ba.ba_budget_id
and ba.ba_line_id = bd.bd_budget_line_id
and ba.ba_line_id = bb.bb_budget_line_id
group by bd.bd_period

View 13 Replies View Related

SQL & PL/SQL :: How To Enter Value At Run Time In Case Statement

Jun 3, 2010

The code written in PL SQL.I am using '&' operator to enter the values at run time in nested case statements.But when I chosen a value for case statement even though it is asking all the values which are not part of the selected case statement.I need only the values related to my choice in case statement.

choice1:= &CHOICE_NO1;
CASE(choice1)
WHEN 1 THEN
DBMS_OUTPUT.PUT_LINE('** ENTER YOUR CHOICE TO PERFORM THE OPERATION: **');
DBMS_OUTPUT.PUT_LINE('** (1)INSERTION (2)DELETION (3) UPDATION **');
[code]....

that is my exact code.when I enter value 1 for choice1 and 2 for choice2 It should ask the values only for student_ scorecard. delete_ record (& STUDENTID); &studentid. But it is asking all the functions (student_scorecard.existing_marks(&ID,&SUBJECTNAME));(student_ scorecard. std_ major_ name (&STD_ID)) and procedures.I dont want that.

View 4 Replies View Related

Application Express :: Enter Input In For Select List?

Nov 28, 2012

I would like to enter input in for a select list. That is, if I have a select list for the common colours (blue, green, red, ... ) that a user could query on, then I would like a user to be able to type in the colour - purple in the box next to the select list. I've looked at the select list options and couldn't see anything obvious?

View 2 Replies View Related

Table Has No Rows - Select Taking Time

Aug 23, 2010

We were trying to insert approx 76 million records worth of approx 4 GB in a table when the insert operation failed with the archive log error.

The database was hanged, we re-started the database and currently there are no records in the table but when we are firing a select

select count(*)
from table

It's taking approx 2 mins to come out with the result.

We checked and found that there are no locks on the table currently.

what do we need to do to get the performance back

View 5 Replies View Related

SQL & PL/SQL :: Enter Multiple Languages Data Into A Table?

Jun 19, 2012

i need to enter multiple languages data into a table.

i did configuration assistant with nls_charecterset=AL32UTF8

but it didn't store other languages strings like hindi,french,japan...etc

View 3 Replies View Related

How To Check A Table If Exists

Oct 12, 2005

I have a script like this:

------------------------------------------------------------

DROP TABLE CON_TEST CASCADE CONSTRAINTS ;

CREATE TABLE CON_TEST (
IDI NUMBER(10,0),
USERID VARCHAR2(10),
PWD VARCHAR2(10),
NOTE VARCHAR(100)
)

----------------------

But i think if table CON_TEST doen't exist, an error message will appear. I know that in SQL Server we can check if table exists or not. So, i wonder if we can do that in Oracle?

By the way, is there any way to run a file script that contents TABLES, STORED, ... on a developed PC connect to oracle db server? (in case, i'm developing on PC, using Net Service Name to conect to Oracle DB Server)

View 9 Replies View Related

SQL & PL/SQL :: Columns From Table Used In Exists Block?

Jun 22, 2011

I have 2 queries one which gives me unique records and second which I created using EXISTS to eliminate duplication.i.e. First query gives me 4 records but when I put the table which is in the EXISTS block in the normal join, it gives me 8 records.

But the issue is I want data from the query which I have put in the EXISTS block.

View 8 Replies View Related

SQL & PL/SQL :: How To Retrieve Data That Does Not Exists In A Table

Dec 13, 2011

I have the following table with the some sample data:

|| Filename || receiving_site || originating_site ||
| fileA | siteA | HQ |
| fileA | siteA | siteA |
| fileB | siteA | HQ |
| fileA | siteB | HQ |
| fileA | siteB | siteB |
| fileB | siteB | HQ |
| fileB | siteB | siteB |

The table works in such way:

1. For each of the Filename, if originating_site is not the same as receiving_site, it means that the file has been sent to receiving_site but has not been acknowledged received yet.

2. For each of the Filename, if originating_site is the same as receiving_site, it means the file has been sent and received by the receiving_site.

My task is to list out all the Filename per receiving_site that has been sent, but not received yet by the receiving_site. For example from the sample data above, I am expecting to see that siteA, fileB has not been received yet.

How can I do that? I had tried MINUS and NOT EXISTS command, but I am just not able to get the result that I want.

View 2 Replies View Related

SQL & PL/SQL :: Error / Table Or View Does Not Exists

Dec 7, 2010

login as system

execute statement
SELECT * FROM scott.emp;

works, how ever when we try to create view as

CREATE OR REPLACE VIEW v_emp AS
SELECT * FROM scott.emp;

then it gives error that table or view does not exists...

View 12 Replies View Related

Security :: ORA-00942 Table Or View Does Not Exists

Aug 31, 2010

I am receiving an "ORA-00942 Table or View does not exists" error message when I try to run the following SQL statement:

SELECT id_status INTO :ls_id_status
FROM USER_ADMINISTRATION
WHERERTRIM(user_id) = :as_userid;

where :as_userid is an argument passed to the SQL.

Here are some background facts in order to save time regarding actions already taken:

(1) The userid used to login successfully is the same one passed to the above SQL;

(2) I have confirmed that the table does exist - we are using it in an application;

(3) The case of the table name is upper case as seen above and is correct;

(4) The spelling of the table name is correct;

(5) The schema name was prefixed to the table and I still got the same error (not shown above);

(6) The userid that I used is assigned to a role and the role has SELECT permissions to the above table.

View 8 Replies View Related

PL/SQL :: CASE Statement With Oracle Table Types And EXISTS?

Aug 14, 2012

I have been trying to use case statements with oracle table type by really not sure how to go about it. I know it might be simple but it been giving me hard time.

Here is my Cursor:

CURSOR c_chk_style IS
      SELECT DISTINCT 1
        FROM TABLE(CAST(I_message.ExtOfXOrderDesc_TBL(1).ExtOfXOrderSkuDesc_TBL AS "RIB_ExtOfXOrderSkuDesc_TBL")) item_diff,
   
[code]...

Now i know that the table type "RIB_ExtOfXOrderSkuDesc_TBL" will be always populated but the table type "RIB_ExtOfXOrderPackDesc_TBL" may not be populate and can be null. So i want to run the exists against the "RIB_ExtOfXOrderPackDesc_TBL" aliased pack_diff only if it is populated. If its null i dont want to run the exists clause.

View 15 Replies View Related

SQL & PL/SQL :: Time Based Select

May 24, 2010

The following query gives error.

select count(*)
from invoice
where inv_id in (SELECT inv_id FROM invoice_hist WHERE to_char(timestamp) between TO_char('05/12/2010 18:22:00', 'MM/DD/YYYY HH24:MM:SS') and
TO_char('05/21/2010 18:22:00', 'MM/DD/YYYY HH24:MM:SS'));.

Here timestamp is of type DATE in the invlice_hist table.

What change is needed?

View 9 Replies View Related

PL/SQL :: Select Time From Sysdate

Sep 20, 2013

I have to concatenate a date(not sysdate) with the system time and store it in a column having datatype as DATE... So I tried like this....

SELECT TO_CHAR (C_DATE, 'DD-MON-YYYY')      || ' '    || TO_CHAR (SYSDATE, 'HH:MI:SS PM')    FROM   DUAL; 

But while inserting the output of the above query in my table it throws error like this... ORA-01830: date format picture ends before converting entire input string Is there any possibility to achieve this.

View 6 Replies View Related

Last Date / Time When Index Used For Select

Jul 26, 2011

Is there a way I can find what the last date/time and index was used for a select...

I have a table with several indexes on them, which I beleive are not being accessed.

I use the following the query to find indexes that where not accessed in a while but this I believe is limited my my workload repository retention, which is set to 90 days.

select index_name from dba_indexes where table_name='<table name>'
and index_name not in (select c1 from(
select p.object_name c1, p.operation c2, p.options c3, count(1) c4
from dba_hist_sql_plan p, dba_hist_sqlstat s
where p.object_owner = 'MTAS' and p.operation like '%INDEX%' and p.sql_id = s.sql_id
group by p.object_name, p.operation, p.options
order by 1,2,3))

Without increasing my repository retention is there a way I can get the last date/time, which an index was used instead of just saying it has not been used in 90 days (retention setting). Is this information kept in the SQL plan?

View 2 Replies View Related

PL/SQL :: Select Data Which Is Inserted At Same Time?

Mar 20, 2013

I wanted to select data which is inserted on the same time.

Is that possible? I am trying with below query but facing isses.

SQL> SELECT a,b,c,d FROM tb;

no rows selected

SQL> SELECT a,b,c,d FROM (INSERT INTO tb VALUES(1,1,1,1));
SELECT a,b,c,d FROM (INSERT INTO tb VALUES(1,1,1,1))
*
ERROR at line 1:
ORA-00903: invalid table name

View 11 Replies View Related

SQL & PL/SQL :: Delete Previously Stored Data And Enter Only Current Data In A Table?

Jul 24, 2012

how to insert data in a table by deleting previous entered data and only inserting current data like:

CREATE TABLE test
(
name VARCHAR2(20),
id NUMBER
)
INSERT INTO test VALUES ('aaa',5500);

[code]....

I got two rows. now when I do insert statement I want to delete the previously stored data and only insert the current data like:

INSERT INTO test VALUES ('aaa',8);
INSERT INTO test VALUES ('aaa',9);

it must show aaa,8 and aaa,9 bt not the previous values.

NOTE: we can not do sth like: update set... where id = ... becoz the values are dynamic.

View 4 Replies View Related

Select Statement To Oracle DB - Time Converting?

Aug 27, 2009

My company use a sybase database that runs business jobs. Currently we run SQL queries from Perl to gather time information on the jobs. Now we have an application that is using Oracle. The server it is on, doesn't have perl, so I am using a shell script to login to sqlplus and run a query for a job and it's end time. I have accomplished this. However, here is the 2 problems I am having.

1. The query reults are returned in Scientific time, I'm able to convert that to EPOCH time in the SQL syntax, however, it comes back with a 13 digit time, instead of 10. The last 3 digits are zero. How can you remove the last 3 digits in the query or convert the 13 digits to Human Time. Right now when you see the select statement, I am doing a to_char to get it to EPOCH time.

2. How to only show the latest time in the query and not show ALL job end times from it's past runs.

Here is my shell script, and I do realize this maybe a select statement syntax solution to one or both, but the UNIX time stamp is puzzling.

#!/usr/bin/sh
sqlplus -S username/password@JAWSPROD <<eof> myfile
set heading off feedback off verify off
select JAWS_APP.JAWSJOB.JOBNAME, to_char(JAWS_APP.JOBRUN.ENDTIME) from JAWS_APP.JAWSJOB, JAWS_APP.JOBRUN where JAWS_APP.JAWSJOB.JOBID = JAWS_APP.JOBRUN.JOBID and JAWS_APP.JAWSJOB.JOBNAME in ('pa_box_settle');
exit

View 1 Replies View Related

Oracle 11.2.0.3.0 - Select Query Taking Time

Jan 24, 2013

My oracle database version is 11.2.0.3.0 where i am having one schema in that schema i am having 3 same tables with same structure same data but with different name.

but problem is in first table when i perform select query it takes 5 sec, in another table it is taking 0 sec and in third table it is taking 10 sec.

View 1 Replies View Related

Time Format - Way To Change My Select To Creation

Jul 18, 2012

when I select I have to using AND creation_dt>='17-JUL-12' is there a way to change my select to creation_dt='17-JUL-12' ?
on meantime my local format is 18-JUL-12(18-JUL-12) is thee anything I can do?

View 5 Replies View Related

SQL & PL/SQL :: How To Calculate Period Date

Sep 14, 2011

Following is the scenario:

CREATE TABLE EMP_VACATION(
EMP_NO NUMBER(3),
VAC_TYPE NUMBER(1),
START_DATE DATE,
END_DATE DATE,
START_PERIOD_DATE DATE,
END_PERIOD_DATE DATE,
PRIMARY KEY (EMP_NO,VAC_TYPE,START_DATE))
[code]....

--How to calculate START_PERIOD_DATE and END_PERIOD_DATE for every time insert reocrd, like for 4 cases?
--I need to check start_date with last period date for same employee.

And based upon calculate START_PERIOD_DATE and END_PERIOD_DATE,,,,,

View 7 Replies View Related

SQL & PL/SQL :: Cross Tab Group By Period?

Apr 27, 2011

I'm trying to write a cross tab query but which groups by periods.

Test Case: -

CREATE TABLE COMPANIES
(
"ID" NUMBER(9,0),
"CODE" NUMBER(8,0),
"DESCRIPTION" VARCHAR2(40 CHAR),
CONSTRAINT "PK_COMPANIES" PRIMARY KEY ("ID")
);

[Code]..

The cross tab is to have columns 1 - 31 which sum the quantity of the article sold. Represnting days of the month.

In addition the description of the company.

I would then like to end up with 3 entries in the results for each company, but these are for summing the quantity of articles by the following periods: -

Breakfast: 01:00 - 10:00
Lunch: 11:00 - 14:00
Dinner: 17:00 - 22:30

I hope that makes sense?

View 13 Replies View Related

SQL & PL/SQL :: How To Find Overlapping Period

Jun 7, 2012

i want to find the data which has the more then one rates available for the given date. Here below i've posted a test table. how can find the products for which, there multiple dates/overlapping period is available through sql statement.

SQL> CREATE TABLE STO.TEMP
2 (
3 ID NUMBER(8),
4 ITEM_ID NUMBER(8),
5 RATE NUMBER(5,2),
6 FROMDATE DATE,
7 TODATE DATE
8 );

[code]....

View 8 Replies View Related

SQL & PL/SQL :: Overlapping Date Period

Jun 28, 2012

CREATE TABLE CONTRACT
(
EQT VARCHAR2(10 BYTE),
SUBTYP VARCHAR2(3 BYTE),
FROM_DT DATE,
TO_DT DATE
);

[Code]....

The data in contract and lease table show like below.

contract

EQT SUBTYPFROM TO
ABCD100000DRY1/1/20121/7/2012
ABCD100000DCH1/7/20121/21/2012
ABCD100000GAZ1/21/2012
lease

EQT CONTRACTFROM TO
ABCD100000LS11/2/20121/10/2012
ABCD100000LS21/10/20121/17/2012
ABCD100000LS31/17/2012

Now required output should be

EQT SUBTYP CONTRACTFROM TO
ABCD100000DRY 1/1/20121/2/2012
ABCD100000DRYLS11/2/20121/7/2012
ABCD100000DCHLS11/7/20121/10/2012
ABCD100000DCHLS21/10/20121/17/2012
ABCD100000DCHLS31/17/20121/21/2012
ABCD100000GAZLS31/21/2012

The period for contracts should be in sequential order and should not overlap and if contract does not exist for that date period, then it should return NULL.

View 9 Replies View Related

SQLPLUS Select Statement To Get Last Failed Time From Each User

Aug 13, 2010

I'm new to the sqlplus,

User ID Failed_timestamp
----------------------------------
userA 20100801 11:22:33
userB 20100802 11:22:33
userA 20100802 12:22:44
userA 20100803 13:34:55
userC 20100803 20:21:23
userB 20100804 16:34:56

I wanna to get the last failed time from each user. what is the select statement?

my expected result will be:

userA 20100803 13:34:55
userB 20100804 16:34:56
userC 20100803 20:21:23

View 3 Replies View Related

SQL & PL/SQL :: Count Of Rows For Specific Period?

Aug 12, 2010

I need to get the number of rows based on one condition for certain time period. For example, writing a query for 3(any) hrs , i need to get the output as count of rows as hourly basis. Like these:

Date Time Count
12/08/2010 16:00 234
12/08/2010 17:00 345
12/08/2010 18:00 645

View 12 Replies View Related

User Account Will Be Locked In A Period Of One Day After

Sep 16, 2013

"ALTER PROFILE profile_name LIMITPASSWORD_LOCK_TIME 1"means the user account will be locked in a period of one day after FAILED_LOGIN_ATTEMPTS has gone over limit.How to set PASSWORD_LOCK_TIME less or more than one day (like not full days)?

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved