Function to compare 2 expressions
Can you please any one give the expression to be used in sql to find out the small value in the 2 expressions given.
LEAST('apples', 'bannana', 'carrots')
RETURNS 'apples'
LEAST(1, 2, 3)
RETURNS 1
LEAST will be the function you require but remember that if you have a NULL value in your data this will return as your LEAST value.
LEAST('apples', 'bannana', 'carrots', NULL)
RETURNS NULL
Similar Messages
-
How to call a SQL function from an XSL expression
Hi
In R12, in Payroll Deposit adivce/Check writer, We need to sort the earnings tag <AC_Earnings> in to two different categories as regular and other earnings. In the DB and form level of element defintiion we have a DFF which differentiates between the two kinds of earnings. But the seeded XML that is gerneated by the check writer does not have this field.
The seeded template displays all the earnings in one column. How can we achieve this in the template without modifying the seeded XML.
The one approach i have is to write a function and based on the return value sort the data. For this I need to know :
1) How to call a SQL function from an XSL expression that is allowed in BI template.
If anyone ahs faced similar requirements please share your approach.
Thanks
SrimathiThank u..
but i'd seen that link wen i searched in google..
Is it possible without using any 3rd party JARs and all?
and more importantly plz tell me what should be preferred way to call a javascript function?
Do it using addLoadEvent() or Windows.Load etc
OR
Call it thru Xsl? (I donno how to do dis)
Thanks in Advance..
Edited by: ranjjose on Jun 3, 2008 8:21 AM -
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) -
Does the condition specified in the function 'DECODE' allow 'BETWEEN' expression?
Does the condition specified in the function 'DECODE' allow 'BETWEEN' expression?
As a completely different approach, in 8i SQL and 9i PL/SQL we can use the CASE function. This delivers decode functionality, but allows us to use conditions e.g.
SELECT CASE WHEN col BETWEEN 1 and 9 THEN 'one' ELSE 'two' END FROM my_table;I love DECODE and wouldn't use anything else for straight value substitutions but CASE does have the advantage of clarity when it comes to maths, etc. Also I believe DECODE is not ANSI compliant. In which case (ho ho!) I suspect it will probably be deprecated, as Oracle seems to be moving towards ANSI SQL compliance, as part of its open standards drive.
Cheers, APC -
Function to compare particular value with LOV Additional Description column
Hi,
Is there an existing function that compares a value with the "Additional Description" of a particular LOV ?
Can the comparison be done by "Adminstration - Personalization"?Sorry & thanks sathish,
Now i got the result.
SQL> select DECISIONED_STAGE_ID,DECISIONED_STAGE_USER_ID from naap10_application where APP_DECISION_DATE BETWEEN TO_DATE ('31.01.2007 00:00:00', 'DD.MM.YYYY HH24:MI:SS') AND TO_DATE ('31.01.2007 23:59:59', 'DD.MM.YYYY HH24:MI:SS')
2 and application_id=2007010028552;
DECISIONED_STAGE_ID DECISIONED_STAG
2006060113 SYSTEM
================================
But one doubt,
When i created the column with the date datatype how it gets the time value,
And in one environment db i got the result but in another environment i dont get,
Shall i want to change any session status of date? -
Hi,
I am getting the following error when using evaluate function
State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 42015] Cannot function ship the following expression: Evaluate( TO_CHAR(%1),D907.c2) . (HY000)
The syntax I had used in the column expression was
EVALUATE('TO_CHAR(%1)' AS CHAR,"SA table"."Prior Quarter QTD Dollars")
I am not sure why this is error is occurring because I have successfully used this syntax before. This is an example syntax I had used in another report and it is working well even now
CAST(EVALUATE('TO_CHAR(%1,%2)' AS CHAR,ROUND(("table1"."QTD Actuals")/1000,0) ,'$9,999,999,999,999,990') AS CHAR)I had to use Case and CAST functions to achieve the same logic. I have raised a TAR with Oracle for this issue. Still waiting to hear from them. Using Case and CAST achieved the result but since there is a bug in 10.1.3.4.0 where download will fail if the query generated is more than 64kb, we are upgrading to 10.1.3.4.1.
-
Cannot function ship the following expression: Evaluate
hello
i used a db function in rpd
EVALUATE('X.F_REPLACE_NEG_VAL_TO_ZERO(%1)' AS DOUBLE PRECISION , "Stock"."Fact - Inventory"."Vol")
the functions purpose is to put to zero the measure in case its <0
when i use this measure in answers it works fine; however when i add a measure from another facts table into the report i get the following error:
"Cannot function ship the following expression: Evaluate( X.F_REPLACE_NEG_VAL_TO_ZERO(%1),D902.c6) "
this is a multifacts area, the dimensions used in the report are common for both facts tables (report runs fine with either measures from facts table 1 or from facts table 2); only error is when i put both measures together;
i went through many threads here but could not find any solution that could be applied to above
id appreciate any suggestions
thanks
rgdshello,
i ran some more tests and apparently this is not related to this particular function i.e. even if i use
evaluate('to_number'(1%)','column') it still throws an error
can evaluate be used in multifacts areas? -
Invoke function from oracle application express
Hello,
I am using oracle application express 10g.
I wrote a simple function.
I want to call the function from oracle application express.
*Is it possible to invoke the function from oracle application express?*
I search the web and find no example for it.
Can you please write any good links for an example? What have I missed?_
I am really stuck with it. Any help will be appreciated!
Thanks a lot,
Niron.Hi,
You can call function in e.g. computations, validations and process like you call it in SQL sheet.
Process example to get value to variable from function sending item value as parameter
DECLARE
l_my_var varchar2(32700);
BEGIN
l_my_var := my_function(:Px_MY_ITEM);
/* other code */
END;Regards,
Jari -
SQL Function to compare 2 strings
Hi All
Is there any SQL function to compare 2 strings?If you are looking for a character by character comparison then you would have to do something like...
SQL> ed
Wrote file afiedt.buf
1 WITH T AS (select 'THIS IS MY 1ST STRING' string1, 'THIS IS MY 2ND String Bob' string2 from dual)
2 --
3 select s1ch, s2ch, decode(s1ch,s2ch,'Match','Mismatch') as compare
4 from (
5 select rn, substr(string1,rn,1) as s1ch, substr(string2,rn,1) as s2ch
6 from t, (select rownum rn from t connect by rownum <= greatest(length(string1), length(string2)))
7 )
8* order by rn
SQL> /
S S COMPARE
T T Match
H H Match
I I Match
S S Match
Match
I I Match
S S Match
Match
M M Match
Y Y Match
Match
1 2 Mismatch
S N Mismatch
T D Mismatch
Match
S S Match
T t Mismatch
R r Mismatch
I i Mismatch
N n Mismatch
G g Mismatch
Mismatch
B Mismatch
o Mismatch
b Mismatch
25 rows selected.
SQL> -
I would like to be able to compare two xpath expressions and evaluate whether their result CAN have nodes in common.
For example:
expression 1: /ItemData[@ItemOID='A']
expression 2: /ItemData[@ItemOID='B']
would need to evaluate to 'false'
Other example:
expression 1: /ItemData[@ItemOID='A']
expression 2: /ItemData[@ItemOID='B or @ItemOID='A']
would need to evaluate to 'true'
Other example:
expression 1: /ItemData[@ItemOID='A']
expression 2: /ItemData[not(@ItemOID='B')]
would need to evaluate to 'true'
Other example:
expression 1: /ItemData[@ItemOID='A']
expression 2: /ItemData[not(@ItemOID='A'][not(@ItemOID='B']
would need to evaluate to 'false'
P.S. Sorry if the Xpath expressions do not show up 100% correctly in the above snippets - the editor is doing crazy ...
I would like to do such an evaluation without actually having an XML document (!).
Is this possible?
Did someone ever write a class for doing so ?
Many thanks
JozefXML4Pharma wrote:
Is this possible?As phrased probably. You would need to create a xpath parser then compare the parse trees for expression equivalency.
You might be able to find a xpath parser. The other part you would need to create yourself. -
Including customized xquery functions in XQuery/XSLT expression Editor-OSB
Hi,
I have written a customized xquery function. I want this to be included in the List of Xquery Functions which is displayed by Oracle Service Bus in the XQuery/XSLT
Expression Editor. OSB displays the built in xquery functions in the XSLT/Xquey Expression Editor. Is there any way to add the customised xquery to this list, so that it can be dragged and dropped later?
Thanks,
Balaji.I doubt if that is exposed out side of Oracle Engineering (Not public/documented). Please raise a support ticket for enhancement. If PM should concur you might get the steps that need to be performed for this feature.
Thanks
Manoj
Edited by: Manoj Neelapu on Jun 8, 2010 8:37 AM -
As the title above suggests this is a somewhat complex problem.
I have the following expression on a field in a MS Access Make Table query.
Left([SYN4_View Invalid Last Candidates]![LastName],3). The table it is referring to: SYN4_View Invalid Last Candidates is a SQL Pass-thru query on an Oracle backend. So, when the expression attempts to evaluate in MS Access 2003 I get the following error msg:
Undefined function 'left' in expression.
I am assuming this is because LEFT function can't evaluate the output of the SQL P-T. I can't use SUBSTR as Access doesn't recognize it.
I would appreciate suggestionsrobleh7 wrote:
I don't have access to the Oracle dB. No pun intended here. Everything I do, I must do from the MS Access 2003 front-end
wow .. that's kinda like sending soldiers into a war zone with a bear trap attached to their legs. O_0
Kind of blatantly trying to hamper your ability to do your job, don't you think? -
Query Transformation in Function Based Index's Expression
Hi All,
I am having a wired issue with Function Based Indexes on Orcale 10.2.0.3 running on Solaris 5.9.
I have created two FBI on two tables using following syntax.
CREATE INDEX EQHUB.IDX_BBO_WRT_DES_FBI ON EQHUB.BBO_WARRANT_PRICING (CASE WHEN latest_version_flag = 'Y' THEN 1 ELSE NULL END);
CREATE INDEX EQHUB.IDX_BBO_DES_FBI ON EQHUB.BBO_DESCRIPTIVE_DATA (CASE WHEN latest_version_flag = 'Y' THEN 1 ELSE NULL END);
For the second command (IDX_BBO_DES_FBI), when i query DBA_IND_EXPRESSIONS view, i found that Oracle has done some kind of QUERY TRANSFORMATION (?) and converted
FBI expression to CASE "LATEST_VERSION_FLAG" WHEN 'Y' THEN 1 ELSE NULL END.At the same time,EXPRESSION on first index is not changed.
Now,my question is what has made transformation to occure only for second index.
I also found that inspite of highly SELECTIVE nature of both the indexes, only SECOND index is being used by CBO (for which trasnformation occured)
and IDX_BBO_WRT_DES_FBI is not being used(FTS is happening instead).
Query is using same expression for both the tables as
(CASE WHEN latest_version_flag = 'Y' THEN 1 ELSE NULL END)=1
INDEX_NAME TABLE_NAME COLUMN_EXPRESSION
IDX_BBO_WRT_DES_FBI BBO_WARRANT_PRICING CASE WHEN "LATEST_VERSION_FLAG"='Y' THEN 1 ELSE NULL END
IDX_BBO_DES_FBI BBO_DESCRIPTIVE_DATA CASE "LATEST_VERSION_FLAG" WHEN 'Y' THEN 1 ELSE NULL ENDI read that expression should be evaluated including CASE of characters and spaces in query.Is that true?
Appreciating responses in advance.Randolf.
It's a shame that I forgot to look into the full execution plan information to check how Oracle really handles my queries.
Look here(edited for clarity):
explain plan for
select /*+ case1 ordered use_nl(x, y) */ count(case c1
when '1' then 1
when '2' then 2
when '3' then 3
else 4
end) from
(select level from dual connect by level <= 300000) x,
(select
from t1
) y;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
| 2 | NESTED LOOPS | | 3 | 6 | 5 (0)| 00:00:01 |
| 3 | VIEW | | 1 | | 2 (0)| 00:00:01 |
| 4 | CONNECT BY WITHOUT FILTERING| | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | T1 | 3 | 6 | 3 (0)| 00:00:01 |
Column Projection Information (identified by operation id):
1 - (#keys=0) COUNT(CASE WHEN "T1"."C1"='1' THEN 1 WHEN "T1"."C1"='2' THEN
2 WHEN "T1"."C1"='3' THEN 3 ELSE 4 END )[22]
2 - (#keys=0) "T1"."C1"[CHARACTER,1]
4 - "DUAL".ROWID[ROWID,10], LEVEL[4]
5 - "DUAL".ROWID[ROWID,10]
6 - "T1"."C1"[CHARACTER,1]
32 rows selected.
explain plan for select /*+ case2 ordered use_nl(x, y) */ count(case
when c1 = '1' then 1
when c1 = '2' then 2
when c1 = '3' then 3
else 4
end) from
(select level from dual connect by level <= 300000) x,
(select
from t1
) y;
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
| 0 | SELECT STATEMENT | | 1 | 2 | 5 (0)| 00:00:01 |
| 1 | SORT AGGREGATE | | 1 | 2 | | |
| 2 | NESTED LOOPS | | 3 | 6 | 5 (0)| 00:00:01 |
| 3 | VIEW | | 1 | | 2 (0)| 00:00:01 |
| 4 | CONNECT BY WITHOUT FILTERING| | | | | |
| 5 | FAST DUAL | | 1 | | 2 (0)| 00:00:01 |
| 6 | TABLE ACCESS FULL | T1 | 3 | 6 | 3 (0)| 00:00:01 |
Column Projection Information (identified by operation id):
1 - (#keys=0) COUNT(CASE WHEN "T1"."C1"='1' THEN 1 WHEN "T1"."C1"='2' THEN
2 WHEN "T1"."C1"='3' THEN 3 ELSE 4 END )[22]
2 - (#keys=0) "T1"."C1"[CHARACTER,1]
4 - "DUAL".ROWID[ROWID,10], LEVEL[4]
5 - "DUAL".ROWID[ROWID,10]
6 - "T1"."C1"[CHARACTER,1]As you exactly mentioned, I was executing different SQL but actually same queries!
Thanks for pointing my flaws.
PS) OP, forgive me for bothering you with off-topic things. :)
================================
Dion Cho - Oracle Performance Storyteller
http://dioncho.wordpress.com (english)
http://ukja.tistory.com (korean)
================================
Edited by: Dion_Cho on Feb 10, 2009 5:45 AM
Typo -
Evaluate function in teststand status expression
Hello,
I can not understand the meaning of function Evaluate() in below sentence,and can not find the explanation in help files,could someone help me ?
Step.DataSource != "Step.Result.PassFail" ? Step.Result.PassFail = Evaluate(Step.DataSource) : False, Step.Result.PassFail ? "Passed" : "Failed"
Solved!
Go to Solution.As an added point of reference, we use the "Evaluate()" function to to parse Variables in a Step Name for TestStand steps. This makes our steps very readable and FAST to code in TestStand.
For example our tests to communicate to a device might be to write a value to a value to a specific parameter, such as writing a Setpoint Value. So the TestStand step name would look like:
[] Writeetpoint(1)=200
Where Setpoint is the Parameter Name, (1) represents the Instance, and 200 is the value written
However we use the Evaluate() function to parse out variables:
Locals.sParameter = "Setpoint"
Locals.nInstance = 1
Parameters.nValue = 200
[]Write:{L.sParameter}({L.nInstance})={P.nValue}
(We use a shortened version of L. for Locals., P. for Parameters., etc. because it doesn't take up so much space on the Step Name)
We have a library subsequence (Check for Curly Brackets to be parsed) that parses out any variables that are enclosed in the {} curly brackets.
Replace "L." with "Locals.", etc. and then parse out the variables in the Pre-Expression,
and then EVALUATE the variables in the Post-Expression:
Locals.sTemporary ="RunState.Caller.RunState.Caller."& Locals.sVariable,
'If the variable exists, resolve it, if not replace it with '{ERROR}' and continue.
Locals.sTemporary =( PropertyExists(Locals.sTemporary)? Evaluate(Locals.sTemporary) :"{ERROR}"),
'Put the resolved variable (or error) back in place of its name
Locals.sWorkingString = Locals.sBeforeVar & Locals.sTemporary & Locals.sAfterVar
Also, during runtime, if there happens to be an error in the StepName, we can edit it and continue on using a "Set Step Name" tool.
Mike -
PL/SQL Pipelined Function to Compare *ANY* 2 tables
I am trying to create a pipelined function in 10g R1 that will take the name of two tables, compare the the tables using dynamic SQL and pipe out the resulting rows using the appropriate row type. The pipelined function will be used in a DML insert statement.
For example:
create table a (f1 number, f2, date, f3 varchar2);
create table b (f1 number, f2, date, f3 varchar2);
create table c (f1 number, f2, date, f3 varchar2);
create or replace TYPE AnyCollTyp IS TABLE OF ANYTYPE;
create or replace TYPE CRowType IS c%ROWTYPE;
create or replace TYPE CRowTabType IS table of CRowType;
CREATE OR REPLACE FUNCTION compareTables (p_source IN VARCHAR2, p_dest IN VARCHAR2)
RETURN AnyCollTyp PIPELINED
IS
CURSOR columnCur (p_tableName IN user_tab_columns.table_name%TYPE)
IS
SELECT column_name, column_id
FROM user_tab_columns
WHERE table_name = p_tableName
ORDER BY column_id;
l_cur sys_refcursor;
l_rec ANYTYPE;
l_stmt VARCHAR2 (32767);
BEGIN
l_stmt := 'select ';
FOR columnRec IN columnCur (p_dest)
LOOP
l_stmt := l_stmt || CASE
WHEN columnRec.column_id > 1
THEN ','
ELSE ''
END || columnRec.column_name;
END LOOP;
l_stmt := l_stmt || ' from ' || p_source;
l_stmt := l_stmt || ' minus ';
l_stmt := l_stmt || ' select ';
FOR columnRec IN columnCur (p_dest)
LOOP
l_stmt := l_stmt || CASE
WHEN columnRec.column_id > 1
THEN ','
ELSE ''
END || columnRec.column_name;
END LOOP;
l_stmt := l_stmt || ' from ' || p_dest;
OPEN l_cur FOR l_stmt;
LOOP
FETCH l_cur
INTO l_rec;
PIPE ROW (l_rec);
EXIT WHEN l_cur%NOTFOUND;
END LOOP;
CLOSE l_cur;
RETURN;
END compareTables;
The pipelined function gets created without error. However, the testCompare procedure gets an error:
SQL> create or replace procedure testCompare is
begin
insert into c
select *
from (TABLE(CAST(compareTables('a','b') as cRowTabType)));
dbms_output.put_line(SQL%ROWCOUNT || ' rows inserted into c.');
end;
Warning: Procedure created with compilation errors.
SQL> show errors
Errors for PROCEDURE TESTCOMPARE:
LINE/COL ERROR
3/4 PL/SQL: SQL Statement ignored
5/47 PL/SQL: ORA-22800: invalid user-defined type
Does anyone know what I am doing wrong? Is there a better way to compare any two tables and get the resulting rows?904640 wrote:
Hi All,
Is it possible to post messages to weblogic JMS queue from pl/sql procedure/function?
From this Queue, message will be read by OSB interface.
Any help will be highly appreciated.
http://www.lmgtfy.com/?q=oracle+pl/sql+weblogic+jms+queue
Maybe you are looking for
-
Considering open PR & PO for CBP
Dear Experts, I have one issue. I want to consider Open PR & PO while considering net requiremment canculation in CBM. ie in following case no planned order should be generated- Stock : 2 PC New Req : 4 PC Open PR/PO : 3 pc So no new planned order sh
-
Not sure what details are needed.
-
My mac keeps crashing EVERYTIME I restart
Ive just had fibre installed and now my Mac mini keeps crashing within minutes of me restarting, even in safe mode. I can't even try to resolve this without it freezing!!
-
How do I change the background pic thats behind my speed dial thumbnails
i put a pic in the browser window behind my speed dial thumbnails and i cannot remember how to change it.
-
Weblogic workshop - download link
Can anyone tell me where is the link to download oracle weblogic workshop.