SQL & PL/SQL :: Record Event If No Rows Are Returned Between Two Timestamp?
Feb 21, 2013
I have employees under a supervisor defines as below:
select LOGIN_USER_ID from APPWMS.VIEW_EMP_LATEST_INFO where SPVSR_LOGIN_USER_ID='erbrand' and EMP_STAT_CODE='ACTIVE'
Now I need to determine if all above employees are clocked in , clocked out or not clocked between yesterday and today using following:
select to_char(CLOCK_IN_DATE,'dd-mon-yyyy hh24:mi:ss' ) ClockIn,to_char(CLOCK_OUT_DATE,'dd-mon-yyyy hh24:mi:ss' ) ClockOut ,LOGIN_USER_ID,--CLOCK_IN_DATE,CLOCK_OUT_DATE, CLOCK_OUT_DATE-CLOCK_IN_DATE,trunc(sysdate) , trunc(sysdate-1),
case when CLOCK_OUT_DATE is null then
'Not clocked out'
else
[code]....
The first SQL gives me 66 rows while second gives me 40 rows. For 26 people , no rows are returned which means these people donot have a clock in record between two timestamps.
How can we modify query to show those 26 people as 'Not clocked In'
View 7 Replies
ADVERTISEMENT
Aug 11, 2011
I need to create a function where in data from 5 rows is clubbed into one row. Like this I have around 425 rows which should be clubbed to 85 rows. Requirement is similar to pivot but not exactly like a pivot as different columns need to be taken from those 5 rows. This is for reporting purpose in order to get data in the desired report format.
SQL mentioned below works fine. It does return data.When below code is used as a normal procedure with OUT parameter as Index by table of Record type code works fine. It returns data. Functionality is met. But when used as a pipeline function, it returns no data.
Below code gets compiled but returns nothing. I didn't find anything on Google or any website for same.
CREATE TYPE r_report_mth_rec_obj AS OBJECT (
acct_num VARCHAR2 (20),
acct_name VARCHAR2 (80),
fund_group VARCHAR2 (80),
fund_type VARCHAR2 (80),
share_class_code VARCHAR2 (10),
share_class_description VARCHAR2 (20),
curr_code VARCHAR2 (10),
[code]...
View 16 Replies
View Related
Sep 26, 2010
difference in the values that are returned?
select count(*) from aaa;
COUNT(*)
----------
1000001
select num_rows from dba_tables where table_name = 'AAA';
NUM_ROWS
----------
994202
View 5 Replies
View Related
Sep 17, 2010
DECLARE
l_query VARCHAR2(4000);
TYPE cursor_type IS REF CURSOR;
[Code].....
How can I get the total number of rows returned by the query?
I want to be able to check omething like c1.ROWS = 0
View 4 Replies
View Related
May 10, 2011
Is there a way we could define a record or a nestedtable with a type based on weak refursor i.e
TYPE RC IS REF CURSOR;
C2 RC;
Type t is table of c2%rowtype;
Following is some more explanation of what I am trying to do.
I have a table T with column A and B. Column A is a primary key with number 1,2,3,4,5,6, Column B has diffrent sql stmts stored. i.e 'Select * from emp', Select count(1) from dept' and so on. So table will look like
1 Select * from emp
2 Select count(1) from dept
Now I want to select statements stored in table T one by one and execute them by using cursor. Problem arises as i need to fetch the cursor into some variable but the outcome of each statment is diffrent and oracle does not allow to use cursorname%rowtype for a weak ref cursor.
View 3 Replies
View Related
Apr 5, 2013
How Can I delete the returned two rows?
1 select s.reg_no,s.course_code,
2 s.section src_sec,a.section a_sec,a.att_date,a.att_flag
3 from attendance a ,src s
4 where a.semester_code=1
5 and a.semester_year=2013
6 and s.semester_code=1
[code]....
View 6 Replies
View Related
Nov 8, 2012
Our application has a homepage that displays results of several SQL statements that are defined as reports. One report in particular should only display a custom message when Count of Invoices having a particular status > 0, and not the actual invoice count itself.
I have gotten the layout to not display the count but I need to be able to display a custom message that says "Problem Invoices exist. Please see Invoices Report for more information." I've looked over the Report Attributes definition page but I cannot find how to display this custom message.
View 2 Replies
View Related
Mar 6, 2013
we are running Oracle R12.1.3 on DB version 11.2.0.3. I just migrated a created a custom subscription for the oracle.apps.ap.supplier.event Oracle Event. I execute a custom package when this event fires. My package is working fine and I'm getting the expected results. My problem is I keep getting a Workflow notification saying:
Sent: Monday, March 04, 2013 9:14 PM
To: SYSADMIN
Subject: Action Required: Local Event UNEXPECTED : oracle.apps.ap.supplier.event / 36422
To SYSADMIN
Sent 04-MAR-2013 21:13:40
ID 1659929
An Error occurred in the following Event Subscription: Event Subscription
Event Error Name:
Event Error Message: No Event Subscriptions exist for this Event
Event Error Stack:
Event Data: Event Data URL
Event Details
Event Field Value
[code]...
I saw an earlier post about this and have tried changing the Source Type to "External" but that didn't change anything. why Workflow is telling me a subscription doesn't exist when my subscription is executing with no problems.
View 5 Replies
View Related
Jan 13, 2012
I Want to make a query to select finished goods product in sales having product code greater than 280 but i have face a problem that order by is not working because products column have character code as well as number. how to sort that column.
View 2 Replies
View Related
Aug 22, 2011
I am importing some data from Oracle into another database on a regular basis. It works fine for most of the queries but couple of queries don't work sometimes (random). I don't get any errors or any data.
We switched on the Oracle auditing to find out the queries being sent to oracle db. We can see all the queries in the Audit log. Is it possible to configure Auditing to get the "Number of Rows" returned by Select statements so that we can be sure that some data was returned.
View 8 Replies
View Related
Dec 27, 2006
I have 3 tables that I want to select all rows from and then order by the timestamp of when the row was inserted.
View 7 Replies
View Related
Sep 16, 2011
I am trying to find sum for one record for each partition but while taking that timestamp giving me bit trouble, i have tried to reproduce the table and some little data
CREATE TABLE TEST_COUNT
(END_TIME DATE
,SUCCESSFUL_ROWS NUMBER
,FAILED_ROWS NUMBER
,TBL_NAME VARCHAR (4)
,PARTITION_NAME VARCHAR (240) )
[code]....
View 11 Replies
View Related
Oct 5, 2010
Due to some business requirements a table field needs to change from date to timestamp in order to handle the millisecs.
1>When i alter the row , for a table with 150 million recs will there be a conversion. Is there a recommended way to convert the field. Mind you this field is used as a part of composite PK.
2> There is a interfacing application which connects and copies the data to its system and is using the date type, will that application be able to continue to work without any changes, if it does not care about the millisecs.
3> Will there be performance impact on an existing application that uses the date field to sort
4> Will DB need more space due to the change
View 3 Replies
View Related
Mar 6, 2013
My problem is i need to display the status and the record count in separate rows.How can i do it
Example
SELECT 'A' STAT, COUNT(A) CNT,'B' STAT, COUNT(B) CNT,'C' STAT, COUNT(C) CNT
FROM TAB1;
OUTPUT SHUD BE LIKE
STAT COUNT
A A_cnt
B B_CNT
C C_CNT
View 13 Replies
View Related
Dec 3, 2012
how to know the trigger event name in trigger calling...like-
CREATE OR REPLACE TRIGGER ******
BEFORE DELETE OR INSERT OR UPDATE
OF TOTAL_QUANTITY,CANCELLED
ON *********
REFERENCING NEW AS NEW OLD AS OLD
FOR EACH ROW
BEGIN
-----------I want to know given trigger event at this level-----------
IF INSERTING THEN
null;
ELSIF UPDATING THEN
null;
ELSIF DELETING THEN
null;
END IF;
END;
View 7 Replies
View Related
May 15, 2011
I've heard about diferent ways of generating email in response to a database event e.g
1 - Using UTL_MAIL package.
OR
2 - Event Driven Reporting feature of 10g Database and using SRW.Run_Report package to generate and mail a report.
Now I'm confused that how should I accomplish the following tasks:
(i) - How to generate an email after Insert/Update/Delete on a table and acknowledge the concerned users about that event?
(ii)- How to attach a text file with that email?
View 8 Replies
View Related
Oct 8, 2013
DB 11.2.0.2AIX 6
I am getting following two top wait events from AWR report
1)SQL*Net more data from client
2)log file sync
Does it hints towards network latency and hardware configuration?what should i do for first wait event?
View 11 Replies
View Related
May 7, 2013
Any example of database startup event and database shutdown event?
View 2 Replies
View Related
Jun 22, 2013
One of our Job running long than usual time. I checked the wtait event for which its waiting. its PL/SQL Timer wait. But i noticed the total waits is 179 and timed out is also 179 for PL/SQL Timer. I checked that job that particular procedure calls dbms_lock.sleep in it. I want to know why this wait event is getting timed out ?
View 1 Replies
View Related
Jan 28, 2013
while trying to execute this
declare ret_val number;
begin
exec p_buildinfo('252657020001', to_date('20120820','YYYYMMDD'),to_date('20120928','YYYYMMDD'),ret_val, 0);
DBMS_OUTPUT.PUT_LINE('Value Returned Is : '||ret_val) ;
end;
I getting the below error
ORA-06550: line 3, column 10:
PLS-00103: Encountered the symbol "P_BUILDINFO" when expecting one of the following:
:= . ( @ % ;
The symbol ":=" was substituted for "P_BUILDINFO" to continue.
the procedure structure is
CREATE OR REPLACE
PROCEDURE p_buildsinfo ( var_p_cod CHAR := NULL,
var_p_dat_from DATE := NULL,
var_p_dat_to DATE := NULL,
po_var_l_nxt_seq IN OUT NUMBER,
var_p_consol_flg NUMBER default 0
)
View 14 Replies
View Related
Jan 5, 2012
I have a problem with a statement that normally execute in few second but after 50h the session is still active and is still waiting for null event.
V$session_wait
EVENT WAIT_TIME SECONDS_IN_WAIT STATE
---------------------------------------------------------------- ---------- --------------- -------------------
null event -1 178737 WAITED KNOWN TIME
V$session
SID STATUS PROGRAM LAST_CALL_ET
---------- -------- ------------------------------------------------ ------------
364 ACTIVE f90runm@CENTRAL1 (TNS V1-V3) 178737
My Oracle version : Oracle9i Enterprise Edition Release 9.2.0.2.0 - 64bit Production
System version : HP-UX V1
I tried tracing the session but no trace file is generated it same there is no activity.
View 5 Replies
View Related
Apr 7, 2011
how to query a list to see if a person had events in consectutive months within the past year. We call a person a LongTermResident if they had a review in any two consectutive months within a reporting period. I wrote a function isResidentLongTerm, passing in FacilityID, ResidentID, ReportPeriodStart, and ReportPeriodStop and returning a 'Y' or 'N'. It works, but the performance is slow.
So if I have a list of reviewers, facilities, reviewees I want to select only those SNF/NF residents who have had routine reviews in any two consectutive months at the same facility.
This is my query:
select ConsultantID, ResidentID
from (
select distinct ConsultantID, FacilityID, ResidentID
from Reviews
where BedType = 17820 -- SNF/NF bed
and ReviewType = 17474 -- routine review
)
where isResidentLongTerm( FacilityID, ResidentID, :startDate, :stopDate ) = 'Y'
View 1 Replies
View Related
Dec 16, 2011
declare
type osd_refone is ref cursor;
osd_ref osd_refone;
l_status number;
[code]......
abc_reports in this pack "ab_report" it is the function it having the ref cursor as out parameter . when am executing the above anonymous block am getting the below error,so how can i print the out ref cursor data in my block.
ERROR at line 8:
ORA-06550: line 8, column 12:
PLS-00221: 'OSD_REF' is not a procedure or is undefined
ORA-06550: line 8, column 3:
PL/SQL: Statement ignored
View 6 Replies
View Related
Apr 4, 2013
I have a business need to have a db function that would construct and return a (temporary) CLOB value.
here is its sample code:
create or replace package PKG_TEST_CLOB
as
function FN_TEST_TEMP_CLOB
return clob;
[code]....
when this function is invoked from a SQL Statement...
***
select PKG_TEST_CLOB.FN_TEST_TEMP_CLOB from dual;
***
... the NOCACHE_LOBS counter in V$TEMPORARY_LOBS for my session is incremented by 1
when this function is invoked via a PL/SQL block...
***
declare
l_clob clob;
begin
select PKG_TEST_CLOB.FN_TEST_TEMP_CLOB into l_clob from dual;
end;
/
declare
[code]....
... the counter doesn't budge
In real life, this function will be used by a Reporting Tool (cognos) via SQL. I tested it, and it seems that it is allocating a new temp lob segment with every invocation.
View 0 Replies
View Related
Aug 2, 2013
If running the following query:
select s.effective_date
from SECURITYDBO.DERIVATIVES s
where s.security_alias=100014320 and s.src_intfc_inst=0;
There are no rows returned.However, if I am running the other query:
select MAX(s.effective_date)
from SECURITYDBO.DERIVATIVES s
where s.security_alias=100014320 and s.src_intfc_inst=0;
There is a BLANK row returned.
View 11 Replies
View Related
Jul 4, 2012
I have a onchange event on a column which calls the following code:
function SetVal(pThis) {
//get the curren row index on change
var currIndex = $('select[name="'+pThis.name+'"]').index(pThis);
var currValue = pThis.Value;
alert(currValue);
$s('P21_mat_id_hold',currValue);
}currValue is "undefined"
Where am I missing something?
View 3 Replies
View Related
Jul 17, 2012
OS: RHEL 5.7 64 bit
DB: 11.2.0.2 Standard Edition 64 bit
Everyday EOD is run and after the eod, users are requesting to receive a mail confirming the same from the database. For this we need to configure automated email which will be sent to a list of users email ID immediately after the EOD is done.
View 3 Replies
View Related
Dec 4, 2012
Most of my day to day work involves the support of DB2 on AIX and z/OS. I support the database infrastructure for one business system that runs on the Oracle RDBMS. The application is Oracle Transportation Management. The non-production environments don't get much traffic. If I sign into the TEST or DEV Enterprise Manager DB Control screen, the following warning is almost always listed on the main page:
Metrics "Database Time Spent Waiting (%)" is at 44.00384 for event class "Concurrency"
Enterprise Manager reports that this metric is continuously fluctuating above and below the warning threshold of 30% of db time when the environment is idle.To investigate(and I am no oracle expert, far from it), I ran the following:
SELECT * FROM v$session_event
WHERE WAIT_CLASS='Concurrency'
ORDER BY TOTAL_WAITS DESC;
By far, the top two entries in the result are the following:
SIDEVENTTOTAL_WAITSTIME_WAITEDAVERAGE_WAITMAX_WAIT
124os thread startup12041423733.5218
359os thread startup150653433.5521
[code]...
Does this indicate a possible problem with the operating system?
View 2 Replies
View Related
Mar 30, 2011
.I created the following procedure to implement Event Driven Reporting:
CREATE OR REPLACE procedure ABC.eve_drv_rep as
myPlist system.SRW_PARAMLIST;
myIdent system.SRW.Job_Ident;
BEGIN
myPlist := system.SRW_PARAMLIST(system.SRW_PARAMETER('',''));
system.srw.add_parameter(myPlist,'GATEWAY','apsIP/reports/rwservlet');
[code]...
Procedure is created successfully but when I execute this procedure, I get the following error:
ORA-20001'Error sending email.Error: ORA-20999
ORA-06512: at "Nml.Eve_Drv_Rep", line 17
ORA-06512: at line 1
2ndly I want to know that whether I should give IP address or Application Server Machine Name in GATEWAY parameter?
And in SERVER parameter either I should give the Application Server Machine Name or Report Server name installed on Application Server Machine?Lastly from where I can get the complete list of Parameters to be added in SRW.Add_Parameter like SERVER, GATEWAY etc.
note that we r using Database 10g Rel.2 and Forms and Reports services on Application Server and the report being called was developed in Reports 10g.
View 6 Replies
View Related
Jul 19, 2013
Yesterday i got wait event when executed simple select from table.This select was like:
SELECT emp_number from employer where subs_id = 111
I got one row, select is very fast.In our Core Bank System we have package with function which returns such information. I tested this select on test DB, and nothing wrong. But when I executed such select and package on Production DB, DB Admin saw that 88 sessions waits when my session release the resource. But what can happen, it was simple select? I used PL/SQL developer to get information from table:
1) SELECT emp_number from employer where subs_id = 111 then
2) Package with this function
Another users used Oracle Forms screen to execute package. How simple select statement could stop all DB?
BANNER
1Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
2PL/SQL Release 10.2.0.5.0 - Production
3CORE 10.2.0.5.0 Production
4TNS for 64-bit Windows: Version 10.2.0.5.0 - Production
5NLSRTL Version 10.2.0.5.0 - Production
[code]...
Forgot to say that after succeful execution on Prod DB I disconnected, and in EM my session was INACTIVE.
View 3 Replies
View Related