Trunc function with date
when i use in my proceadure where trunc(timesent_acct) between '30-AUG-2006' and '27-SEP-2006' it returns 410 rows
but
when i use where timesent_acct between '30-AUG-2006' and '27-SEP-2006' it returns me 400 rows
what actually happened out there my data stored in timestamp like this '9/27/2006 10:24:18 AM'
what trunc actually do with dates
thanks
Hello,
Trunc() without parameter retire the hour part of a date.
SQL> alter session set nls_date_format='DD/MM/YYYY HH24:MI:SS'
2 /
Session modifiée.
SQL> select sysdate, trunc(sysdate) from dual
2 /
SYSDATE TRUNC(SYSDATE)
07/11/2006 14:51:04 07/11/2006 00:00:00
SQL> Francois
Similar Messages
-
How to use TRUNC function with dates in Expression Builder in OBIEE.
Hi There,
How to use TRUNC function with dates in Expression Builder in OBIEE.
TRUNC (SYSDATE, 'MM') returns '07/01/2010' where sysdate is '07/15/2010' in SQL. I need to use the same thing in expression builder in BMM layer logical column.
Thanks in advanceuse this instead:
TIMESTAMPADD(SQL_TSI_DAY, ( DAYOFMONTH(CURRENT_DATE) * -1) + 1, CURRENT_DATE) -
How to use aggregate function with Date
Hi All,
I have a group of date from that is it possible to Max and Min of date.
I have tried like this but its errored out <?MIN (current-group()/CREATION_DATE)?>.
I have also tried like this but it doesnt works
<?xdoxslt:minimum(CREATION_DATE)?>
Is it possible to use aggregate function with date values.
Thanks & Regards
SrikkanthHi KAVI PRIYA,
if date is not in cannonical format, how can we change it in BI publisher, then how to calcualte minimum and as well as maximum.
please advise me,
Thanks,
Sri -
Another thread from today made me think of the basics of TRUNC function used for DATEs. I am confused about what it acutally does.
This is what Oracle Documenations says about TRUNC function without format (like 'DD-MON-YY')
"If you omit fmt, then date is truncated to the nearest day" (Oracle 10Gr2 SQL reference, B14200-02)
SQL> alter session set nls_date_format = 'DD-MON-YYYY HH24:MI:SS';
Session altered.
Query 1.
SQL> SELECT SYSDATE FROM DUAL;
SYSDATE
06-DEC-2007 14:22:01
Query 2.
SQL> SELECT TRUNC(SYSDATE) FROM DUAL;
TRUNC(SYSDATE)
06-DEC-2007 00:00:00I have three questions
1)Since it 2:22 pm , shouldn't the result of TRUNC(SYSDATE) ie Query 2. be 7-Dec-2007 ?
2) What difference does TRUNC function make in the code apart from setting the time to 00:00:00?
3) Is it safer to add TRUNC for DATEs in the code?
SQL> select sysdate-1 from dual;
SYSDATE-1
05-DEC-2007 14:27:51
SQL> select trunc(sysdate) - 1 from dual;
TRUNC(SYSDATE)-1
05-DEC-2007 00:00:00Added third question
Message was edited by:
user609308it's not a function that rounds up date's it purely truncates to the granularity that you want.
So TRUNC(sysdate) still returns a date datatype (which still contains a date and time portion) but the time portion is truncated i.e. cleared down to it's lowest limit.
Likewise if you TRUNC(sysdate,'YYYY') then it will truncate to the year and take months, days, hours, mins and secs down to their lowest limit hence giving you 1st January of that year with 00:00:00 as the time.
It's very simple really. -
How to execute a function with date parameter as an input?
HI
I have a function named fun1(v_fun in date), with date as an input parameter and it returns a number. I have created the function successfully. But i couldnt execute this function in sqlplus. How to pass the dates? Can any one help me in this regard.Hi,
V11081985 wrote:
HI
I have a function named fun1(v_fun in date), with date as an input parameter and it returns a number. I have created the function successfully. But i couldnt execute this function in sqlplus. It's hard for me to say what you're doing wrong when I don't know what you're doing. Post a complete test script that people can run to re-create the problem and test their ideas. Include a function definition, CREATE TABLE and INSERT statements for any of your own tables (if necessary), and the results you want to get from that data, as well as your query.
How to pass the dates? Can any one help me in this regard.You can call the function like this:
SELECT fun1 (hiredate) AS fun1_results
FROM scott.emp
; -
Query with scalar valued function with date filter
Hello experts
i have a problem by filtering my results with the date
i have written the following code
SELECT
T1.ItemCode
, T1.Dscription
,DBO.F_CALCULATION_QUANTITY(T1.ITEMCODE)
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OSLP T3 ON T0.SLPCODE=T3.SLPCODE
WHERE
(T0.DOCDATE BETWEEN '2010-11-01' AND '2010-11-30')
and (t2.cardcode ='80022')
and (T0.CANCELED= 'N')
group by t1.itemcode, T1.Dscription, t2.suppcatnum
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION [dbo].[F_CALCULATION_QUANTITY]
(@ITEMCODE AS NVARCHAR(10))
RETURNS
NUMERIC(19,2)
AS
BEGIN
DECLARE
@RESULT1 AS NUMERIC(19,2),
@RESULT2 AS NUMERIC(19,2),
@RESULT AS NUMERIC(19,2)
SELECT @RESULT1=SUM(A.QUANTITY)
FROM INV1 A
JOIN OINV B ON A.DOCENTRY=B.DOCENTRY
WHERE A.ITEMCODE=@ITEMCODE
AND B.DOCDATE BETWEEN '2010-11-01 00:00:00.000' AND '2010-11-30 00:00:00.000'
SELECT @RESULT2=SUM(A.QUANTITY)
FROM RIN1 A
JOIN ORIN B ON A.DOCENTRY=B.DOCENTRY
WHERE A.ITEMCODE=@ITEMCODE
AND B.DOCDATE BETWEEN '2010-11-01 00:00:00.000' AND '2010-11-30 00:00:00.000'
SELECT @RESULT=ISNULL(@RESULT1,0)-ISNULL(@RESULT2,0)
--SELECT @RESULT=@RESULT1- @RESULT2
RETURN @RESULT
END
the problem i have is that i want to filter my results accoring to the date provided by the user. i want it to be dynamic query.
by now, what i do is to edit the docdate in the function in order to get the desired results. this is not what i want.
could you please help me on this way in order to let the user to input the date?if i add the [%] in the query, it does not bring me the right resultsi have already edited the function to
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER FUNCTION [dbo].[F_CALCULATION_QUANTITY]
(@ITEMCODE AS NVARCHAR(10),
@STARTDATE1 as DATETIME,
@ENDDATE1 AS DATETIME
RETURNS
NUMERIC(19,2)
AS
BEGIN
DECLARE
@RESULT1 AS NUMERIC(19,2),
@RESULT2 AS NUMERIC(19,2),
@RESULT AS NUMERIC(19,2)
SELECT @RESULT1=SUM(A.QUANTITY)
FROM INV1 A
JOIN OINV B ON A.DOCENTRY=B.DOCENTRY
WHERE A.ITEMCODE=@ITEMCODE
AND B.DOCDATE BETWEEN (@STARTDATE1) AND (@ENDDATE1)
SELECT @RESULT2=SUM(A.QUANTITY)
FROM RIN1 A
JOIN ORIN B ON A.DOCENTRY=B.DOCENTRY
WHERE A.ITEMCODE=@ITEMCODE
AND B.DOCDATE BETWEEN (@STARTDATE1) AND (@ENDDATE1)
SELECT @RESULT=ISNULL(@RESULT1,0)-ISNULL(@RESULT2,0)
RETURN @RESULT
END
could you please how to edit the query as well?
i have added the following code and it comes up with the right itemcode but the quantity does not work
DECLARE
@ITEMCODE AS NVARCHAR(10),
@STARTDATE1 as DATETIME,
@ENDDATE1 AS DATETIME
SET @STARTDATE1=(SELECT MAX(T0.DOCDATE) FROM oinv t0 WHERE T0.DOCDATE='2010-11-01')
set @ENDDATE1=(SELECT MAX(T0.DOCDATE) FROM oinv t0 WHERE T0.DOCDATE='2010-11-30')
SELECT
T1.ItemCode
, T1.Dscription
,DBO.F_CALCULATION_QUANTITY(@ITEMCODE,@STARTDATE1,@ENDDATE1)
FROM OINV T0
INNER JOIN INV1 T1 ON T0.DocEntry = T1.DocEntry
INNER JOIN OITM T2 ON T1.ItemCode = T2.ItemCode
INNER JOIN OSLP T3 ON T0.SLPCODE=T3.SLPCODE
WHERE
(T0.DOCDATE BETWEEN @STARTDATE1 AND @ENDDATE1)
and (t2.cardcode ='80022')
and (T0.CANCELED= 'N')
group by t1.itemcode, T1.Dscription, t2.suppcatnum
the result is this
70200 alert1 0.00
70210 alert2 0.00
70220 alert3 0.00
70230 alert4 0.00
as you can see the quantity is 0 and it shouldnt be
Edited by: Fasolis Vasilios on Oct 31, 2011 10:49 AM -
How to use MAX() function with date field
Hi Frzz,
I have created a Graphical calculation view in which i have multiple records for each employee with different dates. But my requirement is to take the records which have maximum date.
I have converted the date into Integer and applied the MAX() function. But still am getting multiple records.
Is there is any other way we can achieve this requirement in Graphical Calculation view?? Your suggestion will really help me.
Thank you.
Krishna.Hmm... what have you tried out so far?
Look, I took the effort and created a little example, just for you
Assume we have a table that contains the logon dates of users.
Every line contains the logon date and some info on the user.
Very much like a not-normalized log file could look like.
Now, the output we want is: one line per user with the most current logon time.
Not too difficult:
1. Have a aggregation node that gives you the distinct user details - one line for every user:
2. Have another aggregation node that gives you the last (MAX) logon date per user:
Finally you do a 1:1 join on the USER_ID and map the result to the output.
Easy as pie
- Lars -
Query regarding Min function with Date
Dear All,
I have written query as follows but it is giving me error message.
Selection CityCode, CityName, Min(Date)
from Entry
I want to write a query which should generate minimum date of transactions of city. There are about 50 cities in the Entry table and against each city there are thousands of records, I want to display only the oldest date against each city with its code. In the out put there should 50 rows as there are 50 cities and oldest (min) date. Can any one please help on this SQL.
ThanksDo you want just min date in the table or need grouping by citycode and city name also?
If just min date of the table is needed, use row_number analytic function to get the min date in the table. -
Hi,
how do i edit my where clause to display between the SYSDATE and exactly one month before that date?
i know it's something like
WHERE last_used >=SYSDATE
AND last_used is <=??????
i don't know what to put after that...
anybody know?Daniel,
This might get you what you want:
WHERE last_used >=SYSDATE
AND last_used is <= add_months(sysdate, -1)
If this answers your question, please assign points and close the question..
Thank you,
Tony Miller
Webster, TX -
Overloading a DATE function with TIMESTAMP to avoid "too many declarations"
CREATE OR REPLACE PACKAGE util
AS
FUNCTION yn (bool IN BOOLEAN)
RETURN CHAR;
FUNCTION is_same(a varchar2, b varchar2)
RETURN BOOLEAN;
FUNCTION is_same(a date, b date)
RETURN BOOLEAN;
/* Oracle's documentation says that you cannot overload subprograms
* that have the same type family for the arguments. But,
* apparently timestamp and date are in different type families,
* even though Oracle's documentation says they are in the same one.
* If we don't create a specific overloaded function for timestamp,
* and for timestamp with time zone, we get "too many declarations
* of is_same match" when we try to call is_same for timestamps.
FUNCTION is_same(a timestamp, b timestamp)
RETURN BOOLEAN;
FUNCTION is_same(a timestamp with time zone, b timestamp with time zone)
RETURN BOOLEAN;
/* These two do indeed cause problems, although there are no errors when we compile the package. Why no errors here? */
FUNCTION is_same(a integer, b integer) return boolean;
FUNCTION is_same(a real, b real) return boolean;
END util;
CREATE OR REPLACE PACKAGE BODY util
AS
NAME: yn
PURPOSE: pass in a boolean, get back a Y or N
FUNCTION yn (bool IN BOOLEAN)
RETURN CHAR
IS
BEGIN
IF bool
THEN
RETURN 'Y';
END IF;
RETURN 'N';
END yn;
NAME: is_same
PURPOSE: pass in two values, get back a boolean indicating whether they are
the same. Two nulls = true with this function.
FUNCTION is_same(a in varchar2, b in varchar2)
RETURN BOOLEAN
IS
bool boolean := false;
BEGIN
IF a IS NULL and b IS NULL THEN bool := true;
-- explicitly set this to false if exactly one arg is null
ELSIF a is NULL or b IS NULL then bool := false;
ELSE bool := a = b;
END IF;
RETURN bool;
END is_same;
FUNCTION is_same(a in date, b in date)
RETURN BOOLEAN
IS
bool boolean := false;
BEGIN
IF a IS NULL and b IS NULL THEN bool := true;
-- explicitly set this to false if exactly one arg is null
ELSIF a is NULL or b IS NULL then bool := false;
ELSE bool := a = b;
END IF;
RETURN bool;
END is_same;
FUNCTION is_same(a in timestamp, b in timestamp)
RETURN BOOLEAN
IS
bool boolean := false;
BEGIN
IF a IS NULL and b IS NULL THEN bool := true;
-- explicitly set this to false if exactly one arg is null
ELSIF a is NULL or b IS NULL then bool := false;
ELSE bool := a = b;
END IF;
RETURN bool;
END is_same;
FUNCTION is_same(a in timestamp with time zone, b in timestamp with time zone)
RETURN BOOLEAN
IS
bool boolean := false;
BEGIN
IF a IS NULL and b IS NULL THEN bool := true;
-- explicitly set this to false if exactly one arg is null
ELSIF a is NULL or b IS NULL then bool := false;
ELSE bool := a = b;
END IF;
RETURN bool;
END is_same;
/* Don't bother to fully implement these two, as they'll just cause errors at run time anyway */
FUNCTION is_same(a integer, b integer) return boolean is begin return false; end;
FUNCTION is_same(a real, b real) return boolean is begin return false; end;
END util;
declare
d1 date := timestamp '2011-02-15 13:14:15';
d2 date;
t timestamp := timestamp '2011-02-15 13:14:15';
t2 timestamp;
a varchar2(10);
n real := 1;
n2 real;
begin
dbms_output.put_line('dates');
dbms_output.put_line(util.yn(util.is_same(d2,d2) ));
dbms_output.put_line(util.yn(util.is_same(d1,d2) ));
dbms_output.put_line('timestamps'); -- why don't these throw exception?
dbms_output.put_line(util.yn(util.is_same(t2,t2) ));
dbms_output.put_line(util.yn(util.is_same(t,t2) ));
dbms_output.put_line('varchars');
dbms_output.put_line(util.yn(util.is_same(a,a)));
dbms_output.put_line(util.yn(util.is_same(a,'a')));
dbms_output.put_line('numbers');
-- dbms_output.put_line(util.yn(util.is_same(n,n2))); -- this would throw an exception
end;
/Originally, I had just the one function with VARCHAR2 arguments. This failed to work properly because when dates were passed in, the automatic conversion to VARCHAR2 was dropping the timestamp. So, I added a 2nd function with DATE arguments. Then I started getting "too many declarations of is_same exist" error when passing TIMESTAMPs. This made no sense to me, so even though Oracle's documentation says you cannot do it, I created a 3rd version of the function, to handle TIMESTAMPS explicitly. Surprisingly, it works fine. But then I noticed it didn't work with TIMESTAMP with TIME ZONEs. Hence, the fourth version of the function. Oracle's docs say that if your arguments are of the same type family, you cannot create an overloaded function, but as the example above shows, this is very wrong.
Lastly, just for grins, I created the two number functions, one with NUMBER, the other with REAL, and even these are allowed - they compile. But then at run time, it fails. I'm really confused.
Here is the apparently incorrect Oracle documentation on the matter: http://docs.oracle.com/cd/B12037_01/appdev.101/b10807/08_subs.htm (see overloading subprogram names), and here are the various types and their families: http://docs.oracle.com/cd/E11882_01/appdev.112/e17126/predefined.htm.
Edited by: hotwater on Jan 9, 2013 3:38 PM
Edited by: hotwater on Jan 9, 2013 3:46 PM>
So, I added a 2nd function with DATE arguments. Then I started getting "too many declarations of is_same exist" error when passing TIMESTAMPs. This made no sense to me
>
That is because when you pass a TIMESTAMP Oracle cannot determine whether to implicitly convert it to VARCHAR2 and use your first function or implicitly convert it to DATE and use your second function. Hence the 'too many declarations' exist error.
>
, so even though Oracle's documentation says you cannot do it, I created a 3rd version of the function, to handle TIMESTAMPS explicitly. Surprisingly, it works fine. But then I noticed it didn't work with TIMESTAMP with TIME ZONEs.
>
Possibly because of another 'too many declarations' error? Because now there would be THREE possible implicit conversions that could be done.
>
Hence, the fourth version of the function. Oracle's docs say that if your arguments are of the same type family, you cannot create an overloaded function, but as the example above shows, this is very wrong.
>
I think the documentation, for the 'date' family, is wrong as you suggest. For INTEGER and REAL the issue is that those are ANSI data types and are really the same Oracle datatype; they are more like 'aliases' than different datatypes.
See the SQL Language doc
>
ANSI, DB2, and SQL/DS Datatypes
SQL statements that create tables and clusters can also use ANSI datatypes and datatypes from the IBM products SQL/DS and DB2. Oracle recognizes the ANSI or IBM datatype name that differs from the Oracle Database datatype name. It converts the datatype to the equivalent Oracle datatype, records the Oracle datatype as the name of the column datatype, and stores the column data in the Oracle datatype based on the conversions shown in the tables that follow.
INTEGER
INT
SMALLINT
NUMBER(38)
FLOAT (Note b)
DOUBLE PRECISION (Note c)
REAL (Note d)
FLOAT(126)
FLOAT(126)
FLOAT(63) -
Hi,
I try using the CountIf-function with dates in the conditional parameter of the function and I am experiencing the same problem as stated here: http://forums.sdn.sap.com/thread.jspa?threadID=1756183
In the Designer and in Excel itself everything looks ok, but not in the final swf-file.
I am using the function like this:
=COUNTIF(G$3:G$40; ">"&P4)
while P4 holds the value 40940 (01.02.2012 in numeric format) and G3 to G40 also holds various dates with the cell-style set to "numeric". Does it even have any influence to which format the cell-style is set?
Is there any workaround or am simply doing something wrong?
I'm using Dashboard Design Version 6.0.0.0 Build 14,0,2,364
Thank you,
Daniel
Edit:
I changed the source data of the function. P4 now contains the return value of DATEVALUE("01.02.2012"). G3 to G40 also contain now =DATEVALUE(<anotherCell>) while <anotherCell> contains the date in textform.
The result is still the same (right result in Excel, wrong result in the Preview/SWF-file). This is confusing because CountIf should work with numbers, right?
Edit2:
I got around the problem by not using dates at all and use mere text for the dates. I then convert it with some text-functions and VALUE() to numbers and do COUNTIF() on these numbers. Not nice but it works.
Seems like Dashboard Design doesn't like DATEVALUE() even though it is in the list of supported functions.
Edited by: Daniel Schueler on Feb 29, 2012 1:31 PMEach of the functions listed above should work. A comprehensive list of Excel Funtions that work with Xcelsius 2008 follows:
ABS ACOS ACOSH ADDRESS AND ASIN
ASINH ASSIGN ATAN ATAN2 ATANH AVEDEV
AVERAGE AVERAGEA AVERAGEIF BETADIST CEILING CHAR
CHOOSE CODE COLUMN COLUMNS COMBIN CONCATENATE
CORREL COS COSH COUNT COUNTA
COUNTIF COVAR DATE DATEVALUE DAVERAGE DAY
DAYS360 DB DCOUNT DCOUNTA DDB DEGREES
DEVSQ DGET DIVIDE DMAX DMIN DOLLAR
DPRODUCT DSTDEV DSSTDEVP DSUM DVAR DVARP
EDATE EFFECT EOMONTH EVEN EXACT EXP
EXPONDIST FACT FACTDOUBLE FALSE FIND FISHER
FISHERINV FIXED FLOOR FORECAST FV GE
GEOMEAN GT HARMEAN HLOOKUP HOUR IF
IFERROR INDEX INT INTERCEPT IPMT
IRR ISBLANK ISERR ISERROR ISEVEN ISLOGICAL
ISNA ISNONTEXT ISNUMBER ISODD ISTEXT KURT
LARGE LE LEFT LEN LN LOG
LOG10 LOOKUP LOWER MATCH MAX MAXA
MEDIAN MID MIN MINA MINUS MINUTE
MIRR MOD MODE MONTH N NE
NETWORKDAYS NORMDIST NORMINV NORMSINV NOT NOW
NPER NPV OFFSET OR PEARSON PERCENTILE
PERCENTRANK PERMUT PI PMT POWER PPMT
PRODUCT PV QUOTIENT RADIANS RAND
RANDBETWEEN RANGE_COLON RANK RATE REPLACE REPT
RIGHT ROUND ROUNDDOWN ROUNDUP ROWS
RSQ SECOND SIGN SIN SINH SLN
SLOPE SMALL SQRT STANDARDIZE STDEV STDEVA
STDEVP SUBTOTAL SUM SUMIF SUMPRODUCT SUMSQ
SUMX2MY2 SUMX2PY2 SUMXMY2 SYD TAN TANH
TEXT TIME TIMEVALUE TODAY TRUE TRUNC
TYPE VALUE VAR VARA VARP VARPA
VDB VLOOKUP WEEKDAY WEEKNUM WORKDAY YEAR
YEARFRAC
For future lookup of what functions are supported, Within Xcelsius click on Help and under the Contents tab expand "Working With Data" The Supported Excel Functions are listed in that area. -
ORA-00932 while using nvl with trunc function
What happens when trunc is executed on null?
I am executing the following query:
"select nvl(trunc(null),sysdate) from dual"
and this throws "ORA-00932: inconsistent datatypes: expected NUMBER got DATE, error at Line:1 Column:23".
Whereas "select nvl(null,sysdate) from dual" returns sysdate correctly.
Also "select trunc(null) from dual" returns null only. So when the returned null is passed through nvl why am I getting exception?
This is happening in ver 9.2.0.5.0 and 10.2.0.2.0
There is another observation, which is an issue that we have found in our code, and while trying to fix that we saw the earlier observation.
SELECT * FROM orgs, dual where
trunc(SYSDATE) between trunc(orgs.effective_start_date) and nvl(trunc(orgs.effective_end_date),trunc(sysdate))
Here effective start date and effective end date for orgs are null for all records.
When we run this query on ver 9.2.0.5.0, this runs without any exception. But when we run this query on ver 10.2.0.2.0, we get the same exception, "ORA-00932: inconsistent datatypes: expected NUMBER got DATE, error at Line:2 Column:95".
The join with dual is fake, in actual scenario we have join with other tables, but since we are able to replicate with dual, removed all other details to keep this simple.
Now if we remove the join with dual, the query works fine in both the env.
SELECT * FROM orgs where
trunc(SYSDATE) between trunc(orgs.effective_start_date) and nvl(trunc(orgs.effective_end_date),trunc(sysdate))What happens when trunc is executed on null?
I am executing the following query:
"select nvl(trunc(null),sysdate) from dual"
and this throws "ORA-00932: inconsistent datatypes:
expected NUMBER got DATE, error at Line:1
Column:23".
Whereas "select nvl(null,sysdate) from dual" returns
sysdate correctly.
Also "select trunc(null) from dual" returns null
only. So when the returned null is passed through nvl
why am I getting exception?
This is happening in ver 9.2.0.5.0 and 10.2.0.2.0The first parameter to NVL is determining the expected datatype of the returned column, with the trunc function defaulting that to NUMBER because it's parameter is NULL. The second parameter to NVL needs to match that datatype which it doesn't because it is a date.
SQL> select nvl(trunc(sysdate), sysdate) as mydate from dual;
MYDATE
26/05/2006 00:00:00
SQL> select nvl(trunc(null), sysdate) as mydate from dual;
select nvl(trunc(null), sysdate) as mydate from dual
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got DATE
SQL> select nvl(trunc(123), sysdate) as mydate from dual;
select nvl(trunc(123), sysdate) as mydate from dual
ERROR at line 1:
ORA-00932: inconsistent datatypes: expected NUMBER got DATE
SQL> -
Error while calling XQuery Function with xs:date type as Argument
Hi,
I have follwing function in my DataService .
declare function tns:getXXXDetail($effectiveDate as xs:date,
$cancelDate as xs:date) as element(ns26:XXXAccount)* {
implCode
declare function tns:testGetXXXDetail($searchCriteria as element(ns15:locateMemberXXXDetail))
as element(ns26:XXXAccount)* {
for $Account in tns:getXXXDetail($searchCriteria/ns16:accountTypeDates/ns18:effectiveDate,
$searchCriteria/ns16:accountTypeDates/ns18:cancelDate)
return $Account
I am trying to test the getXXXDetail() function from testGetXXXDetail .
The searchCriteria is a complex type with date elements effectiveDate and cancelDate, both are optional
When i test with effectiveDate,cancelDate elements present in $searchCriteria its working fine.
When i remove these dates element i am getting follwing error
"expected exactly one item, got 0 items" error
Any Clue ?When i remove these dates element i am getting follwing error"expected exactly one item, got 0 items" error
Sounds like your schema for these items indicates minOccurs="1" (or relies on that as the default).
Edit the schema and change the definitions to be...
<xs:element name="effectiveDate" minOccurs="0" ... /> -
Error while executing planning function with reference data
Hi,
I have a two planning functions one is used to upload the file (with out reference data checkbox in planning function RSPLF1) and other planning function ('Referece data'check box is selected in custom planning function RSPLF1) to execute the logic of creating new record along with the flat file data.
Following data is uplooaded
Company code | Profit_ctr | calmonth | Amount
1000 | 50000 | 01.2011 | 150
Cube data
Field1 | Company code | Profit_ctr | calmonth | Amount
| 1000 | 50000 | 01.2011 | 150
Z1 | 1000 | 50000 | 01.2011 | 150
Now I want to change the value from 150 to 200 and when I try to execute with the following data, it is giving dump 'a row with the same key already exists'.
Company code | Profit_ctr | calmonth | Amount
1000 | 50000 | 01.2011 | 200
Ideally in the second execution it should append the new row with Amount value 50 to cube which is the delta value.
I debugged the issue and found that I_TH_REF_DATA has following data and C_TH_DATA also contains the same records.
Field1 Company code | Profit_ctr | calmonth | Amount
# 1000 | 50000 | 01.2011 | 150
Z1 1000 | 50000 | 01.2011 | -150
Z1 1000 | 50000 | 01.2011 | 150
Due to this, record which already exists in C_TH_DATA and trying to append new record with the same combination is failing.
C_TH_DATA should only contain the source data of Amount 200, but not sure why reference data is coming in C_TH_DATA.
Could anyone please guide me on how the reference data is getting populated in C_TH_DATA ?
Thanks in advance
Edited by: peppy on Aug 3, 2011 5:00 PM
Edited by: peppy on Aug 3, 2011 8:37 PMHi Peppy,
C_TH_DATA is hashed table! According to your post you are trying to append to C_TH_DATA and this results in a dump. Please take a look at the standard planning function to see how SAP is programming the planning functions. E.g. in CL_RSPLFC_REPOST method IF_RSPLFA_SRVTYPE_IMP_EXEC~EXECUTE you can find the following code:
CREATE DATA l_r_data_wa LIKE LINE OF c_th_data.
ASSIGN l_r_data_wa->* TO <s_data_wa>.
CREATE DATA l_r_new_wa LIKE LINE OF c_th_data.
ASSIGN l_r_new_wa->* TO <s_new_wa>.
LOOP AT c_th_data INTO <s_data_wa>.
<s_new_wa> = <s_data_wa>.
now the SAP code changes the values, you can do it your way here
and than write the changes back
MODIFY TABLE c_th_data FROM <s_data_wa>.
ENDLOOP:
Another option is to use the READ statement to check if the record is already in the table. If not, you can use MODIFY otherwise you use INSERT. So you get something like this:
READ C_TH_DATA from <s_data_wa> transporting no fields.
if not sy-subrc EQ 0.
INSERT <s_data_wa> into table C_TH_DATA.
else.
MODIFY TABLE c_th_data FROM <s_data_wa>.
endif.
Depending on your requirements you can also use the collect statement.
If c_th_data shows the reference data as well, you may need to adjust the filter to restrict it to the correct values.
Hope this helps.
Best regards
Matthias Nutt
SAP Consulting Switzerland -
Pipelined function with lagre amount of data
We would like to use pipelined functions as source of the select statements instead of tables. Thus we can easily switch from our tables to the structures with data from external module due to the need for integration with other systems.
We know these functions are used in situations such as data warehousing to apply multiple transformations to data but what will be the performance in real time access.
Does anyone have any experience using pipelined function with large amounts of data in the interface systems?It looks like you have already determined that the datatable object will be the best way to do this. When you are creating the object, you must enter the absolute path to your spreadsheet file. Then, you have to create some type of connection (i.e. a pushbutton or timer) that will send a true to the import data member of the datatable object. After these two things have been done, you will be able to access the data using the A3 - K133 data members.
Regards,
Michael Shasteen
Applications Engineering
National Instruments
www.ni.com/ask
1-866-ASK-MY-NI
Maybe you are looking for
-
Hi For past two days I am trying to download Weblogic Server 10.3.5 and ATG 10.3.2 for 64 bit window but the download stops after downloading 30 or 40 MB and once I got network error. I dont know whats the issue. I even disabled my antivirus and f
-
I highly doubt that I need to switch to Mountain lion or any of that because I had this issue with my last macbook several years ago. This is hapening all the time and tends to occur after updating my mac. This time, nothing will fix it and I know ma
-
I tried deleting and re-entering the accounts, but problem with sent folder still occurs
-
Trouble understanding static objects
Hello, I have trouble understanding static objects. 1) class TestA public static HashMap h = new HashMap(); So if I add to TestA.h from within a Servlet, this is not a good idea, right? But if I just read from it, that is ok, right? 2) class TestB pu
-
I am having trouble downloading installation. Help please