Between 31-180days using Sysdate function -Help needed
I am not getting any data in between 31 days and 180days in table
Cust_lst_prch_dt :
02/19/2009
01/20/2009
My query :
select CUST_LST_PRCH_DT from order_table
where CUST_LST_PRCH_DT>=trunc(sysdate)-31
and CUST_LST_PRCH_DT<=trunc(sysdate)-180
Please help me with my query
Regards,
clar
Because you want it to be
CUST_LST_PRCH_DT BETWEEN trunc(sysdate)-180 AND trunc(sysdate)-31?
I'm guessing you mixed up your lower / upper boundary conditions in your query. However as i said, it's guessing since you've provided very little information.
Similar Messages
-
Using 'SYSDATE' function in ACCESS 2000?
'SYSDATE' function is not working in ACCESS 2000 , is there any other
alternative function available in access.
I use a select statement using SYSDATE, but it did not work.I found it already.
use the now() function. -
Analytical function help needed
hi i'm using oracle 10g.
CREATE TABLE test100(
hcim VARCHAR2(10 BYTE),
bcim VARCHAR2(10 BYTE),
num VARCHAR2(6 BYTE),
mindate varchar2(10 byte))
insert into test100 values ('03217979','03236915','76120F','10/1/2006')
insert into test100 values ('03217979','03236916','76121F','10/1/2006')
insert into test100 values ('03217979','03236917','76122F','10/1/2006')
insert into test100 values ('03217979','03236918','76123F',null)
insert into test100 values ('03217979','03236919','76124F','11/1/2009')
SELECT hcim
, bcim
, num
, mindate
, Max(TO_DATE(mindate,'MM/DD/YYYY')) OVER (PARTITION BY hcim) AS mindate1
FROM test100
;output:
03217979 03236915 76120F 10/1/2006 11/1/2009
03217979 03236916 76121F 10/1/2006 11/1/2009
03217979 03236919 76124F 11/1/2009 11/1/2009
03217979 03236918 76123F 11/1/2009
03217979 03236917 76122F 10/1/2006 11/1/2009how can i show null in mindate1 column since one of the date value in mindate has a null. Only if there is no nulls then i need to show max(mindate) in mindate1
Thanks in advanceHi,
Thanks for posting the CREATE TABLE and INSERT statements; that's very helpful.
Do you mean you want mindate1 to be NULL on every row for that hcim, because at least one row in that hcim had a NULL mindate? It would help if you posted the exact results you want. (I was typing this message before your message, clarifying this point, was posted.) It would also help to have a couple of different hcims in the sample data, at least one with a NULL mindate, and another where mindate is never NULL.
I think you want something like this:
SELECT hcim
, bcim
, num
, mindate
, FIRST_VALUE ( TO_DATE (mindate, 'MM/DD/YYYY')
) OVER ( PARTITION BY hcim
ORDER BY TO_DATE (mindate, 'MM/DD/YYYY') DESC NULLS FIRST
) AS mindate1
FROM test100
;Output:
HCIM BCIM NUM MINDATE MINDATE1
03217979 03236916 76121F 10/1/2006
03217979 03236915 76120F 10/1/2006
03217979 03236917 76122F 10/1/2006
03217979 03236919 76124F 11/1/2009
03217979 03236918 76123FStoring dates in a VARCHAR2 column is a really bad idea. Why not use a DATE column? Coding will be simpler, errors will be fewer, and execution will be faster.
Edited by: Frank Kulash on Nov 11, 2011 4:53 PM -
Output using Blackmagic HD - Help needed!
I am trying to output via Decklink a DVCProHD 50 sequence and use the Blackmagic downconverter to get it on to DigiBeta. But when I try to tell FCP to use the same compressor for video playback the drop down doesn't give me a DVCProHD 50 option. Can anyone explain what I'm doing wrong and how I can get the sequence out before Monday !!
Thanks in advance.Hey Jeremy
Welcome to the forum.
I'm not a work, so dare not claim catagorically, but could it be that DVCPRO HD 50 doesn't exist ?
surely its either DVCPRO HD or DVCPRO 50 (i suppose the former might reasonably be called DVCPro100)
if you're looking for DVCPRO 50 its often just called DV50, if you're looking for DVCPRO HD then make sure it isn't hiding behind a prefix like HDTV 1080 or HDTV 720 etc (you need to specify all this)
hope it helps
Andy -
K8N Neo FSR Bios overclocking functions help needed
Hi all, I am a small pc builder for the family and i have found some problems with the bios of my uncles K8N neo FSR which I recommended for him. Basically it wouldn't seem to overclock with the 'Dynamic Overclocking' function on bios v1.7 but did manually by adjusting FSB incrementally (ie from 200 to 205 Mhz). When I questioned this before someone had mentioned that it could be ok to run like this. However I have since updated the bios to v1.9 and even v2.1 as they became available but now neither seem to overclock manually nor using 'Dynamic overclocking'
Firstly though, can someone clear up my first conception; To test if the Dynamic Overclocking function is working can I set it to a higher setting (ie.'Commander'), save and exit bios (restarting) ---> go straight back into bios ----> go straight back into Cell Menu and check 'Current frequency of cpu' has changed?
I only ask this as if this is the case then my Dynamic Overclocking function hasn't worked with three bios' and I wont bother with anything until I RMA the board lol, as I have never been able to change the frequency of my cpu at boot/bios stage with the dynamic overclocking function.
Can anyone help me?Hi Stu, yesterday I think i found out what u mean lol. I studied a 'Sticky' ? about overclocking A64s and found some interesting stuff. Apparently overclocking the HTT is dangerous, and A64s are always at least half locked. Now with this in mind Ive been wondering if there are interlocks built into my mainboard stopping me from using the 'CPU Overclock' function to overclock my pc manually from the set 200Mhz while my HTT is still set at 4x. -I say this as the HTT on my system is 800Mhz for a socket754 Sempron 3000Bx, thus overclocking this would increase my HTT above the 800Mhz threashold (I think) lol. All sounds complex but I think Ive figured it out as Im following instructions from the sticky to lower my HTT multiplier before increasing my cpu overclock. Its hard as my mainboard has Nforce3 chipset which has different ways of overclocking to every other board lol. So far I have managed to increase the overclock, but only when the HTT multiplier is lowered to 3x. I have also lowered my cpu multiplier though, and thus am trying to figure out where my 1810Mhz clock speed has changed to 1630 lol. Will try again now. I want to raise the clock speed above 1810, keeping the HTT lower than 800 and leaving the memory alone at 400DDR lol. Im hoping the memory is seperate as it seems to be on this chipset.
-
Hi everyone.
I trying to work out how to run a function after 5 seconds.
All i'm trying to do is make some text dropdown after a set time.
Here's my code so far:
Code:
import fl.transitions.easing.*;
import fl.transitions.Tween;
var myText:TextField = new TextField();
var myFormat:TextFormat = new TextFormat();
var dropText:Tween;
var dropTextTimer:Timer = new Timer(5000, 2);
addChild(myText);
myFormat.size = 14;
myFormat.color = 0x0000FF;
myFormat.font = "Helvetica";
myText.text = "Hello World";
myText.autoSize = TextFieldAutoSize.LEFT;
myText.setTextFormat(myFormat);
dropTextTimer.addEventListener(TimerEvent.TIMER_COMPLETE, dropTextFunc);
dropText = new Tween(myText,"y",Bounce.easeOut,myText.y,200,5,true);
function dropTextFunc(event:TimerEvent):void
dropText;
At the moment the text drops down as soon as it loaded.
Any help would be great
Thanksuse:
Code:
import fl.transitions.easing.*;
import fl.transitions.Tween;
var myText:TextField = new TextField();
var myFormat:TextFormat = new TextFormat();
var dropText:Tween;
var dropTextTimer:Timer = new Timer(5000, 1);
addChild(myText);
myFormat.size = 14;
myFormat.color = 0x0000FF;
myFormat.font = "Helvetica";
myText.text = "Hello World";
myText.autoSize = TextFieldAutoSize.LEFT;
myText.setTextFormat(myFormat);
dropTextTimer.addEventListener(TimerEvent.TIMER, dropTextFunc);
dropTextTimer.start();
function dropTextFunc(event:TimerEvent):void
dropText = new Tween(myText,"y",Bounce.easeOut,myText.y,200,5,true); -
I am inserting an xml doc into a table with a CLOB column and have a Query such as this inside a dbms_xmlgen function :-
SELECT XMLELEMENT("provider", XMLForest(DECODE(a1.CORP_ID,''D'',13478,''RR'',14450) as"provider-id"),
xmlagg(XMLELEMENT( "Employee", XMLForest ( a18.EMP_FIRST_NM "first-name", a18.EMP_LAST_NM "last-name" ),XMLELEMENT("enc", XMLATTRIBUTES ( 'PWE-IL' AS "measure-set"),XMLForest ( a110.PP_DESC as "enc-flag",a18.EMP_ID as "emp-id",a12.EMP_AUX_RECORD_NBR as "Employee-group-number") )))) as "provider" .
I want to supress the duplicated PROVIDER nodes in the resulting doc. If I remove the 'AS PROVIDER' tag, it takes the xml function XMLELEMENT on the first line as the NODE.
I am at my wits end trying to get the duplicate tag out of the way. Please help...
VRI want to supress the duplicated PROVIDER nodes in the resulting docWhat duplicate nodes are you talking about?:
SQL> select xmlelement("provider", deptno, xmlagg(xmlelement(ename, ename))) as "provider" from emp
group by deptno
provider
<provider>10<ENAME>CLARK</ENAME><ENAME>KING</ENAME><ENAME>MILLER</ENAME></provider>
<provider>20<ENAME>SMITH</ENAME><ENAME>FORD</ENAME><ENAME>ADAMS</ENAME><ENAME>SCOTT</EN
AME><ENAME>JONES</ENAME></provider>
<provider>30<ENAME>ALLEN</ENAME><ENAME>BLAKE</ENAME><ENAME>MARTIN</ENAME><ENAME>TURNER<
/ENAME><ENAME>JAMES</ENAME><ENAME>WARD</ENAME></provider> -
Query using Group by - help needed
I am having a query as follows:
select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
from details where created_date = ' 22-Jul-08';
As group by clause is missing it is giving errors.
But when I add group by to this query, I have to add all selected values.
How can I add the concatenatd values here.
Is there any other way rather than writing as :
(select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
from details where created_date = ' 22-Jul-08'
group by id_nbr, stop_nbr, street || city || state)so where is the problem in writing:
select id_nbr, stop_nbr, street || city || state, count(sub_stop_nbr)
from details
where created_date = ' 22-Jul-08'
group by id_nbr, stop_nbr, street || city || state
???? -
I have this SELECT below which i have to run it in a LOOP for every activity_id(record) that i get from the join.
Also,this SELECT has to be run in multiple places in a procedure to get details and for that records-->I run the assign_course or assign_test as below.
Can anyone please help me write a function which would have this select.inputs are strtplanid,strPersonid,p_objective_id
FOR activity_id( IN
(SELECT objact.activity_id, objact.activity_type,objact.IS_REQUIRED
FROM test_training_plan tp,
test_tp_objective tp_obj,
test_train_obj_activity objact
WHERE tp.tplan_id = tp_obj.tplan_id
AND tp.tplan_id = strtplanid
AND tp_obj.t_objective_id = p_objective_id
AND tp_obj.t_objective_id = objact.t_objective_id
AND objact.activity_id NOT IN (
SELECT tplplr.activity_id
FROM test_learning_record lr,
test_learning_record lr1,
test_tp_learning_activity tplplr
WHERE lr.lr_catalog_history_id = tplplr.activity_id
AND lr.learning_record_id =
tplplr.activity_lp_lr_id
AND tplplr.tp_lp_lr_id = lr1.learning_record_id
AND lr1.lr_catalog_history_id =
strtplanid
AND lr.lr_person_id = strPersonid
AND lr1.lr_person_id = strPersonid
AND lr.status IN
('PASSED', 'WAIVED', 'TESTED_OUT'))
AND objact.activity_id NOT IN (
SELECT event_id
FROM test_train_obj_activity toa,
test_event_sessions sessions,
test_learning_record lr1,
test_tp_learning_activity tplearnact,
test_learning_record tplr
WHERE toa.activity_id = sessions.event_id
AND sessions.event_session_id =
lr1.lr_catalog_history_id
AND lr1.learning_record_id =
tplearnact.activity_lp_lr_id
AND tplearnact.tp_lp_lr_id =
tplr.learning_record_id
AND tplr.lr_catalog_history_id =
strtplanid
--AND toa.is_required = 1
AND toa.t_objective_id = obj.t_objective_id
AND tplr.lr_person_id = strPersonid
AND lr1.lr_person_id = strPersonid
AND lr1.status IN
('PASSED', 'WAIVED', 'TESTED_OUT')))
LOOP
IF (activity.activity_type = 'Course')
THEN
SP_ASSIGN_COURSETP(strPersonid,activity.activity_id,strPersonid,activity.activity_type,
activity.IS_REQUIRED,strtplanid,v_straccreditingorg);
ELSif (activity.activity_type ='Test')
THEN
SP_ASSIGN_TESTTP(strPersonid,activity.activity_id,strPersonid,activity.activity_type,
activity.IS_REQUIRED,strtplanid,v_straccreditingorg);
END IF;Hi all,
I am back again and requesting your help on this.I want your help to properly write the below code because now i feel-that its very confusing and not easily readable.
I want to replace the same looping done in many places using a function.Then,need all your important suggestions in any other ways,approach...i can do the same
which would be very good for performance and best practices.
CREATE OR REPLACE PROCEDURE "TEST_PROCEDURE" (
p_strtplanid test_training_plan.tplan_id%TYPE,
p_strpersonid test_person.person_id%TYPE,
p_strorg_id test_org.org_id%TYPE
IS
/*Here declarartion of variables */
BEGIN
/*Since TP is presently in LR,verify if its completed or not*/
SELECT COUNT (learning_record_id)
INTO v_inttpcompltd
FROM test_learning_record lr
WHERE lr.catalog_item_type = 'training-plan'
AND lr.status IN ('PASSED', 'WAIVED', 'TESTED_OUT')
AND lr.lr_catalog_history_id = p_strtplanid
AND lr.lr_person_id = p_strpersonid
AND lr.lr_org_id = p_strorg_id;
/*Credit based */
SELECT is_credit_based
INTO v_intcreditbased
FROM test_training_plan
WHERE tplan_id = p_strtplanid;
IF (v_inttpcompltd > 0)
THEN
IF (v_intcreditbased = 1)
THEN
DBMS_OUTPUT.put_line ('Starting Credit based ');
v_inttotreqactcompltd :=
fn_tp_get_cmpltd_act_cnt (p_strtplanid,
p_strpersonid,
p_strorg_id
SELECT NVL (EXTRACT (tplan_xml_data, '//numberOfCredits/text()').getstringval
0
NVL (EXTRACT (tplan_xml_data, '//accreditingOrg/text()').getstringval
0
INTO v_intrequiredcredits,
v_straccreditingorg
FROM test_training_plan
WHERE tplan_id = p_strtplanid;
SELECT accred_org_id
INTO v_straccreditingorg
FROM test_tp_acc_org
WHERE tplan_id = p_strtplanid;
IF (v_intrequiredcredits > v_inttotreqactcompltd)
THEN
DBMS_OUTPUT.put_line ('test_tp_acc_org ');
FOR obj IN (SELECT t_objective_id,
NVL (required_credits, 0) required_credits
FROM test_tp_objective
WHERE tplan_id = p_strtplanid)
LOOP
DBMS_OUTPUT.put_line
( ' Looping each Objective******************************'
|| obj.t_objective_id
SELECT NVL (SUM (lcdt.credit_hours), 0)
INTO v_inttotreqacttobecompltd
FROM test_train_obj_activity toa,
test_tp_objective tpobj,
test_learningactivity_credits lcdt,
test_tp_acc_org acc_org
WHERE lcdt.learning_activity_id = toa.activity_id
AND lcdt.acc_org_id = v_straccreditingorg
AND toa.t_objective_id = tpobj.t_objective_id
AND tpobj.tplan_id = acc_org.tplan_id
AND toa.t_objective_id = obj.t_objective_id
AND tpobj.tplan_id = p_strtplanid
AND tpobj.t_objective_id = obj.t_objective_id
AND toa.is_required = 1;
DBMS_OUTPUT.put_line
( 'Total credits for required activities****'
|| v_inttotreqacttobecompltd
--get credits for non event activities
SELECT NVL (SUM (credit_hours), 0)
INTO v_intnoneventbasedactcredit
FROM test_tp_objective tobj,
test_train_obj_activity toa,
test_learningactivity_credits lac,
test_learning_record lr,
test_tp_learning_activity tplplr,
test_learning_record tplr
WHERE tobj.t_objective_id = obj.t_objective_id
AND toa.t_objective_id = tobj.t_objective_id
AND toa.activity_id = lac.learning_activity_id
AND toa.activity_id = lr.lr_catalog_history_id
AND toa.is_required = 1
AND lr.learning_record_id = tplplr.activity_lp_lr_id
AND tplplr.tp_lp_lr_id = tplr.learning_record_id
AND tobj.tplan_id = p_strtplanid
AND tplr.lr_catalog_history_id = p_strtplanid
AND acc_org_id = v_straccreditingorg
AND lr.lr_person_id = p_strpersonid
AND tplr.lr_person_id = p_strpersonid
AND lr.status IN ('PASSED', 'WAIVED', 'TESTED_OUT');
--Get credits for events
SELECT NVL (SUM (credit_hours), 0)
INTO v_inteventbasedactcredit
FROM test_learningactivity_credits lac
WHERE lac.learning_activity_id IN (
SELECT event_id
FROM test_tp_objective tobj,
test_train_obj_activity toa,
test_learning_record lr,
test_event_sessions sessions,
test_tp_learning_activity tplplr,
test_learning_record tplr
WHERE tobj.t_objective_id = obj.t_objective_id
AND tobj.t_objective_id = toa.t_objective_id
AND toa.activity_id = sessions.event_id
AND toa.is_required = 1
AND sessions.event_session_id =
lr.lr_catalog_history_id
AND lr.learning_record_id =
tplplr.activity_lp_lr_id
AND tplplr.tp_lp_lr_id = tplr.learning_record_id
AND tplr.lr_catalog_history_id = p_strtplanid
AND tobj.tplan_id = p_strtplanid
AND tplr.lr_person_id = p_strpersonid
AND lr.lr_person_id = p_strpersonid
AND lr.status IN
('PASSED', 'WAIVED', 'TESTED_OUT'))
AND acc_org_id = v_straccreditingorg;
v_inttotreqactcompltd :=
v_intnoneventbasedactcredit + v_inteventbasedactcredit;
DBMS_OUTPUT.put_line
( ' Total credits of reqd. completed activities'
|| v_inttotreqactcompltd
IF (v_inttotreqacttobecompltd <= v_inttotreqactcompltd)
THEN
DBMS_OUTPUT.put_line
( '****** START INSIDE OBJ-COUNT COMPLETED************** '
|| obj.required_credits
v_strreturnval :=
fn_tp_obj_comp_act_cdt (p_strpersonid,
p_strtplanid,
obj.t_objective_id,
v_intcreditbased
DBMS_OUTPUT.put_line ( 'FN_TP_GET_CMPLTD_ACT_CNT'
|| v_strreturnval
IF (obj.required_credits > v_strreturnval)
THEN
DBMS_OUTPUT.put_line
|| obj.required_credits
*I want to write a function to do the below looping and SELECT functionality and return certain values selected.*
*Most importantly- this query being run in several places throughout the whole main program and everytime I have to put this SQL there and*
*which has increased the code by huge amount.*
**Another thing is-I want to remove the NOT IN below and use a different approach.
/*Start processing of new activity */
FOR activity IN
(SELECT objact.activity_id, objact.activity_type,
objact.is_required
FROM test_training_plan tp,
test_tp_objective tp_obj,
test_train_obj_activity objact
WHERE tp.tplan_id = tp_obj.tplan_id
AND tp.tplan_id = p_strtplanid
AND tp_obj.t_objective_id = obj.t_objective_id
AND tp_obj.t_objective_id = objact.t_objective_id
AND objact.activity_id NOT IN (
SELECT tplplr.activity_id
FROM test_learning_record lr,
test_learning_record lr1,
test_tp_learning_activity tplplr
WHERE lr.lr_catalog_history_id =
tplplr.activity_id
AND lr.learning_record_id =
tplplr.activity_lp_lr_id
AND tplplr.tp_lp_lr_id =
lr1.learning_record_id
AND lr1.lr_catalog_history_id =
p_strtplanid
AND lr.lr_person_id = p_strpersonid
AND lr1.lr_person_id = p_strpersonid
AND lr.status IN
('PASSED', 'WAIVED',
'TESTED_OUT'))
AND objact.activity_id NOT IN (
SELECT event_id
FROM test_train_obj_activity toa,
test_event_sessions sessions,
test_learning_record lr1,
test_tp_learning_activity tplearnact,
test_learning_record tplr
WHERE toa.activity_id = sessions.event_id
AND sessions.event_session_id =
lr1.lr_catalog_history_id
AND lr1.learning_record_id =
tplearnact.activity_lp_lr_id
AND tplearnact.tp_lp_lr_id =
tplr.learning_record_id
AND tplr.lr_catalog_history_id =
p_strtplanid
---AND toa.is_required = 1
AND toa.t_objective_id =
obj.t_objective_id
AND tplr.lr_person_id = p_strpersonid
AND lr1.lr_person_id = p_strpersonid
AND lr1.status IN
('PASSED', 'WAIVED',
'TESTED_OUT')))
LOOP
/*The function should return data so that i can validate them as the below ones*/
IF (activity.activity_type = 'Course')
THEN
sp_test_assign_coursetp (p_strpersonid,
activity.activity_id,
p_strpersonid,
activity.activity_type,
activity.is_required,
p_strtplanid,
v_straccreditingorg,
obj.t_objective_id,
v_strlpid
ELSIF (activity.activity_type = 'Test')
THEN
sp_assign_testtp (p_strpersonid,
activity.activity_id,
p_strpersonid,
activity.activity_type,
activity.is_required,
p_strtplanid,
v_straccreditingorg,
obj.t_objective_id
END IF;
END LOOP;
DBMS_OUTPUT.put_line ('Case of Optional Activity');
ELSE
/*Start processing of new activity */
FOR activity IN
(SELECT objact.activity_id, objact.activity_type,
objact.is_required
FROM test_training_plan tp,
test_tp_objective tp_obj,
test_train_obj_activity objact
WHERE tp.tplan_id = tp_obj.tplan_id
AND tp.tplan_id = p_strtplanid
AND tp_obj.t_objective_id = obj.t_objective_id
AND objact.is_required = 1
AND tp_obj.t_objective_id = objact.t_objective_id
AND objact.activity_id NOT IN (
SELECT tplplr.activity_id
FROM test_learning_record lr,
test_learning_record lr1,
test_tp_learning_activity tplplr
WHERE lr.lr_catalog_history_id =
tplplr.activity_id
AND lr.learning_record_id =
tplplr.activity_lp_lr_id
AND tplplr.tp_lp_lr_id =
lr1.learning_record_id
AND lr1.lr_catalog_history_id =
p_strtplanid
AND lr.lr_person_id = p_strpersonid
AND lr1.lr_person_id = p_strpersonid
AND lr.status IN
('PASSED', 'WAIVED',
'TESTED_OUT'))
AND objact.activity_id NOT IN (
SELECT event_id
FROM test_train_obj_activity toa,
test_event_sessions sessions,
test_learning_record lr1,
test_tp_learning_activity tplearnact,
test_learning_record tplr
WHERE toa.activity_id = sessions.event_id
AND sessions.event_session_id =
lr1.lr_catalog_history_id
AND lr1.learning_record_id =
tplearnact.activity_lp_lr_id
AND tplearnact.tp_lp_lr_id =
tplr.learning_record_id
AND tplr.lr_catalog_history_id =
p_strtplanid
AND toa.is_required = 1
AND toa.t_objective_id =
obj.t_objective_id
AND tplr.lr_person_id = p_strpersonid
AND lr1.lr_person_id = p_strpersonid
AND lr1.status IN
('PASSED', 'WAIVED',
'TESTED_OUT'))
LOOP
/*Move the TP only for required ids */
IF (activity.activity_type = 'Course')
THEN
SP_TEST_ASSIGN_COURSETP (p_strpersonid,
activity.activity_id,
p_strpersonid,
activity.activity_type,
activity.is_required,
p_strtplanid,
v_straccreditingorg,
obj.t_objective_id,
v_strlpid
ELSIF (activity.activity_type = 'Test')
THEN
sp_assign_testtp (p_strpersonid,
activity.activity_id,
p_strpersonid,
activity.activity_type,
activity.is_required,
p_strtplanid,
v_straccreditingorg,
obj.t_objective_id
END IF;
END LOOP;
END IF;
ELSE
DBMS_OUTPUT.put_line
('*********/*No of required credits is more then completed
******Start processing of new activity */'
/*Start processing of new activity */
FOR activity IN
(SELECT objact.activity_id, objact.activity_type,
objact.is_required
FROM test_training_plan tp,
test_tp_objective tp_obj,
test_train_obj_activity objact
WHERE tp.tplan_id = tp_obj.tplan_id
AND tp.tplan_id = p_strtplanid
AND tp_obj.t_objective_id = obj.t_objective_id
AND objact.is_required = 1
AND objact.t_objective_id = tp_obj.t_objective_id
AND objact.activity_id NOT IN (
SELECT tplplr.activity_id
FROM test_learning_record lr,
test_learning_record lr1,
test_tp_learning_activity tplplr
WHERE lr.lr_catalog_history_id =
tplplr.activity_id
AND lr.learning_record_id =
tplplr.activity_lp_lr_id
AND tplplr.tp_lp_lr_id =
lr1.learning_record_id
AND lr1.lr_catalog_history_id =
p_strtplanid
AND lr.lr_person_id = p_strpersonid
AND lr1.lr_person_id = p_strpersonid
AND lr.status IN
('PASSED', 'WAIVED', 'TESTED_OUT'))
AND objact.activity_id NOT IN (
SELECT event_id
FROM test_train_obj_activity toa,
test_event_sessions sessions,
test_learning_record lr1,
test_tp_learning_activity tplearnact,
test_learning_record tplr
WHERE toa.activity_id = sessions.event_id
AND sessions.event_session_id =
lr1.lr_catalog_history_id
AND lr1.learning_record_id =
tplearnact.activity_lp_lr_id
AND tplearnact.tp_lp_lr_id =
tplr.learning_record_id
AND tplr.lr_catalog_history_id =
p_strtplanid
AND toa.is_required = 1
AND toa.t_objective_id = obj.t_objective_id
AND tplr.lr_person_id = p_strpersonid
AND lr1.lr_person_id = p_strpersonid
AND lr1.status IN
('PASSED', 'WAIVED', 'TESTED_OUT')))
LOOP
/*Move the TP only for required ids */
IF (activity.activity_type = 'Course')
THEN
sp_assign_coursetp (p_strpersonid,
activity.activity_id,
p_strpersonid,
activity.activity_type,
activity.is_required,
p_strtplanid,
v_straccreditingorg,
obj.t_objective_id,
v_strlpid
ELSIF (activity.activity_type = 'Test')
THEN
sp_assign_testtp (p_strpersonid,
activity.activity_id,
p_strpersonid,
activity.activity_type,
activity.is_required,
p_strtplanid,
v_straccreditingorg,
obj.t_objective_id
END IF;
END LOOP;
END IF;
FOR lr_lp_act IN (SELECT tplplr.activity_id,
tplplr.tp_lp_lr_id
FROM test_tp_objective tp_obj,
test_train_obj_activity toa,
test_learning_record lr,
test_tp_learning_activity tplplr,
test_learning_record tplr
WHERE tplplr.activity_lp_lr_id =
lr.learning_record_id
AND lr.lr_catalog_history_id =
toa.activity_id
AND tplplr.tp_lp_lr_id =
tplr.learning_record_id
AND tp_obj.t_objective_id =
toa.t_objective_id
AND tp_obj.tplan_id = p_strtplanid
AND tplplr.lp_lr_flag = 'LR'
AND tp_obj.t_objective_id =
obj.t_objective_id
AND lr.status IN
('PASSED', 'WAIVED', 'TESTED_OUT')
AND lr.lr_person_id = p_strpersonid
AND tplr.lr_person_id = p_strpersonid)
LOOP
DBMS_OUTPUT.put_line
( 'Get data for the activity to update TPs LP id****'
|| v_strlpid
DBMS_OUTPUT.put_line
( 'Values which I am updating----lr_lp_act.activity_id---'
|| obj.t_objective_id
DBMS_OUTPUT.put_line
( 'Values which I am updating----lr_lp_act.activity_id---'
|| lr_lp_act.activity_id
DBMS_OUTPUT.put_line
( 'Values which I am updating----lr_lp_act.tp_lp_lr_id---'
|| lr_lp_act.tp_lp_lr_id
UPDATE test_tp_learning_activity
SET tp_lp_lr_id = v_strlpid
WHERE activity_id = lr_lp_act.activity_id
AND tp_lp_lr_id = lr_lp_act.tp_lp_lr_id;
UPDATE test_learning_record
SET is_for_training_plan = 'NO'
WHERE learning_record_id IN (
SELECT activity_lp_lr_id
FROM test_tp_learning_activity
WHERE tp_lp_lr_id =
lr_lp_act.tp_lp_lr_id);
END LOOP;
END LOOP;
DELETE FROM test_learning_record_details
WHERE learning_record_id =
(SELECT learning_record_id
FROM test_learning_record
WHERE lr_catalog_history_id = p_strtplanid
AND lr_person_id = p_strpersonid
AND status = 'PASSED');
DBMS_OUTPUT.put_line
('UPDATE
test_learning_record_details'
DELETE FROM test_learning_record
WHERE learning_record_id =
(SELECT learning_record_id
FROM test_learning_record
WHERE lr_catalog_history_id = p_strtplanid
AND lr_person_id = p_strpersonid
AND status = 'PASSED');
END IF; -
How to draw a line(shortest distance) between two ellipse using SWING
how to draw a line(should be shortest distance) between two ellipse using SWING
any help will be appreciated
regardsimport java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import javax.swing.*;
import javax.swing.event.MouseInputAdapter;
public class ELine extends JPanel {
Ellipse2D.Double red = new Ellipse2D.Double(150,110,75,165);
Ellipse2D.Double blue = new Ellipse2D.Double(150,50,100,50);
Line2D.Double line = new Line2D.Double();
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
RenderingHints.VALUE_ANTIALIAS_ON);
g2.setPaint(Color.green.darker());
g2.draw(line);
g2.setPaint(Color.blue);
g2.draw(blue);
g2.setPaint(Color.red);
g2.draw(red);
private void connect() {
double flatness = 0.01;
PathIterator pit = blue.getPathIterator(null, flatness);
double[] coords = new double[2];
double x1 = 0, y1 = 0, x2 = 0, y2 = 0;
double min = Double.MAX_VALUE;
while(!pit.isDone()) {
int type = pit.currentSegment(coords);
switch(type) {
case PathIterator.SEG_MOVETO:
case PathIterator.SEG_LINETO:
Point2D.Double p = getClosestPoint(coords[0], coords[1]);
double dist = p.distance(coords[0], coords[1]);
if(dist < min) {
min = dist;
x1 = coords[0];
y1 = coords[1];
x2 = p.x;
y2 = p.y;
break;
case PathIterator.SEG_CLOSE:
break;
default:
System.out.println("blue type: " + type);
pit.next();
line.setLine(x1, y1, x2, y2);
private Point2D.Double getClosestPoint(double x, double y) {
double flatness = 0.01;
PathIterator pit = red.getPathIterator(null, flatness);
double[] coords = new double[2];
Point2D.Double p = new Point2D.Double();
double min = Double.MAX_VALUE;
while(!pit.isDone()) {
int type = pit.currentSegment(coords);
switch(type) {
case PathIterator.SEG_MOVETO:
case PathIterator.SEG_LINETO:
double dist = Point2D.distance(x, y, coords[0], coords[1]);
if(dist < min) {
min = dist;
p.setLocation(coords[0], coords[1]);
break;
case PathIterator.SEG_CLOSE:
break;
default:
System.out.println("red type: " + type);
pit.next();
return p;
public static void main(String[] args) {
final ELine test = new ELine();
test.addMouseListener(test.mia);
test.addMouseMotionListener(test.mia);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(test);
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
Graphics g = test.getGraphics();
g.drawString("drag me", 175, 80);
g.dispose();
private MouseInputAdapter mia = new MouseInputAdapter() {
Point2D.Double offset = new Point2D.Double();
boolean dragging = false;
public void mousePressed(MouseEvent e) {
Point p = e.getPoint();
if(blue.contains(p)) {
offset.x = p.x - blue.x;
offset.y = p.y - blue.y;
dragging = true;
public void mouseReleased(MouseEvent e) {
dragging = false;
public void mouseDragged(MouseEvent e) {
if(dragging) {
double x = e.getX() - offset.x;
double y = e.getY() - offset.y;
blue.setFrame(x, y, blue.width, blue.height);
connect();
repaint();
} -
New to PL/SQL and need help on check sum using ASCII function
Hello,
Need your expertise to help in figuring out how to write
code to calculate using ASCII function to return value for a character. For example ASCII('A') is 58. I want to do the check sum to sum-up the value for each character in the name. For example 'Jack'
Appreciate your help.
CKHi,
Please post all the technical queries in the respective forums. For more details and answers in SQL and PL/SQL, use the following forum:
PL/SQL
Sample PL/SQL code for your requirement:
-- make sure you have the serveroutput on using command.
-- set serveroutput on
DECLARE
sumval NUMBER(10);
tempval NUMBER(10);
colval VARCHAR2(20);
BEGIN
SELECT USER INTO colval FROM dual;
sumval := 0;
FOR i IN 1..LENGTH(colval)
LOOP
SELECT ASCII(SUBSTR(colval,i,1)) INTO tempval FROM dual;
sumval := sumval+tempval;
END LOOP;
DBMS_OUTPUT.PUT_LINE('sum is: '||to_char(sumval));
END;
The output of this pl/sql block will be:
sum is: 397
Please note: ASCII('A') is 65 and not 58.
Hope that helps.
Savitha.
http://otn.oracle.com/sample_code/content.html -
Using analytical function to calculate concurrency between date range
Folks,
I'm trying to use analytical functions to come up with a query that gives me the
concurrency of jobs executing between a date range.
For example:
JOB100 - started at 9AM - stopped at 11AM
JOB200 - started at 10AM - stopped at 3PM
JOB300 - started at 12PM - stopped at 2PM
The query would tell me that JOB1 ran with a concurrency of 2 because JOB1 and JOB2
were running started and finished within the same time. JOB2 ran with the concurrency
of 3 because all jobs ran within its start and stop time. The output would look like this.
JOB START STOP CONCURRENCY
=== ==== ==== =========
100 9AM 11AM 2
200 10AM 3PM 3
300 12PM 2PM 2
I've been looking at this post, and this one if very similar...
Analytic functions using window date range
Here is the sample data..
CREATE TABLE TEST_JOB
( jobid NUMBER,
created_time DATE,
start_time DATE,
stop_time DATE
insert into TEST_JOB values (100, sysdate -1, to_date('05/04/08 09:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 11:00:00','MM/DD/YY hh24:mi:ss'));
insert into TEST_JOB values (200, sysdate -1, to_date('05/04/08 10:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 13:00:00','MM/DD/YY hh24:mi:ss'));
insert into TEST_JOB values (300, sysdate -1, to_date('05/04/08 12:00:00','MM/DD/YY hh24:mi:ss'), to_date('05/04/08 14:00:00','MM/DD/YY hh24:mi:ss'));
select * from test_job;
JOBID|CREATED_TIME |START_TIME |STOP_TIME
----------|--------------|--------------|--------------
100|05/04/08 09:28|05/04/08 09:00|05/04/08 11:00
200|05/04/08 09:28|05/04/08 10:00|05/04/08 13:00
300|05/04/08 09:28|05/04/08 12:00|05/04/08 14:00
Any help with this query would be greatly appreciated.
thanks.
-peterafter some checking the model rule wasn't working exactly as expected.
I believe it's working right now. I'm posting a self-contained example for completeness sake.I use 2 functions to convert back and forth between epoch unix timestamps, so
I'll post them here as well.
Like I said I think this works okay, but any feedback is always appreciated.
-peter
CREATE OR REPLACE FUNCTION date_to_epoch(p_dateval IN DATE)
RETURN NUMBER
AS
BEGIN
return (p_dateval - to_date('01/01/1970','MM/DD/YYYY')) * (24 * 3600);
END;
CREATE OR REPLACE FUNCTION epoch_to_date (p_epochval IN NUMBER DEFAULT 0)
RETURN DATE
AS
BEGIN
return to_date('01/01/1970','MM/DD/YYYY') + (( p_epochval) / (24 * 3600));
END;
DROP TABLE TEST_MODEL3 purge;
CREATE TABLE TEST_MODEL3
( jobid NUMBER,
start_time NUMBER,
end_time NUMBER);
insert into TEST_MODEL3
VALUES (300,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 19:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (200,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 12:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (400,date_to_epoch(to_date('05/07/2008 10:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 14:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (500,date_to_epoch(to_date('05/07/2008 11:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 16:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (600,date_to_epoch(to_date('05/07/2008 15:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 22:00','MM/DD/YYYY hh24:mi')));
insert into TEST_MODEL3
VALUES (100,date_to_epoch(to_date('05/07/2008 09:00','MM/DD/YYYY hh24:mi')),
date_to_epoch(to_date('05/07/2008 23:00','MM/DD/YYYY hh24:mi')));
commit;
SELECT jobid,
epoch_to_date(start_time)start_time,
epoch_to_date(end_time)end_time,
n concurrency
FROM TEST_MODEL3
MODEL
DIMENSION BY (start_time,end_time)
MEASURES (jobid,0 n)
(n[any,any]=
count(*)[start_time<= cv(start_time),end_time>=cv(start_time)]+
count(*)[start_time > cv(start_time) and start_time <= cv(end_time), end_time >= cv(start_time)]
ORDER BY start_time;
The results look like this:
JOBID|START_TIME|END_TIME |CONCURRENCY
----------|---------------|--------------|-------------------
100|05/07/08 09:00|05/07/08 23:00| 6
200|05/07/08 09:00|05/07/08 12:00| 5
300|05/07/08 10:00|05/07/08 19:00| 6
400|05/07/08 10:00|05/07/08 14:00| 5
500|05/07/08 11:00|05/07/08 16:00| 6
600|05/07/08 15:00|05/07/08 22:00| 4 -
Help in using listagg function for more than 8000 char.
Hi Friends,
Need you urgent help in using listagg function for more than 8000 char.
I did the below sample SQL and in "e_orig" and "d_orig" for upto 4000 char it is working fine but I have to use it for more than 8000 char. and it is giving error,
I checked the listagg function is having limitation of 4000 char.
I tried but I am unable to achive this. Can someone provide me a sample example to achive this
select d.dname,d.loc,e.hiredate
,listagg(e.ename,',' ) within group (order by e.deptno) over (partition by e.deptno) as e_orig
,listagg(e.ename, ',') within group (order by e.sal) over (partition by e.deptno) as d_orig
from emp e, dept d
where e.deptno=d.deptno;[ This is my first post, I gone through the guideline for posting a post , and try to go according to that ( I have not pasted here create table and insert as I have used basic table emp, dept for example), please let me know if still I should give this, I will take care from my next post ]
Thanks in advanceInteresting, I didn't know you could do that, but...
BluShadow wrote:
You could write some PL/SQL code that does it all for you, but that would involve loops and would be slow.Well, objects are written in PL/SQL aren't they? And presumably there'll be implicit looping too? So it's not at all obvious that this method will be faster than doing the joining in PL/SQL in memory. The only way to find out is to benchmark them - so I have done that.
I noticed that OP's ref cursor actually only ever retrieves a single record for a bound department number, so I decided the best thing would be to test using a procedure that passes an output string back. I selected all (109) employees and put spaces in to ensure above 4000 characters. I also noticed that as he is using PL/SQL he probably can use a VARCHAR2 type, but just not ListAgg in the query, so I wrote short procedures as follows:
SimpleAggChr - bulk collect and array processing, VARCHAR2 output
ClobAggPrc - the custom aggregation method, CLOB output
SimpleAggClob - bulk collect and array processing, CLOB output
I then wrote a driving script that calls them in the order above and times each call (I like benchmarking so I have my own timing object to make it easy). I then print the lengths for checking, and my object writes the timings to my output table. Running a few times I got varying results, but generally it looks like there isn't a lot to choose between them for performance.
Here's the procedure code:
CREATE OR REPLACE TYPE char100_list_type AS TABLE OF VARCHAR2(100)
CREATE OR REPLACE PROCEDURE SimpleAggChr (x_out OUT VARCHAR2) IS
l_enames char100_list_type;
BEGIN
SELECT first_name || ' ' || last_name
BULK COLLECT INTO l_enames
FROM employees
ORDER BY salary;
FOR i IN 1..l_enames.COUNT LOOP
x_out := x_out || l_enames(i) || ',';
END LOOP;
END SimpleAggChr;
CREATE OR REPLACE PROCEDURE SimpleAggClob (x_out OUT CLOB) IS
l_enames char100_list_type;
BEGIN
SELECT first_name || ' ' || last_name
BULK COLLECT INTO l_enames
FROM employees
ORDER BY salary;
FOR i IN 1..l_enames.COUNT LOOP
x_out := x_out || l_enames(i) || ',';
END LOOP;
END SimpleAggClob;
SHO ERR
PROMPT ClobAggPrc
CREATE OR REPLACE PROCEDURE ClobAggPrc (x_out OUT CLOB) IS
BEGIN
SELECT clobagg(first_name || ' ' || last_name || ',')
INTO x_out
FROM employees
ORDER BY salary;
END ClobAggPrc;
SHO ERRand the driving script:
SET SERVEROUTPUT ON
SET TIMING ON
DECLARE
l_enames_c1 CLOB;
l_enames_c2 CLOB;
l_enames_v VARCHAR2(32767);
l_timer timer_set_type := timer_set_type ('Aggregation');
BEGIN
Utils.g_id := 'Aggregation';
SimpleAggChr (l_enames_v);
l_timer.Increment_Time ('SimpleAggChr');
ClobAggPrc (l_enames_c1);
l_timer.Increment_Time ('ClobAggPrc');
SimpleAggClob (l_enames_c2);
l_timer.Increment_Time ('SimpleAggClob');
DBMS_Output.Put_Line ('SimpleAggChr returned string of length ' || Length (l_enames_v));
DBMS_Output.Put_Line ('ClobAggPrc returned string of length ' || Length (l_enames_c1));
DBMS_Output.Put_Line ('SimpleAggClob returned string of length ' || Length (l_enames_c2));
l_timer.Write_Times;
END;
SET TIMING OFF
SET LINES 150
SET PAGES 1000
COLUMN id FORMAT A30
COLUMN line_text FORMAT A120
SELECT line_text
FROM output_log
WHERE id = 'Aggregation'
ORDER BY line_ind
/and the results:
SimpleAggChr returned string of length 5779
ClobAggPrc returned string of length 5779
SimpleAggClob returned string of length 5779
PL/SQL procedure successfully completed.
Elapsed: 00:00:27.05
LINE_TEXT
Timer Set: Aggregation, constructed at 03 Nov 2011 16:27:07, written at 16:27:35
================================================================================
[Timer timed: Elapsed (per call): 0.02 (0.000016), CPU (per call): 0.01 (0.000010), calls: 1000, '***' denotes corrected
line below]
Timer Elapsed CPU Calls Ela/Call CPU/Call
SimpleAggChr 9.84 0.36 1 9.84400 0.36000
ClobAggPrc 9.37 0.32 1 9.37400 0.32000
SimpleAggClob 8.25 0.22 1 8.25000 0.22000
(Other) 0.00 0.00 1 0.00000 0.00000
Total 27.47 0.90 4 6.86700 0.22500
13 rows selected. -
Using substr function loses index. Query tune help
Hi
when i use substr function in the join condition it loses index and the query is slow. How to fix this problem or tune this query. These are the lines in the query.
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_key
select
pap.full_name employe_name,
k.SEGMENT1 ||'.' ||k.segment2 Cost_Center,
a.invoice_num Invoice_Number,
b.item_description Line_Item,
b.amount Amount,
cc.trx_id Corporate_Card_Transaction_Id,
cc.transaction_date Date_Charge_Incurred,
cc.posted_date Date_Charge_Posted_To_USBank,
cc.creation_date Date_Posted_To_IExpense,
a.creation_date Expense_Report_Creation_Date,
l.report_submitted_date Expense_Report_Submitted_Date,
mgr_apprv_lst.activity_begin_date Managers_Approval_Begin_Date,
mgr_apprv_lst.activity_end_date Managers_Approval_End_Date,
pbl_apprv_lst.activity_begin_date AP_Approval_Begin_Date,
pbl_apprv_lst.activity_end_date AP_Approval_End_Date,
e.check_date Payment_Date_To_USBank,
e.check_number Payment_Number,
mgr_apprv_lst.activity_result_display_name Managers_Process_Result,
pbl_apprv_lst.activity_result_display_name AP_Process_Result
from
ap_checks_all e,
ap_invoice_payments_all d,
ap_invoices_all c,
ap_expense_report_headers_all a,
ap_credit_card_trxns_all cc,
per_all_people_f pap,
ap_expense_report_headers_all l,
ap_expense_report_lines_all b,
gl_code_combinations k,
(select ias1.user_key,
ias1.activity_result_display_name,
ias1.activity_begin_date,
ias1.activity_end_date
from wf_item_activity_statuses_v ias1,
(select c1.invoice_num
from ap_checks_all e1,
ap_invoice_payments_all d1,
ap_invoices_all c1
where trunc(e1.check_date) between nvl(:From_Date, trunc(e1.check_date))
and nvl(:To_Date, trunc(e1.check_date))
and e1.org_id = 141
and e1.void_date IS null
and d1.check_id = e1.check_id
and c1.invoice_id = d1.invoice_id) inv_lst1
where ias1.item_type = 'APEXP'
and ias1.user_key = inv_lst1.invoice_num
and ias1.activity_name = 'AP_MANAGER_APPROVAL_PROCESS') mgr_apprv_lst,
(select ias2.user_key,
ias2.activity_result_display_name,
ias2.activity_begin_date,
ias2.activity_end_date
from wf_item_activity_statuses_v ias2,
(select c2.invoice_num
from ap_checks_all e2,
ap_invoice_payments_all d2,
ap_invoices_all c2
where trunc(e2.check_date) between nvl(:From_Date, trunc(e2.check_date))
and nvl(:To_Date, trunc(e2.check_date))
and e2.org_id = 141
and e2.void_date IS null
and d2.check_id = e2.check_id
and c2.invoice_id = d2.invoice_id) inv_lst2
where ias2.item_type = 'APEXP'
and ias2.user_key = inv_lst2.invoice_num
and ias2.activity_name = 'AP_PAYABLES_APPROVAL_PROCESS') pbl_apprv_lst
where
trunc(e.check_date) between nvl(:From_Date, trunc(e.check_date))
and nvl(:To_Date, trunc(e.check_date))
and e.org_id = 141
and e.void_date IS null
and d.check_id = e.check_id
and c.invoice_id = d.invoice_id
and a.invoice_num = c.invoice_num
and a.source = 'CREDIT CARD'
and a.employee_id = nvl(:Emp_id,a.employee_id)
and a.report_header_id = b.report_header_id
and cc.trx_id = b.credit_card_trx_id
and pap.person_id = a.employee_id
and pap.effective_start_date <= trunc(sysdate)
and pap.effective_end_date >= trunc(sysdate)
and k.code_combination_id = b.code_combination_id
and k.segment2 between nvl(:From_Cost_Center,k.segment2)
and nvl(:To_Cost_Center,k.segment2)
and substr(a.invoice_num,1,9) = l.invoice_num
and substr(c.invoice_num,1,9) = mgr_apprv_lst.user_key
and substr(c.invoice_num,1,9) = pbl_apprv_lst.user_keyHi
If I understood correctly your logic, and if the columns involved are of type varchar2, you can use the like operator:
and a.invoice_num like l.invoice_num || '%'
and c.invoice_num like mgr_apprv_lst.user_key || '%'
and c.invoice_num like pbl_apprv_lst.user_key || '%'In this case, Oracle will be able to use the indexes. If they are numeric, you need to do something like:
and a.invoice_num between l.invoice_num * 1000000
and l.invoice_num * 1000000 + 999999I hope this makes sense...
Luis -
Help needed Displaying ALV Secondary list without using oops concept
Hi Experts
Help needed Displaying ALV Secondary list without using oops concept.
its urgent
regds
rajasekharhi chk this code
******************TABLES DECLARATION*****************
TABLES : VBAP,MARA.
*****************TYPE POOLS**************************
TYPE-POOLS : SLIS.
****************INTERNAL TABLES**********************
DATA : BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
END OF IT_VBAP.
****************TEMPORARY VARIABLES******************
DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
*****************FIELD CATALOG***********************
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
****************LAYOUT*******************************
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
***************VARIANT*******************************
DATA : G_VARIANT LIKE DISVARIANT.
****************SAVE*********************************
DATA : G_SAVE(1) TYPE C.
*****************EVENTS******************************
DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
G_EVENTS TYPE SLIS_T_EVENT.
******************PF STATUS**************************
DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
******************USER COMMAND************************
DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
R_UCOMM LIKE SY-UCOMM.
****************SELECTION SCREEN************************
SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
***************AT SELECTION SCREEN*********************
AT SELECTION-SCREEN.
PERFORM VALIDATE.
**************START-OF-SELECTION**************************
START-OF-SELECTION.
PERFORM GET_DETAILS.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM VARIANT.
PERFORM SAVE.
PERFORM EVENTS.
PERFORM ALV_DISPLAY.
*********************FORMS*******************************************
*& Form validate
text
--> p1 text
<-- p2 text
FORM VALIDATE .
SELECT SINGLE VBELN
FROM VBAP
INTO V_VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'enter valid vbeln'.
ENDIF.
ENDFORM. " validate
*& Form get_details
text
--> p1 text
<-- p2 text
FORM GET_DETAILS .
SELECT VBELN
POSNR
MATNR
FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'no details found'.
ENDIF.
ENDFORM. " get_details
*& Form fieldcat
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-OUTPUTLEN = 10.
WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-OUTPUTLEN = 6.
WA_FIELDCAT-SELTEXT_L = 'ITEM'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-OUTPUTLEN = 18.
WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " fieldcat
*& Form LAYOUT
text
--> p1 text
<-- p2 text
FORM LAYOUT .
WA_LAYOUT-ZEBRA = 'X'.
ENDFORM. " LAYOUT
*& Form VARIANT
text
--> p1 text
<-- p2 text
FORM VARIANT .
CLEAR G_VARIANT.
G_VARIANT-REPORT = SY-REPID.
ENDFORM. " VARIANT
*& Form SAVE
text
--> p1 text
<-- p2 text
FORM SAVE .
CLEAR G_SAVE.
G_SAVE = 'A'.
ENDFORM. " SAVE
*& Form EVENTS
text
--> p1 text
<-- p2 text
FORM EVENTS .
CLEAR XS_EVENTS.
XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENTS-FORM = 'TOP_OF_PAGE'.
APPEND XS_EVENTS TO G_EVENTS.
ENDFORM. " EVENTS
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
WRITE :/ ' INTELLI GROUP'.
ENDFORM. "TOP_OF_PAGE
*& Form ALV_DISPLAY
text
--> p1 text
<-- p2 text
FORM ALV_DISPLAY .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = PF_STATUS
I_CALLBACK_USER_COMMAND = USER_COMMAND
I_STRUCTURE_NAME =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = G_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ALV_DISPLAY
*& Form SET_PF_STATUS
text
FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'Z50651_PFSTATUS' EXCLUDING EXTAB.
ENDFORM. "SET_PF_STATUS
*& Form SET_USER_COMMAND
text
FORM SET_USER_COMMAND USING R_UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DC'.
READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
SELECT SINGLE MTART
FROM MARA
INTO V_MTART
WHERE MATNR = IT_VBAP-MATNR.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
ELSE.
WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
WRITE :/ 'MATERIAL TYPE :' , V_MTART.
ENDIF.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CLOSE'.
CALL TRANSACTION 'SE38'.
ENDCASE.
REPORT Z_ALV_INTERACTIVE MESSAGE-ID ZMSG_50651
LINE-SIZE 100
LINE-COUNT 60
NO STANDARD PAGE HEADING.
******************TABLES DECLARATION*****************
TABLES : VBAP,MARA.
*****************TYPE POOLS**************************
TYPE-POOLS : SLIS.
****************INTERNAL TABLES**********************
DATA : BEGIN OF IT_VBAP OCCURS 0,
VBELN LIKE VBAP-VBELN, "SALES DOCUMENT
POSNR LIKE VBAP-POSNR, "SALES DOCUMENT ITEM
MATNR LIKE VBAP-MATNR, "MATERIAL NUMBER
END OF IT_VBAP.
****************TEMPORARY VARIABLES******************
DATA : V_VBELN LIKE VBAP-VBELN."SALES DOCUMENT
DATA : V_MTART LIKE MARA-MTART. "MATERIAL TYPE
*****************FIELD CATALOG***********************
DATA : IT_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
****************LAYOUT*******************************
DATA : WA_LAYOUT TYPE SLIS_LAYOUT_ALV.
***************VARIANT*******************************
DATA : G_VARIANT LIKE DISVARIANT.
****************SAVE*********************************
DATA : G_SAVE(1) TYPE C.
*****************EVENTS******************************
DATA : XS_EVENTS TYPE SLIS_ALV_EVENT,
G_EVENTS TYPE SLIS_T_EVENT.
******************PF STATUS**************************
DATA : PF_STATUS TYPE SLIS_FORMNAME VALUE 'SET_PF_STATUS'.
******************USER COMMAND************************
DATA : USER_COMMAND TYPE SLIS_FORMNAME VALUE 'SET_USER_COMMAND',
R_UCOMM LIKE SY-UCOMM.
****************SELECTION SCREEN************************
SELECT-OPTIONS : S_VBELN FOR VBAP-VBELN.
***************AT SELECTION SCREEN*********************
AT SELECTION-SCREEN.
PERFORM VALIDATE.
**************START-OF-SELECTION**************************
START-OF-SELECTION.
PERFORM GET_DETAILS.
PERFORM FIELDCAT.
PERFORM LAYOUT.
PERFORM VARIANT.
PERFORM SAVE.
PERFORM EVENTS.
PERFORM ALV_DISPLAY.
*********************FORMS*******************************************
*& Form validate
text
--> p1 text
<-- p2 text
FORM VALIDATE .
SELECT SINGLE VBELN
FROM VBAP
INTO V_VBELN
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'enter valid vbeln'.
ENDIF.
ENDFORM. " validate
*& Form get_details
text
--> p1 text
<-- p2 text
FORM GET_DETAILS .
SELECT VBELN
POSNR
MATNR
FROM VBAP
INTO TABLE IT_VBAP
WHERE VBELN IN S_VBELN.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'no details found'.
ENDIF.
ENDFORM. " get_details
*& Form fieldcat
text
--> p1 text
<-- p2 text
FORM FIELDCAT .
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'VBELN'.
WA_FIELDCAT-OUTPUTLEN = 10.
WA_FIELDCAT-SELTEXT_L = 'SALES DOC'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'POSNR'.
WA_FIELDCAT-OUTPUTLEN = 6.
WA_FIELDCAT-SELTEXT_L = 'ITEM'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
WA_FIELDCAT-TABNAME = 'IT_VBAP'.
WA_FIELDCAT-FIELDNAME = 'MATNR'.
WA_FIELDCAT-OUTPUTLEN = 18.
WA_FIELDCAT-SELTEXT_L = 'MATERIAL NO'.
APPEND WA_FIELDCAT TO IT_FIELDCAT.
CLEAR WA_FIELDCAT.
ENDFORM. " fieldcat
*& Form LAYOUT
text
--> p1 text
<-- p2 text
FORM LAYOUT .
WA_LAYOUT-ZEBRA = 'X'.
ENDFORM. " LAYOUT
*& Form VARIANT
text
--> p1 text
<-- p2 text
FORM VARIANT .
CLEAR G_VARIANT.
G_VARIANT-REPORT = SY-REPID.
ENDFORM. " VARIANT
*& Form SAVE
text
--> p1 text
<-- p2 text
FORM SAVE .
CLEAR G_SAVE.
G_SAVE = 'A'.
ENDFORM. " SAVE
*& Form EVENTS
text
--> p1 text
<-- p2 text
FORM EVENTS .
CLEAR XS_EVENTS.
XS_EVENTS-NAME = SLIS_EV_TOP_OF_PAGE.
XS_EVENTS-FORM = 'TOP_OF_PAGE'.
APPEND XS_EVENTS TO G_EVENTS.
ENDFORM. " EVENTS
*& Form TOP_OF_PAGE
text
FORM TOP_OF_PAGE.
WRITE :/ ' INTELLI GROUP'.
ENDFORM. "TOP_OF_PAGE
*& Form ALV_DISPLAY
text
--> p1 text
<-- p2 text
FORM ALV_DISPLAY .
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_INTERFACE_CHECK = ' '
I_BYPASSING_BUFFER =
I_BUFFER_ACTIVE = ' '
I_CALLBACK_PROGRAM = SY-REPID
I_CALLBACK_PF_STATUS_SET = PF_STATUS
I_CALLBACK_USER_COMMAND = USER_COMMAND
I_STRUCTURE_NAME =
IS_LAYOUT = WA_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
IT_EXCLUDING =
IT_SPECIAL_GROUPS =
IT_SORT =
IT_FILTER =
IS_SEL_HIDE =
I_DEFAULT = 'X'
I_SAVE = G_SAVE
IS_VARIANT = G_VARIANT
IT_EVENTS = G_EVENTS
IT_EVENT_EXIT =
IS_PRINT =
IS_REPREP_ID =
I_SCREEN_START_COLUMN = 0
I_SCREEN_START_LINE = 0
I_SCREEN_END_COLUMN = 0
I_SCREEN_END_LINE = 0
IMPORTING
E_EXIT_CAUSED_BY_CALLER =
ES_EXIT_CAUSED_BY_USER =
TABLES
T_OUTTAB = IT_VBAP
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " ALV_DISPLAY
*& Form SET_PF_STATUS
text
FORM SET_PF_STATUS USING EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'STANDARD' EXCLUDING EXTAB.
ENDFORM. "SET_PF_STATUS
*& Form SET_USER_COMMAND
text
FORM SET_USER_COMMAND USING R_UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
CASE R_UCOMM.
WHEN 'DC'.
READ TABLE IT_VBAP INDEX RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
SELECT SINGLE MTART
FROM MARA
INTO V_MTART
WHERE MATNR = IT_VBAP-MATNR.
IF SY-SUBRC <> 0.
MESSAGE E000 WITH 'NO MATERIAL DESCRIPTION FOR SELECTED MATERIAL NO'.
ELSE.
WRITE :/ 'MATERIAL NO :',IT_VBAP-MATNR.
WRITE :/ 'MATERIAL TYPE :' , V_MTART.
SUBMIT SLIS_DUMMY WITH P_MATNR EQ IT_VBAP-MATNR
WITH P_MTART EQ V_MTART.
ENDIF.
ENDIF.
WHEN 'BACK'.
LEAVE TO SCREEN 0.
WHEN 'EXIT'.
LEAVE TO SCREEN 0.
WHEN 'CLOSE'.
CALL TRANSACTION 'SE38'.
ENDCASE.
plz reward if useful
Maybe you are looking for
-
I am already a Firefox user, how do I get rid of the new Firefox setup on my computer?
I am already a Firefox user, how do I get rid of the new Firefox 4 setup on my computer now?
-
How to build dynamic query strings in the query using DB adapter 'Pure SQL'
Dear Forum, I am building an application which will access DB to fetch some result set. The query involves retrieving data from multiple tables(nearly 10 tables). So I have created a DB adapter using 'execute pure sql' option. With this query works f
-
R9 290X GAMING 4G - high temperatures?
Hi! On IDLE its about 38*C (100.4*F) to 42*C (107.6*F), but while gaming it raises from about 86*C to 90*C (186.8 to 194 *F). My PC is very well vented using 8 fans (7x120mm and 1x140mm except CPU) temp. in room is about 28*C (82*F). Those temperatur
-
BSOD Windows 8.1 System Service Exception (memory_corruption)
Hello, I have a new computer with AMD processor and AMD Radeon R9 graphic card. Several times a day, usually when I play a game I receive BSOD on Win 8.1 (with latest updates + http://support.microsoft.com/kb/2818604 microcode Update for AMD procs+ l
-
Financial Reporting Studio - pdf error
I have one FRS report that will not produce a pdf when running as a view in Workspace or when running as a batched report. All my other reports are working fine. This reports does preview/print in the Reporting Studio and works in HTML on Workspace.