Select Product based on date
Hai,
Product Date
pd0 2012-08-11 18:45:55.780
Pd1 2012-08-11 18:55:17.020
pd2 2012-08-11 19:06:58.623
pd3 2012-08-18 12:00:01.193
pd4 2012-08-25 12:13:04.077
pd5 2012-08-25 17:28:30.347
pd6 2012-08-25 18:23:16.473
pd7 2012-09-18 18:29:58.360
I want select the product based on from date and to date.
For Example
I want the select the product date in between 2012-08-11 to 2012-08-18
Note:dont check the time.
I want the query for select product based on only date not depend upon time
>
Product Date
pd0 2012-08-11 18:45:55.780
Pd1 2012-08-11 18:55:17.020
pd2 2012-08-11 19:06:58.623
pd3 2012-08-18 12:00:01.193
pd4 2012-08-25 12:13:04.077
pd5 2012-08-25 17:28:30.347
pd6 2012-08-25 18:23:16.473
pd7 2012-09-18 18:29:58.360
I want select the product based on from date and to date.
For Example
I want the select the product date in between 2012-08-11 to 2012-08-18
>
Hopefully what you are calling 'Date', which is actually a timestamp value, is really being stored in a column of datatype TIMESTAMP and not being stored in a VARCHAR2.
NEVER store date or datetime values in a character datatype. And the word BETWEEN, when used as an operator means that BOTH endpoints will be included.
1. Data is stored in a TIMESTAMP column the way it should be stored
WITH Q AS (SELECT 'pd0' PRODUCT, TO_TIMESTAMP('2012-08-11 18:45:55.780', 'YYYY-MM-DD HH24:MI:SS.FF3') myBadDateFormat from dual
UNION ALL SELECT 'Pd1',TO_TIMESTAMP('2012-08-11 18:55:17.020', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
UNION ALL SELECT 'pd2',TO_TIMESTAMP('2012-08-11 19:06:58.623', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
UNION ALL SELECT 'pd3',TO_TIMESTAMP('2012-08-18 12:00:01.193', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
UNION ALL SELECT 'pd4',TO_TIMESTAMP('2012-08-25 12:13:04.077', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
UNION ALL SELECT 'pd5',TO_TIMESTAMP('2012-08-25 17:28:30.347', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
UNION ALL SELECT 'pd6',TO_TIMESTAMP('2012-08-25 18:23:16.473', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual
UNION ALL SELECT 'pd7',TO_TIMESTAMP('2012-09-18 18:29:58.360', 'YYYY-MM-DD HH24:MI:SS.FF3') from dual)
SELECT PRODUCT FROM Q
WHERE myBadDateFormat BETWEEN TO_TIMESTAMP('2012-08-11', 'YYYY-MM-DD')
AND TO_TIMESTAMP('2012-08-18', 'YYYY-MM-DD')
PRODUCT
pd0
Pd1
pd2If you don't want the second endpoint included you need to use > and <= operators instead of BETWEEN.
2. Data is stored in a VARCHAR2 column the way it should NEVER be stored
WITH Q AS (SELECT 'pd0' PRODUCT, '2012-08-11 18:45:55.780' myBadDateFormat from dual
UNION ALL SELECT 'Pd1','2012-08-11 18:55:17.020' from dual
UNION ALL SELECT 'pd2','2012-08-11 19:06:58.623' from dual
UNION ALL SELECT 'pd3','2012-08-18 12:00:01.193' from dual
UNION ALL SELECT 'pd4','2012-08-25 12:13:04.077' from dual
UNION ALL SELECT 'pd5','2012-08-25 17:28:30.347' from dual
UNION ALL SELECT 'pd6','2012-08-25 18:23:16.473' from dual
UNION ALL SELECT 'pd7','2012-09-18 18:29:58.360' from dual)
SELECT PRODUCT FROM Q
WHERE myBadDateFormat BETWEEN '2012-08-11' AND '2012-08-18'
PRODUCT
pd0
Pd1
pd2Neither of the solutions posted by others so far will work unless your data is stored in a TIMESTAMP column and even then Oracle will rewrite the filter to use TIMESTAMP values
SQL> select product from test_timestamp
2 WHERE myBadDateFormat < DATE '2012-08-18'
3 AND myBadDateFormat >= DATE '2012-08-11'
4 /
Execution Plan
Plan hash value: 3988574921
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 3 | 54 | 3 (0)| 00:00:01 |
|* 1 | TABLE ACCESS FULL| TEST_TIMESTAMP | 3 | 54 | 3 (0)| 00:00:01 |
Predicate Information (identified by operation id):
1 - filter("MYBADDATEFORMAT"<TIMESTAMP'2012-08-18 00:00:00' AND
"MYBADDATEFORMAT">=TIMESTAMP'2012-08-11 00:00:00')
Note
- dynamic sampling used for this statement
Similar Messages
-
Select Query Based on date condition
Hi ,
Is it Possible.
i want to run select query based on date condition.
Eg...
if the date between 01-jan-01 and 01-jan-05 then
select * from table1;
if the date between 02-jan-05 and 01-jan-08 then
select * from table2;
Becaz i have data in 2 diffrent tables , based on the date condition i wnt to run the select statement to diffrent tables.
i dont want plsql here Just SQL needed.
thanks,
-R
Edited by: infant_raj on May 5, 2009 11:48 PMHelo Kanish,
this is not the one i was asking..
wht i mean was .
i use bind variable to get date while running the select statement , once i get the date then i want to choose any one of the table to run select query.
EG..
select col1,col2 from table1 where date between only if 01-jan-01 and 01-jan-05;
select col1,col2 from table2 where date between only if 02-jan-05 and 01-jan-08;
Run any one of the two . not all
thanks,
_raj -
Selecting material based on date
Hello Experts,
I have requirement where i want to give material and date.
i have to select materia, condition record number based on date.
In database table field is stored like material , validity from date and validity to date.
Same material number is there but validity date and condtion record number is different.
Matno from date to date Condition record no
1234 01.01.2009 31.12.2009 23456
1234 01.01.2008 31.12.2008 12367
if user enter date 12.09.2009 it should fetch me first record. ( because date is between 01.01.2009 to 31.12.2009)
if user enter date 20.08.2008 it should fetch me first record. ( because date is between 01.01.2008 to 31.12.2008)
field for input date is fkdate.
So how i have to query in select statement to get this requirement.
Thanks in advance.
Best regards,
Saiselect * "or the fields you need
from abcd
into table itab
where matnr in s_matnr "if you have it in sel screen or remove it..
and dat_fr GE p_fkdat
and dat_to LE p_fkdat.
but if the dates are not keys...
better not use them in select...
delete the unnecessary items after the select using DELETE ITAB where... -
To select from database table based on date range
hi
i have a selection screen in which date range is being given
say eg 23/06/07 to 23/12/08
based on this date i want to select data from a ztable
eg i want to select a field amount from table
and three is a field date range on the table
for this particular field i want to select all records for amount field and factual field falling wiithing this date range and sum it
eg
based on date range as in selcetion screen
select amount( field1) factual ( field2) from ztable into it_ztable where date = ?....
please give me code for it and how to sum all values as i will get from the ztable into internal table the two values as fetched from the ztable
please suggest asap
regards
arorahi
i am using
sELECT field1 field2 FROM Ztable INto it_matu
where DATE GE sl_dat-low
AND DATE LE sl_dat-high.
i am getting data in internal table but
say i have twelve records now i want to sum it the both the columns into and use that sum final amount to display
let me know how to use sume in the intrranal tabl do i need to use control statement
how to use the sum for two columns and take into a serperate variable to display
regards
aRora -
Select records based on monthly anniversary date
Hi,
I have a table with a date_added field and I want to select records based on the monthly anniversary date of this field.
eg. ID, Date_added
1, 10-DEC-2012
2, 11-NOV-2012
3, 10-MAR-2012
4, 28-FEB-2012
5, 30-DEC-2012
So For the 10th of Jan 2013, I would want to return records 1 and 3 only
I started looking at the extract function, but this soon falls down for records at the end of the month. For example, on the 28th Feb, I would also want to include records where the date_added day is the 29th, 30th or 31st. So, in the table above I would want to return records 4 and 5, but extract would only return 4.
Is there a simple function to do this month anniversary query - am I missing something very obvious? Or, do I need to write a query to explicitly cope with dates at the end of the month? So far I haven't found a sensible simple solution!
I'm using 11g
thanksI didn't look into leap year, but this should give you a starting point:
select *
from t
where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
when to_date(:target_date,'mmddyyyy')
then case
when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
then 1
end
else case
when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
then 1
end
end
/For example, target date is 1/10/2013:
SQL> variable target_date varchar2(8)
SQL> exec :target_date := '01102013';
PL/SQL procedure successfully completed.
SQL> with t as (
2 select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
3 select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
4 select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
5 select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
6 select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
7 )
8 select *
9 from t
10 where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
11 when to_date(:target_date,'mmddyyyy')
12 then case
13 when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
14 then 1
15 end
16 else case
17 when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
18 then 1
19 end
20 end
21 /
ID DATE_ADDE
1 10-DEC-12
3 10-MAR-12
SQL> And target date is 2/28/2013:
SQL> exec :target_date := '02282013';
PL/SQL procedure successfully completed.
SQL> with t as (
2 select 1 id,to_date('10-DEC-2012','dd-mon-yyyy') date_added from dual union all
3 select 2,to_date('11-NOV-2012','dd-mon-yyyy') from dual union all
4 select 3,to_date('10-MAR-2012','dd-mon-yyyy') from dual union all
5 select 4,to_date('28-FEB-2012','dd-mon-yyyy') from dual union all
6 select 5,to_date('30-DEC-2012','dd-mon-yyyy') from dual
7 )
8 select *
9 from t
10 where 1 = case last_day(to_date(:target_date,'mmddyyyy'))
11 when to_date(:target_date,'mmddyyyy')
12 then case
13 when to_char(date_added,'dd') >= to_char(to_date(:target_date,'mmddyyyy'),'dd')
14 then 1
15 end
16 else case
17 when to_char(date_added,'dd') = to_char(to_date(:target_date,'mmddyyyy'),'dd')
18 then 1
19 end
20 end
21 /
ID DATE_ADDE
4 28-FEB-12
5 30-DEC-12
SQL> SY. -
Dynamic Select List based on TextField data
Hi,
I like to dynamically display the select list based on the value in the textfield, the data in the textfield is of character type.
ThanksHello,
Well as you now know HTML based select lists don't work like that, that widget is called a combo box and there will be built in combo boxes in APEX 3.0, it's a fairly complex dhtml widget.
What you might want to do is provide a text item next to your select box and an Add New Value Option in your select list.
Carl -
Production version selection according to explosion date
Hello
In customizing for MRP (OPPQ), parameters for BOM explosion / routing selection is 3 (BOM explosion number/order start date).
In MRP4 view of material master, selection method for BOM explosion is 2 (Selection by production version).
No MRP group is assigned.
I have 3 production versions : one for 2014, one for 2015, one for 2016 :
I use a BOM explosion number with fixed key date 1st December 2015 :
When manually creating a planned order with dates in 2014 and explosion number EXP_1215 (fixed key date 1st December 2015), Production Version PV1 is selected (valid for 2014), but no routing is selected because explosion date is BOM explosion number, and in PV1 there is no valid routing in 2015 :
Is it possible to select production version according to explosion date, and not order dates ?Hi Tristan
The following modification note can be used to influence the selection of production version on planned orders:
351773 - Selection of production versions for planned order
Alternatively, you can create your own logic using BAdI MD_MODIFY_PRODVERS.
BR
Caetano -
Updating product revenue close date based off opportunity close date
We do not use the product revenue close date, only the opportunity close date. We need to get the fiscal month of the opportunity close date but we have several reports the need to use the opportunity product history area and that does not contain the fiscal month for the opportunity. If we did a combined report, we cannot offer the user any prompts.
Does anyone know how to get the opportunity close date fiscal month from the opportunity products area? Is there a way to update the product revenue close date when the opportunity close date it updated?
ThanksHi David,
In the universe you describe you have the opportunity 'Close Date'. Use a 'case-when' expression to create the 'Fiscal Month' you need.
Other than that you can use the JoinFieldValue function in the application to retrieve the opty close date, but that will require you to update product revenue for it to trigger which probably won't work for you.
Good luck. -
How to use multiple selection parameters in the data model
Hi, after have looked all the previous threads about how to use multiple selection parameters , I still have a problem;
I'm using Oracle BI Publisher 10.1.3.3.2 and I'm tried to define more than one multiple selection parameters inside the data template;
Inside a simple SQL queries they work perfectly....but inside the data template I have errors.
My data template is the following (it's very simple...I am just testing how the parameters work):
<dataTemplate name="Test" defaultPackage="bip_departments_2_parameters">
<parameters>
<parameter name="p_dep_2_param" include_in_output="false" datatype="character"/>
<parameter name="p_loc_1_param" include_in_output="false" datatype="character"/>
</parameters>
<dataTrigger name="beforeReport" source="bip_departments_2_parameters.beforeReportTrigger"/>
<dataQuery>
<sqlStatement name="Q2">
<![CDATA[
select deptno, dname,loc
from dept
&p_where_clause
]]>
</sqlStatement>
</dataQuery>
<dataStructure>
<group name="G_DEPT" source="Q2">
<element name="deptno" value="deptno"/>
<element name="dname" value="dname"/>
<element name="loc" value="loc"/>
</group>
</dataStructure>
</dataTemplate>
The 2 parameters are based on these LOV:
1) select distinct dname from dept (p_dep_2_param)
2) select distinct loc from dept (p_loc_1_param)
and both of them have checked the "Multiple selection" and "Can select all" boxes
The package I created, in order to use the lexical refence is:
CREATE OR REPLACE package SCOTT.bip_departments_2_parameters
as
p_dep_2_param varchar2(14);
p_loc_1_param varchar2(20);
p_where_clause varchar2(100);
function beforereporttrigger
return boolean;
end bip_departments_2_parameters;
CREATE OR REPLACE package body SCOTT.bip_departments_2_parameters
as
function beforereporttrigger
return boolean
is
l_return boolean := true;
begin
if (p_dep_2_param is not null) --and (p_loc_1_param is not null)
then
p_where_clause := 'where (dname in (' || replace (p_dep_1_param, '''') || ') and loc in (' || replace (p_loc_1_param, '''') || '))';
else
p_where_clause := 'where 1=1';
end if;
return (l_return);
end beforereporttrigger;
end bip_departments_2_parameters;
As you see, I tried to have only one p_where_clause (with more than one parameter inside)....but it doesn't work...
Using only the first parameter (based on deptno (which is number), the p_where_clause is: p_where_clause := 'where (deptno in (' || replace (p_dep_2_param, '''') || '))';
it works perfectly....
Now I don't know if the problem is the datatype, but I noticed that with a single parameter (deptno is number), the lexical refence (inside the data template) works.....with a varchar parameter it doesn't work....
So my questions are these:
1) how can I define the p_where_clause (inside the package) with a single varchar parameter (for example, the department location name)
2) how can I define the p_where_clause using more than one parameter (for example, the department location name and the department name) not number.
Thanks in advance for any suggestion
AlexAlex,
the missing thing in your example is the fact, that if only one value is selected, the parameter has exact this value like BOSTON. If you choose more than one value, the parameter includes the *'*, so that it looks like *'BOSTON','NEW YORK'*. So you need to check in the package, if there's a *,* in the parameter or not. If yes there's more than one value, if not it's only one value or it's null.
So change your package to (you need to expand your variables)
create or replace package bip_departments_2_parameters
as
p_dep_2_param varchar2(1000);
p_loc_1_param varchar2(1000);
p_where_clause varchar2(1000);
function beforereporttrigger
return boolean;
end bip_departments_2_parameters;
create or replace package body bip_departments_2_parameters
as
function beforereporttrigger
return boolean
is
l_return boolean := true;
begin
p_where_clause := ' ';
if p_dep_2_param is not null then
if instr(p_dep_2_param,',')>0 then
p_where_clause := 'WHERE DNAME in ('||p_dep_2_param||')';
else
p_where_clause := 'WHERE DNAME = '''||p_dep_2_param||'''';
end if;
if p_loc_1_param is not null then
if instr(p_loc_1_param,',')>0 then
p_where_clause := p_where_clause || ' AND LOC IN ('||p_loc_1_param||')';
else
p_where_clause := p_where_clause || ' AND LOC = '''||p_loc_1_param||'''';
end if;
end if;
else
if p_loc_1_param is not null then
if instr(p_loc_1_param,',')>0 then
p_where_clause := p_where_clause || 'WHERE LOC in ('||p_loc_1_param||')';
else
p_where_clause := p_where_clause || 'WHERE LOC = '''||p_loc_1_param||'''';
end if;
end if;
end if;
return (l_return);
end beforereporttrigger;
end bip_departments_2_parameters;
I've written a similar example at http://www.oracle.com/global/de/community/bip/tipps/Dynamische_Queries/index.html ... but it's in german.
Regards
Rainer -
How to display data from a recordset based on data from another recordset
How to display data from a recordset based on data from
another recordset.
What I would like to do is as follows:
I have a fantasy hockey league website. For each team I have
a team page (clubhouse) which is generated using PHP/MySQL. The one
area I would like to clean up is the displaying of the divisional
standings on the right side. As of right now, I use a URL variable
(division = id2) to grab the needed data, which works ok. What I
want to do is clean up the url abit.
So far the url is
clubhouse.php?team=Wings&id=DET&id2=Pacific, in the end all
I want is clubhouse.php?team=Wings.
I have a separate table, that has the teams entire
information (full team name, short team, abbreviation, conference,
division, etc. so I was thinking if I could somehow do this:
Recordset Team Info is filtered using URL variable team
(short team). Based on what team equals, it would then insert this
variable into the Divisional Standings recordset.
So example: If I type in clubhouse.php?team=Wings, the Team
Info recordset would bring up the Pacific division. Then 'Pacific'
would be inserted into the Divisional Standings recordset to
display the Pacific Division Standings.
Basically I want this
SELECT *
FROM standings
WHERE division = <teaminfo.division>
ORDER BY pts DESC
Could someone help me, thank you.Assuming two tables- teamtable and standings:
teamtable - which has entire info about the team and has a
field called
"div" which has the division name say "pacific" and you want
to use this
name to get corresponding details from the other table.
standings - which has a field called "division" which you
want to use to
give the standings
SELECT * FROM standings AS st, teamtable AS t
WHERE st.division = t.div
ORDER BY pts DESC
Instead of * you could be specific on what fields you want to
select ..
something like
SELECT st.id AS id, st.position AS position, st.teamname AS
team
You cannot lose until you give up !!!
"Leburn98" <[email protected]> wrote in
message
news:[email protected]...
> How to display data from a recordset based on data from
another recordset.
>
> What I would like to do is as follows:
>
> I have a fantasy hockey league website. For each team I
have a team page
> (clubhouse) which is generated using PHP/MySQL. The one
area I would like
> to
> clean up is the displaying of the divisional standings
on the right side.
> As of
> right now, I use a URL variable (division = id2) to grab
the needed data,
> which
> works ok. What I want to do is clean up the url abit.
>
> So far the url is
clubhouse.php?team=Wings&id=DET&id2=Pacific, in the end
> all
> I want is clubhouse.php?team=Wings.
>
> I have a separate table, that has the teams entire
information (full team
> name, short team, abbreviation, conference, division,
etc. so I was
> thinking if
> I could somehow do this:
>
> Recordset Team Info is filtered using URL variable team
(short team).
> Based on
> what team equals, it would then insert this variable
into the Divisional
> Standings recordset.
>
> So example: If I type in clubhouse.php?team=Wings, the
Team Info recordset
> would bring up the Pacific division. Then 'Pacific'
would be inserted into
> the
> Divisional Standings recordset to display the Pacific
Division Standings.
>
> Basically I want this
>
> SELECT *
> FROM standings
> WHERE division = <teaminfo.division>
> ORDER BY pts DESC
>
> Could someone help me, thank you.
> -
Problem writing a sql query for a select list based on a static LOV
Hi,
I have the following table...
VALIDATIONS
ID Number (PK)
APP_ID Number
REQUESTED Date
APPROVED Date
VALID_TIL Date
DEPT_ID Number (FK)
I have a search form with the following field item variables...
P11_DEPT_ID (select list based on dynamic LOV from depts table)
P11_VALID (select list based on static Yes/No LOV)
A report on the columns of the Validations table is shown based on the values in the search form. So far, my sql query for the report is...
SELECT v.APP_ID,
v.REQUESTED,
v.APPROVED,
v.VALID_TIL,
d.DEPT
FROM DEPTS d, VALIDATIONS v
WHERE d.DEPT_ID = v.DEPT_ID(+)
AND (d.DEPT_ID = :P11_DEPT_ID OR :P11_DEPT_ID = -1)
This query works so far. My problem is that I don't know how to do a search based on the P11_VALID item - if 'yes' is selected, then the VALID_TIL date is still valid. If 'no' is selected then the VALID_TIL date has passed.
Can anyone help me to extend my query to include this situation?
Thanks.Hello !
Let's have a look at my example:create table test
id number
,valid_til date
insert into test values( 1, sysdate-3 );
insert into test values( 2, sysdate-2 );
insert into test values( 3, sysdate-1 );
insert into test values( 4, sysdate );
insert into test values( 5, sysdate+1 );
insert into test values( 6, sysdate+2 );
commit;
select * from test;
def til=yes
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
def til=no
select *
from test
where decode(sign(trunc(valid_til)-trunc(sysdate)),1,1,0,1,-1)
=decode('&til','yes',1,-1);
drop table test; It's working fine, I've tested it.
The above changes to my first idea I did because of time portion of the DATE datatype in Oracle and therefore the wrong result for today.
For understandings:
1.) TRUNC removes the time part of DATE
2.) The difference of to date-values is the number of days between.
3.) SIGN is the mathematical function and gives -1,0 or +1 according to an negative, zero or positiv argument.
4.) DECODE is like an IF.
Inspect your LOV for the returning values. According to my example they shoul be 'yes' and 'no'. If your values are different, you may have to modify the DECODE.
Good luck,
Heinz -
SELECT QUERY BASED ON SECONDARY INDEX
Hi all,
CAN ANYONE TELL ME HOW TO WRITE SELECT QUERY BASED ON SECONDARY INDEX.
IN WHAT WAY DOES IT IMPROVE PERFORMANCE.
i KNOW WHEN CREATING SECONDARY INDEX I NEED TO GIVE AN INDEX NO -iT SHOULD BE ANY NUMBER RIGHT?
I HAVE TO LIST ALL PRIMARY KEYS FIRST AND THEN THE FIELD FOR WHICH I AM CREATING SECONDARY INDEX RIGHT?
LETS SAY I HAVE 2 PRIMARY KEYS AND I WANT TO CREATE SEONDARY INDEX FOR 2 FIELDS THEN
I NEED TO CREATE A SEPERTE SECONDARY INDEX FOR EACH ONE OF THOSE FIELDS OR ONE SHOULD BE ENOUGH
pLS LET ME KNOW IF IAM WRONGHI,
If you cannot use the primary index to determine the result set because, for example, none of the primary index fields occur in the WHERE or HAVINGclauses, the system searches through the entire table (full table scan). For this case, you can create secondary indexes, which can restrict the number of table entries searched to form the result set.
You create secondary indexes using the ABAP Dictionary. There you can create its columns and define it as UNIQUE. However, you should not create secondary indexes to cover all possible combinations of fields.
Only create one if you select data by fields that are not contained in another index, and the performance is very poor. Furthermore, you should only create secondary indexes for database tables from which you mainly read, since indexes have to be updated each time the database table is changed. <b>As a rule, secondary indexes should not contain more than four fields</b>, <b>and you should not have more than five indexes for a single database table</b>.
<b>What to Keep in Mind for Secondary Indexes:</b>
http://help.sap.com/saphelp_nw04s/helpdata/en/cf/21eb2d446011d189700000e8322d00/content.htm
http://www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm
Regards
Sudheer -
Hello,
We need some help with an SSAS MDX query based on date logic. One of the problems is that I don't have access to the Cube but have been given a query example with the logic needed for the calculation. Here's the scenario;
The ETL process will run on the first Tuesday after the 15<sup>th</sup> of a given month. The Analysis Cube data queried should include the current year up to the end of the previous month. For example, on May 19<sup>th</sup>
(the first Tuesday on or after the 15th) the query should include data from January 1<sup>st</sup> through April 30<sup>th</sup>.
The 15<sup>th</sup> of the month is not part of the query, it is a factor in when the query is run. The query will always be in terms of complete months.
SELECT
NON EMPTY { [Measures].[Revenue Amount],
[Measures].[Utilization],
[Measures].[AVG Revenue Rate],
[Measures].[Actual Hours] }
ON
COLUMNS,
NON EMPTY { ([dimConsultant].[User Id TT].[User Id TT].ALLMEMBERS * [dimConsultant].[Full Name].[Full Name].ALLMEMBERS * [dimConsultant].[Employee
Type].[Employee Type].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION,
MEMBER_UNIQUE_NAME
ON
ROWS
FROM
( SELECT
( { [dimDate].[Week Date].[1/4/2015], [dimDate].[Week Date].[1/11/2015], [dimDate].[Week Date].[1/18/2015], [dimDate].[Week Date].[1/25/2015], [dimDate].[Week Date].[2/1/2015] } )
ON
COLUMNS
FROM
( SELECT
( { [dimIsBillable].[Is Billable].&[True] } )
ON
COLUMNS
FROM
[SSASRBA]
WHERE
( [dimIsBillable].[Is Billable].&[True], [dimDate].[Week Date].CurrentMember ) CELL PROPERTIES VALUE,
BACK_COLOR,
FORE_COLOR,
FORMATTED_VALUE,
FORMAT_STRING,
FONT_NAME,
FONT_SIZE,
FONT_FLAGSHi Hans,
Thank you for your question.
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Regards,
Simon Hou
TechNet Community Support -
Newbie: Trying to write PL/SQL that is dynamic based on data
Hi everyone,
I was wondering how I would go about writing a report that outer joins based on data from the main table? Here is what I wanna do in pseudo-sql:
SELECT
b.po_number,
a.ht_code,
b.figure_no,
b.order_number,
a.supplier_no,
b.cert_date,
b.plant
FROM header b, part_spec a
where ...
begin:
project = '' /* initialize project */
/* The table to get the project value for the report is named ORDER01 or ORDER02 or ... */
/* It is the word ORDER concatenated with the plant value above. */
select project from 'ORDER' || :PLANT;
END;
How would I do this with APEX 2.0?
I've successfully used APEX to generate SQL Query reports (REGION) but never PL/SQL.
Your help is appreciated,
FerrisWheel
Edited by: FerrisWheel on Dec 15, 2009 10:13 AM
Edited by: FerrisWheel on Dec 15, 2009 10:14 AM
Edited by: FerrisWheel on Dec 15, 2009 10:14 AMOK, Thanks for the quick feedback. Here is a quick generic SQL I wrote up to show my goal using your suggestion. Notice the ERP_ORDERHDR and plant values in each of the SQLs below.
SELECT b.cust_po_no,
a.ht_code,
b.item_no,
b.ERP_ORDER_NO,
a.supplier_code,
b.cert_date,
c.prj
FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR011 c
WHERE plant = 1
AND a.cert_no = b.cert_no
AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
AND c.orno (+) = b.ERP_ORDER_NO
AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
UNION ALL
SELECT b.cust_po_no,
a.ht_code,
b.item_no,
b.ERP_ORDER_NO,
a.supplier_code,
b.cert_date,
c.prj
FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR012 c
WHERE plant = 2
AND a.cert_no = b.cert_no
AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
AND c.orno (+) = b.ERP_ORDER_NO
AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
UNION ALL
SELECT b.cust_po_no,
a.ht_code,
b.item_no,
b.ERP_ORDER_NO,
a.supplier_code,
b.cert_date,
c.prj
FROM CERT_HDR b, PART_DETL a, ERP_ORDERHDR014 c
WHERE (plant = 4 or plant = 5 or plant = 8)
AND a.cert_no = b.cert_no
AND a.cert_no like '%%%' || UPPER(:p1_cert_no) || '%%%'
AND b.cust_po_no like '%%%' || UPPER(:p1_cust_po_no) || '%%%'
AND a.ht_code like '%%%' || UPPER(:p1_ht_code) || '%%%'
AND b.item_no like '%%%' || UPPER(:p1_item_no) || '%%%'
AND b.ERP_ORDER_NO like '%%%' || UPPER(:p1_sales_order) || '%%%'
AND (b.cert_date BETWEEN :P1_DATE_FROM AND :P1_DATE_TO)
AND c.orno (+) = b.ERP_ORDER_NO
AND c.prj like '%%%' || UPPER(:p1_project) || '%%%'
and this would go on for up to 4 more unions. Is there a way to use PL/SQL to make it more clean? Another issue I have with the above is that the c.orno field that I try to outer join is not numeric whereas the b.ERP_ORDER_NO is numeric. I can to_char(c.orno) but how do I do that and still have an outer join? If I can use PL/SQL, I hope to be able to better control the output and eliminate the unions.
I hope this is enough information.
Thanks,
FerrisWheel -
List item - Population - Based on Data setup
Dear All,
I need to populate the list item based on data defined at the database level.
Tables Used:
Table 1 : JBCAI_JOB_COM_ADD_INFO
Column Name Pk Null? Data Type Default
JBEDC_UID 1 N NUMBER (22)
JBCAI_ADD_INFO_CODE 2 N VARCHAR2 (2 Char)
JBCAI_INFO_CODE_SEQUENCE 3 N NUMBER (3,1) 1
JBCAI_ADD_INFO_TEXT Y VARCHAR2 (35 Char)
SHIPCOMP_CODE N VARCHAR2 (4 Char)
Table 2 :CODES
CODE_TYPE CODE_VALUE DESCRIPTION NEXT_VALUE CODE_FLAG
MCAR 01 Customs References 01 NULL N
MCAR 02 Customs References 02 NULL N
MCAR 03 Value of Commodities NULL N
MCAR 04 Currency of commodities NULL N
MCAR 05 Purchase Order Number NULL N
MCAR 06 Other NULL N
MCAR 07 Consignee Name NULL N
MCAR 08 VIN NULL N
FORMS Section
=========
JBCAI_ADD_INFO_CODE are the list items which needs to be populated; JBCAI_ADD_INFO_TEXT(free text) which user can enter any descriptions.
References - Label of the Block
JBCAI_ADD_INFO_CODE JBCAI_ADD_INFO_TEXT
Customs References 01 - Free Text()
Customs References 02 - Free Text()
Value of Commodities - Free Text()
Currency of commodities - Free Text()
Purchase Order Number - Free Text()
Other - Free Text()
Consignee Name - Free Text()
VIN - Free Text()
VIN - Free Text()
Business Rules:
If JBCAI_ADD_INFO_CODE has the flag as 'N' in CODES table then user can select only one time from the list item.
If JBCAI_ADD_INFO_CODE has the flag as 'Y' in CODES table then user can do multi-selection from the list item e.g; VIN
How the records are fetched:
Value for the list item are been populated from CODES table ; which am doing through the below query.
In WHEN-NEW-FORM-INSTANCE am using the below code:
PROCEDURE p_fetch_code_value
IS
l_query VARCHAR2(200) ;
l_rg_name VARCHAR2(40) := 'CODES';
l_errcode NUMBER;
l_rg RECORDGROUP;
BEGIN
l_query := 'SELECT adcod.description description,adcod.code_flag code_flag FROM codes adcod WHERE adcod.code_type = ''MCAR'' AND adcod.code_value IN (''01''''02'',''03'',''04'',''05'',''06'',''07'',''08'') ORDER BY code_value';
l_rg := FIND_GROUP( l_rg_name );
IF ID_NULL(l_rg) THEN
l_rg := CREATE_GROUP_FROM_QUERY(l_rg_name, l_query);
END IF;
l_errcode := POPULATE_GROUP( l_rg );
POPULATE_LIST('BLK_CONTROL.JBCAI_ADD_INFO_CODE',l_rg);
EXCEPTION
Handled WHEN OTHERS exception
END p_fetch_code_value;
Saving of Record:
List value selection are saved to JBCAI_JOB_COM_ADD_INFO.JBCAI_ADD_INFO_CODE column.
Free Text is saved to JBCAI_JOB_COM_ADD_INFO.JBCAI_ADD_INFO_TEXT column.
Doubt:
When i select the first list item value i.e Customs References 01 and then enter some description i.e free text and moved to the next list item; the value Custom reference 01 should not be visible wheras the other values should have to be visible e.g; Customs Reference 02,Value of Commodities.....
Please help and let me know how can i acccomplish this task?
Thanks....
Regards,
Sunil.GHi Sarah,
Thanks for your reply.
There is no issue in the population of the list item; it is working fine with the query which i have pasted.
My doubt is:
There are few places where i have set the code_flag as 'Y' / 'N'.
For the first time when user selects the list item; all the values should be shown.....
If user has selected the first list item i.e Customs Reference 01 for which the code_flag is 'N' from a multi-record block; then when he moves to the further lines the previous selection for which the flag is set as 'N' should not be shown(if user has already selected once) e.g; 'Customs Reference 01' should not be shown again if user has made the selection before.
Plz revert incase more explanations required.
Thanks...
Regards,
Sunil.G
Edited by: Sunil G on Nov 29, 2009 12:16 AM
Maybe you are looking for
-
I want to connect my iPhone to my macbook to backup all my photos but it just vibrates constantly and flashes the trust computer question over and over. Any help would be great.
-
IPod says "FireWire not supported" when connecting with a USB cable
Hello all. First post ever. I am trying to connect my Nano (1 gig) to my Windows Vista. (This use to work flawlessly) Whenever I try to connect my iPod to my computer via a USB cable, it says "FireWire connections are not supported please use USB cab
-
Missing files in Adobe application support CS5.1
Why do I get this error message when I start CS5? One or more files in the Adobe Application Support folder, necessary for running Photoshop, are missing. Please run the Photoshop installer and re-install Photoshop. New install on new iMac and worke
-
IMessaging with iOS 7.0.2
My iMessaging is not wanting to send as quickly to fellow iphone and ipad users as it did before the 7.0.1 and 7.0.2 update. I have turned off my iMessage to allow it to reboot along with turning off my phone as well. What are some steps to get thi
-
New Installation / EM doesn't start.
Hi All, I am installing a 11gr2 database on a RHEL... These are the OS and DB versions: Host> [oracle@rhel98 /]$ uname -a Linux rhel98 2.6.32-100.34.1.el6uek.x86_64 #1 SMP Wed May 25 17:46:45 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux DB> SQL> select *