BIP SQL Query calling db function....
Hi ,
I am using SQL as my data model (Not Data Template).
Can I modify my SQL query to include a database function .....eg
select
col1 ,
col2,
mypackage.myfunction(col2)
from table_1
Please let me know
rgds
s
yes.
don't forget to give me the points.
Ike Wiggins
http://bipublisher.blogspot.com
Similar Messages
-
What is the best way to Optimize a SQL query : call a function or do a join?
Hi, I want to know what is the best way to optimize a SQL query, call a function inside the SELECT statement or do a simple join?
Hi,
If you're even considering a join, then it will probably be faster. As Justin said, it depends on lots of factors.
A user-defined function is only necessary when you can't figure out how to do something in pure SQL, using joins and built-in functions.
You might choose to have a user-defined function even though you could get the same result with a join. That is, you realize that the function is slow, but you believe that the convenience of using a function is more important than better performance in that particular case. -
SQL Query With analytical function
Hi
Below is the scenario which i am looking for in sql query using analytical functions
I/p
Col1
50
0
-150
-200
300
-100
-300
500
-100
O/p
Col1 col2
50 0
0 0
-150 -100
-200 -200
300 0
-100 0
-300 -100
500 400
-100 0Any help really appreciated
Thanks in advance
Edited by: unique on Aug 10, 2010 4:53 AM
Edited by: unique on Aug 10, 2010 4:55 AM
Edited by: unique on Aug 10, 2010 4:55 AMOh,In this case,There is OLAP solution ;-)
OLAP samples of my homepage http://www.geocities.jp/oraclesqlpuzzle/oracle-sql1-olap.html
with work(SK,Val) as(
select 1, 50 from dual union
select 2, 0 from dual union
select 3,-150 from dual union
select 4,-200 from dual union
select 5, 300 from dual union
select 6,-100 from dual union
select 7,-300 from dual union
select 8, 500 from dual union
select 9,-100 from dual)
select SK,Val,GID,
case when Val > 0
then greatest(0,sum(Val) over(partition by GID))
else Least(0,Val+greatest(0,sum(Val) over(partition by GID
order by SK rows between unbounded preceding
and 1 preceding)))
end as COL3
from (select SK,Val,
sum(greatest(0,sign(Val))) over(order by SK) as GID
from work)
order by SK;
SK VAL GID COL3
1 50 1 0
2 0 1 0
3 -150 1 -100
4 -200 1 -200
5 300 2 0
6 -100 2 0
7 -300 2 -100
8 500 3 400
9 -100 3 0 -
Put SQL query in a function/ call function from region
How can I write a SQL query (like SELECT EMPNO, ENAME, JOB FROM EMP) as PL/SQL function, and then call this function from the PL/SQL Function Returning SQL Statement region?
Thanks, Tomthanks jverd for your quick reply.
I know passing in a reference to an object will do the job if I want to change the value several parameters in one function call.
But I want to ask, is there any other ways?
the following code works.....
public class TestParameter {
public static void main(String[] args) {
Test2 t2 = new Test2();
invokeChange(t2);
System.out.println("x = " + t2.x + "\t y = " + t2.y);
static void invokeChange(Test2 t2) {
t2.x = 10;
t2.y = 15;
class Test2 {
int x;
int y;
} -
Invalid state in SQL query for a function that was created with no errors.
SQL> CREATE OR REPLACE FUNCTION overlap(in_start1 IN TIMESTAMP, in_end1 IN TIMESTAMP, in_start2 IN TIMESTAMP, in_end2 IN TIMESTAMP) RETURN NUMBER
2 IS
3
4 BEGIN
5 IF (in_start1 BETWEEN in_start2 AND in_end2 OR in_end1 BETWEEN in_start2 AND in_end2 OR in_start2 BETWEEN in_start1 AND in_end1) THEN
6 RETURN 0;
7 ELSE
8 RETURN 1;
9 END IF;
10 END;
11 /
Function created.
SQL> show errors;
No errors.
SQL>
SQL> SELECT * FROM tbl where overlaps(current_time,current_time+1,current_time-1,current_time+2) = 0;
SELECT * FROM tbl where overlaps(current_time,current_time+1,current_time-1,current_time+2) = 0
ERROR at line 1:
ORA-06575: Package or function OVERLAPS is in an invalid state
I do not understand why overlaps is returned as in invalid state in the query, when it was created with no errors earlier. Could anyone help me?Marius
Looking at the logic you are trying to create it looks like you are looking for overlapping time periods.
Consider two date/time ranges:
Range 1 : T1 - T2
Range 2 : T3 - T4
Do they overlap?
1) No: T1 < T4 (TRUE) T2 > T3 (FALSE)
T1 --- T2
T3 --- T4
2) Yes: T1 < T4 (TRUE) T2 > T3 (TRUE)
T1 ---------- T2
T3 --- T4
3) Yes: T1 < T4 (TRUE) T2 > T3 (TRUE)
T1 -------------------- T2
T3 --- T4
4) Yes: T1 < T4 (TRUE) T2 > T3 (TRUE)
T1 ----- T2
T3 --- T4
5) Yes: T1 < T4 (TRUE) T2 > T3 (TRUE)
T1 --- T2
T3 ------------ T4
5) No: T1 < T4 (FALSE) T2 > T3 (TRUE)
T1 --- T2
T3 --- T4Answer: Yes they overlap if:
T1 < T4 AND T2 > T3
So you can code the logic in your SQL as simply:
SELECT *
FROM tbl
WHERE range1_start < range2_end
AND range_1_end > range2_startIf you go around implementing PL/SQL functions for simple logic that can be achieved in SQL alone then you cause context switching between the SQL and PL/SQL engines which degrades performance. Wherever possible stick to just SQL and only use PL/SQL if absolutely necessary. -
SQL query with object function
I want to write a function, which returns more than one value and to include those values into a SQL statement. For example I want to query the RDB with....
select t.id, my_function(t.id).value1 name, my_function(t.id).value2 address ....
from table_x t
where t.id between 1 and 10
and bitand(my_function(t,id)).sec_id,2)>3
Is it possible to do something like this?
I tried to use object and table of objects(my_type) to return value of my_type but when I used
select ......my_function(t.id).name,my_function(t.id).address ...
from table_x
where t.id=some_value;
the function was called twice(i expected this result, but i don't know how to avoid it).
Simple example
CREATE OR REPLACE TYPE l_test AS OBJECT
id NUMBER(10),
name varchar2(100),
a_date date
CREATE OR REPLACE FUNCTION test_f2(test_number IN NUMBER)
RETURN l_test
IS
a number;
BEGIN
select t_seq.nextval into a from dual;
return l_test(a,'test value ='||test_number,sysdate+test_number);
END;
select test_f2(i.id).id client_id, test_f2(i.id).name client_name from r_owners i
CLIENT_ID CLIENT_NAME
1 test value =1
3 test value =2
I want to be able to loop in cursor and use those values
All ideas are welcome!
Thanks,
Iassen HoubenovCheck it out...
SQL> CREATE OR REPLACE TYPE emp_add AS OBJECT
2 ( office VARCHAR2(50),
3 location VARCHAR2(50),
4 MEMBER FUNCTION get_office RETURN VARCHAR2,
5 MEMBER FUNCTION get_location RETURN VARCHAR2,
6 CONSTRUCTOR FUNCTION emp_add(id NUMBER) RETURN SELF AS RESULT,
7 CONSTRUCTOR FUNCTION emp_add(id NUMBER, office VARCHAR2,location VARCHAR2) RETURN
8 SELF AS RESULT
9 ) NOT FINAL;
10 /
Type created.
SQL> CREATE OR REPLACE TYPE BODY emp_add IS
2 MEMBER FUNCTION get_office RETURN VARCHAR2
3 IS
4 BEGIN
5 RETURN SELF.office;
6 END;
7 MEMBER FUNCTION get_location RETURN VARCHAR2
8 IS
9 BEGIN
10 RETURN SELF.location;
11 END;
12 CONSTRUCTOR FUNCTION emp_add(id NUMBER)
13 RETURN SELF AS RESULT
14 IS
15 BEGIN
16 SELECT dname, loc
17 INTO SELF.office, SELF.location
18 FROM dept
19 WHERE deptno = id;
20 RETURN;
21 END;
22 CONSTRUCTOR FUNCTION emp_add(id NUMBER, office VARCHAR2,location VARCHAR2)
23 RETURN SELF AS RESULT
24 IS
25 BEGIN
26 SELF.office := office;
27 SELF.location := location;
28 RETURN;
29 END;
30 END;
31 /
Type body created.
SQL> SELECT e.ename, e.d.office, e.d.location
2 FROM ( SELECT ename
3 , (SELECT emp_add(emp.deptno) FROM dual ) d
4 FROM emp ) e
5 /
ENAME D.OFFICE
D.LOCATION
SMITH RESEARCH
DALLAS
ALLEN SALES
CHICAGO
WARD SALES
CHICAGO
....Smoke me a kipper I'll be back before breakfast.
Cheers, APC -
Need help converting MS SQL query into Oracle, Function 'WHERE' issues
SELECT PERS_NBR, PAY_ID, PAY_CODE, LOGICAL_DATE, LOGICAL_DATE AS END_DATE, PCNAMES + REPLICATE(',', 39 - (LEN(PCNAMES) - LEN(REPLACE(PCNAMES, ',', ''))))
AS PC_NAMES_FINAL
FROM (SELECT DISTINCT A.PAY_ID, A.PAY_CODE, A.PERS_NBR, A.LOGICAL_DATE, PCNAMES = substring
((SELECT TOP 10 ',' + PC_NAME + ',' + SUBSTRING(CAST(B.VALUE AS VARCHAR), 0, LEN(CAST(B.VALUE AS VARCHAR)) - 2)
FROM T_PAY_CAT_RECORD B
WHERE B.PERS_NBR = A.PERS_NBR AND
B.LOGICAL_DATE = A.LOGICAL_DATE FOR XML path(''), elements), 2, 500)
FROM T_PAY_CAT_RECORD A, T_PERSON P
WHERE A.PERS_NBR = P.NBR) FINAL
Edited by: 919969 on Mar 9, 2012 3:45 PMHello
Like any language you need to understand what the messages coming from the syntax check are saying...
XXXX> SELECT PERS_NBR,
2 PAY_ID,
3 PAY_CODE,
4 LOGICAL_DATE,
5 LOGICAL_DATE AS END_DATE,
6 PCNAMES || LPAD(',', 39 - (LENGTH(PCNAMES) - NVL(LENGTH(REPLACE(PCNAMES,',')),0)),',') AS PC_NAMES_FINAL
7 FROM (
8 SELECT PAY_ID,
9 PAY_CODE,
10 PERS_NBR,
11 LOGICAL_DATE,
12 SUBSTR(
13 RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',') PCNAMES
14 2,
15 500
16 )
17 FROM (
18 SELECT A.PAY_ID,
19 A.PAY_CODE,
20 A.PERS_NBR,
21 A.LOGICAL_DATE,
22 A.PC_NAME,
23 ROW_NUMBER() OVER(PARTITION BY A.PERS_NBR,A.LOGICAL_DATE ORDER BY 1) RN
24 FROM T_PAY_CAT_RECORD A,
25 T_PERSON P
26 WHERE A.PERS_NBR = P.NBR
27 )
28 WHERE RN <= 10
29 GROUP BY PAY_ID,
30 PAY_CODE,
31 PERS_NBR,
32 LOGICAL_DATE
33 ) FINAL
34 /
RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',') PCNAMES
ERROR at line 13:
ORA-00907: missing right parenthesisIf you use something like SQL*Plus or SQL Developer, they will give you the error stack which will point you to the source of the problem.
It's saying missing right parenthesis. Start by finding out if we've got all out matching brackets. Counting from the start of that statement i.e. SUBSTR on line 12, we have 7 open brackets and 6 close brackets. So there does appear to be a problem with brackets. However if we take a step back and look at lines 12 to 16, this is actually a single statement. It's a call to the SUBSTR function and within it it has calls to RTRIM, XMLAGG etc. For the statement as a whole there are the same number of left and right parenthesis so the problem is related to something else. Something that is leading the syntax check to think it has reached the end of a statement and hasn't found enough closing parethesis.
The issue here appears to be that we have the token PCNAMES at the end of line 13 but syntactically that's not correct. We can't have that token there because it's appearing in the middle of a function call. PCTNAMES is actually a column alias but it's just in the wrong place. We need it to be an alias for the whole expression from line 12 to 16. So make the change and see what happens...
XXXX> select PERS_NBR,
2 PAY_ID,
3 PAY_CODE,
4 LOGICAL_DATE,
5 LOGICAL_DATE AS END_DATE,
6 PCNAMES || LPAD(',', 39 - (LENGTH(PCNAMES) - NVL(LENGTH(REPLACE(PCNAMES,',')),0)),',') AS PC_NAMES_FINAL
7 FROM (
8 SELECT PAY_ID,
9 PAY_CODE,
10 PERS_NBR,
11 LOGICAL_DATE,
12 SUBSTR(
13 RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',')
14 2,
15 500
16 ) PCNAMES
17 FROM (
18 SELECT A.PAY_ID,
19 A.PAY_CODE,
20 A.PERS_NBR,
21 A.LOGICAL_DATE,
22 A.PC_NAME,
23 ROW_NUMBER() OVER(PARTITION BY A.PERS_NBR,A.LOGICAL_DATE ORDER BY 1) RN
24 FROM T_PAY_CAT_RECORD A,
25 T_PERSON P
26 WHERE A.PERS_NBR = P.NBR
27 )
28 WHERE RN <= 10
29 GROUP BY PAY_ID,
30 PAY_CODE,
31 PERS_NBR,
32 LOGICAL_DATE
33 ) FINAL
34 /
2,
ERROR at line 14:
ORA-00907: missing right parenthesisNOw we've got a new error. Again it's saying we've got a missing parenthesis but this time on line 14. The issue here is that line 13 is a parameter to the SUBSTR function but there is no comma on the end. What we actually have at the moment is a line that looks like so
RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),',') 2,Which is just not formed correctly. We need a comma at the end of line 13 to state that this is the end of that line as a parameter.
XXXX> select PERS_NBR,
2 PAY_ID,
3 PAY_CODE,
4 LOGICAL_DATE,
5 LOGICAL_DATE AS END_DATE,
6 PCNAMES || LPAD(',', 39 - (LENGTH(PCNAMES) - NVL(LENGTH(REPLACE(PCNAMES,',')),0)),',') AS PC_NAMES_FINAL
7 FROM (
8 SELECT PAY_ID,
9 PAY_CODE,
10 PERS_NBR,
11 LOGICAL_DATE,
12 SUBSTR(
13 RTRIM(XMLAGG(XMLELEMENT(e,PC_NAME || ',' || SUBSTR(VALUE,1,LEN(VALUE) - 2),',').EXTRACT('//text()')),','),
14 2,
15 500
16 ) PCNAMES
17 FROM (
18 SELECT A.PAY_ID,
19 A.PAY_CODE,
20 A.PERS_NBR,
21 A.LOGICAL_DATE,
22 A.PC_NAME,
23 ROW_NUMBER() OVER(PARTITION BY A.PERS_NBR,A.LOGICAL_DATE ORDER BY 1) RN
24 FROM T_PAY_CAT_RECORD A,
25 T_PERSON P
26 WHERE A.PERS_NBR = P.NBR
27 )
28 WHERE RN <= 10
29 GROUP BY PAY_ID,
30 PAY_CODE,
31 PERS_NBR,
32 LOGICAL_DATE
33 ) FINAL
34 /
T_PERSON P
ERROR at line 25:
ORA-00942: table or view does not existNow we have a new error but this time it's because I don't have the t_person table on my database. Syntactically the statement above is now correct so it should work on your system.
HTH
David
Edited by: Bravid on Mar 12, 2012 10:20 AM -
Tuning SQL Query calling multiple views
Dear All,
I have a complex scenario in which I have created views in 3 levels for sales and Service separately so total no of views are 6.
Level 2 calls view in Level 1 and Level 3 calls level 2 in sales as well as services.
Finally Level 4 has the union of sales and Service Level 3 view.
There are 5 tables used in total and all have been indexed for better performance.
The cube processing for the above scenario has processing time of 6 mins.
The goal is to bring it down to 2-3 mins.
The amount of data currently we are looking at is not more than 2-3 GB.
Can anybody help me fine tune this scenario?
Thanks, Franco.Run the queries the cube is using in SSMS and turn on the Include Actual Execution Plan option.
https://msdn.microsoft.com/en-us/library/ms189562.aspx?f=255&MSPPError=-2147217396
Straight up it may suggest missing indexes which you can test to see if they improve the query performance. You can't take these suggestions as gospel - sometimes SQL Server gets it wrong - so you need to test them.
After that look in the query plan for any table scan operators. Unless you are actually retrieving every row in a table you shouldn't have any of these and they can probably be removed by placing a properly considered index on the table.
After that look for any RID Lookups or Key Lookups. These can generally be resolved fairly easily by adding the columns being looked up as "include" columns in the indexes.
Here are some links that might get you started.
Reading Execution Plans: http://www.mssqltips.com/sqlservertip/1873/how-to-read-sql-server-graphical-query-execution-plans/
Resolving Table Scans http://blog.sqlauthority.com/2007/03/30/sql-server-index-seek-vs-index-scan-table-scan/
Resolving Lookups: http://blog.sqlauthority.com/2009/11/09/sql-server-removing-key-lookup-seek-predicate-predicate-an-interesting-observation-related-to-datatypes/
Those are the obvious things - and generally the easiest to achieve. Performance tuning is a big area. It may be that the database queries are already performing perfectly well and the time being spent is processing the cube itself so you need
to establish where the time is going. There is no point trying to tune the database queries if they are already working well.
LucasF -
I am trying to only display the records where the 'date_entered' is the most recent date per case number.
SELECT distinct c.case_number, u.email,c.assigneddate_chart,
--m.date_entered,
max(m.date_entered)as last_date_entered,
trunc(sysdate)-trunc(c.assigneddate_chart)days_late,
trunc(sysdate)-trunc(m.date_entered)addl_days_late
from chart c, chart_user_roles u,comments m
where
(c.case_status IN ('Open','Pending')) and
c.case_number=m.case_number
group by c.case_number,
u.email,c.assigneddate_chart,m.date_enteredRight now, this is the output im am getting.
Output:
CASE_NUMBER------EMAIL---------ASSIGNEDDATE_CHART---LAST_DATE_ENTERED---DAYS_LATE--ADDL_DAYS_LATE
[email protected]----06-NOV-09-----------------31--------------------11
[email protected]----10-NOV-09-----------------31---------------------7
[email protected]----06-NOV-09-----------------31--------------------11
[email protected]----06-NOV-09-----------------31--------------------11
[email protected]----06-NOV-09-----------------31--------------------11
[email protected]----03-NOV-09-----------------34--------------------14
I am wanting to achieve this output:
Therefore, based on the data below, the only records that i am wanting to display are:
[email protected]----10-NOV-09-----------------31---------------------7
[email protected]----03-NOV-09-----------------34--------------------14
Thanks
DeannaIs there a reason that you have a DISTINCT in your query? It always makes me nervous to see that where it's not clearly necessary because it frequently means that a developer is missing a join condition and is using the DISTINCT to mask that fact.
On to the meat of your question, though, is there a potential for ties? If so, how do you want to handle that-- do you want two rows for that case, do you want to break the tie using some other column, do you want to pick an arbitrary row? If you want to pick an arbitrary row
SELECT case_number, email, assignedDate_chart, last_date_entered, days_late, addl_days_late
FROM (
SELECT a.*, row_number() over (partition by case_number order by date_entered) rn
FROM (<<your query>>) a
WHERE rn = 1If you want to do something else, just adjust the analytic function and use RANK or add a tie-breaker to the ORDER BY.
Justin -
SQL Query for all Function Name attached to Responsibility
I have a requiremnet where in the data needs to be fetched giving all details of User Name, Responsibility Name, Function_user_name at responsibility level.
For e.g when a user logs in ORacle application and gets in to a responsibility and uses short cut key (Cntrl + L), the application lists out all the form functions, i need those form funtion for all users at responsibility level.
follwoing is the SQL i developed but its not listing the form function when we use (cntrl + L).
SELECT fur.user_name, fur.description, fur.responsibility_name,
mnu.user_function_name, mnu.function_name --, mnu.TYPE, mnu.PARAMETERS
FROM (
SELECT /*+ ordered use_nl(ffft) */
DISTINCT fm.menu_id, ffft.user_function_name, fff.function_name,
fff.TYPE, fff.PARAMETERS
FROM (select distinct menu_id
from apps.fnd_responsibility_tl frt,
applsys.fnd_responsibility fr
where 1=1
and frt.responsibility_id = fr.responsibility_id
and frt.application_id = fr.application_id
and frt.responsibility_name = 'SLCHR Admin Asst' ) frm,
apps.fnd_menus fm,
apps.fnd_form_functions fff,
apps.fnd_form_functions_tl ffft
WHERE 1 = 1
--AND fm.menu_id IN (1004979, 1009084)
AND frm.menu_id = fm.menu_id
AND fff.function_id = ffft.function_id
AND fm.menu_id IN (SELECT me.menu_id
FROM apps.fnd_menu_entries me
START WITH me.function_id = fff.function_id
CONNECT BY PRIOR me.menu_id = me.sub_menu_id)
) mnu,
(SELECT fusr.user_name, fusr.description, frv.responsibility_name, frv.menu_id
FROM apps.fnd_responsibility_vl frv,
apps.fnd_user_resp_groups_direct frg,
apps.fnd_user fusr
WHERE 1 = 1
--and fusr.user_name = 'JLEWIS03'
AND frv.responsibility_name = 'SLCHR Admin Asst'
AND frv.end_date IS NULL
AND fusr.user_id = frg.user_id
AND fusr.end_date IS NULL
AND frv.responsibility_id = frg.responsibility_id
) fur
WHERE 1 = 1
AND fur.menu_id = mnu.menu_id
Please helpPlease see these docs.
Checking Functions Associated with a User Menu or a Responsibility [ID 948512.1]
HOW TO GENERATE MENU TREE FOR A MENU ATTACHED TO A RESPONSIBILITY IN ORACLE APPLICATIONS 11i ? [ID 312014.1]
Thanks,
Hussein -
SQL Query - Using Lag function
Hi All,
I need to select the previous and next record, when the value of column is changed for each account.
My table structure is as follows:
Account_No number(10)
Payment_type number(5)
Installment_Type number(5)
Date_chage date
Sample record:
Account_No Payment_Type Installment_Type Date_change
70539 ** 1 ** 2 ** 01-OCT-83
70539 ** 1 ** 2 ** 03-FEB-01
70539 ** 1 ** 2 ** 26-APR-02
70539 ** 1 ** 1 ** 21-JUN-02
70539 ** 1 ** 2 ** 12-JUL-02
185562 ** 1 ** 2 ** 23-APR-02
185562 ** 2 ** 2 ** 10-MAY-02
In the above sample data, the value of instalment is changed on 21-jun-02 and 12-jul-02 for the account 70539. Also the value of Payment Type is changed on 23-apr-02 for the account 185562.
So, my output should be like this.
Account_No Payment_Type Installment_Type Date_change
70539 ** 1 ** 2 ** 26-APR-02
70539 ** 1 ** 1 ** 21-JUN-02
70539 ** 1 ** 2 ** 12-JUL-02
185562 ** 1 ** 2 ** 23-APR-02
185562 ** 2 ** 2 ** 10-MAY-02
I tried with lag function, but I couldnt succeed. Im using oracle 8.1.6 Version.
Can anyone help me to achieve this?
** To distinguish the value for each coulmn.
Thanks and regards,
Vijay R.With the information you have provided, I've come up with the following.
SELECT A.ACCOUNT_NO, A.PAYMENT_TYPE, A.INSTALLMENT_TYPE, A.DATE_CHANGE
FROM
(SELECT account_no, payment_type, installment_type, date_change,
LEAD( (payment_type), 1)
over (partition by account_no order by account_no, DATE_CHANGE) LEAD_PAY,
LEAD( (installment_type), 1)
over (partition by account_no order by account_no, DATE_CHANGE) LEAD_INST
from T_ACCNTS ) A
WHERE A.PAYMENT_TYPE <> NVL(A.LEAD_PAY,99)
OR A.INSTALLMENT_TYPE <> NVL(A.LEAD_INST,99)
ORDER BY 1, 4; -
Calling a function in the select part of a query
I am integrating Apex with E-Bus Suite 11.5.10.2.
I have a function in a sql query. The function calls an apps view. When i run the sql query in TOAD, I get the correct data. When I run it in Apex, i get an error - it says "Invalid number"
My apex report is registered in my 11i menu. Who is the user that is running this report? Is it apps?
thanksWhen you run it in TOAD, you are passing through a value, correct? Maybe when your EBS call to your APEX report is done, it is passing through a character value as apposed to a number. You might want to convert your passed in value in your function to a number to be sure..
Also, it is not always the best idea to call a function in a select statement.. Is there a reason you can't do in sql what your function is doing?
Thank you,
Tony Miller
Webster, TX -
How to write SQL query and apply aggregate functions on it
Hello experts,
Iu2019ve a task to write SQL query on tree tables and do inner join on them. Iu2019ve accomplish this task by using T-CODE SQVI. However now I need to write a query and apply SQL functions on it i.e. Add, Count, Max and Min etc. Please can someone tell me how I can write SQL query with aggregate functions in SAP?
Thanks a lot in advanceHI Mr. Cool
you can see the below code for using aggregate functions.
where ARTIST and SEATSOCCU are the field names for which you want to perform these functions.
DATA: TOTAL_ENTRIES TYPE I,
TOTAL_ATT TYPE I,
MAX_ATT TYPE I,
AVG_ATT TYPE I.
SELECT COUNT( DISTINCT ARTIST )
SUM( SEATSOCCU )
MAX( SEATSOCCU )
AVG( SEATSOCCU ) FROM YCONCERT INTO (TOTAL_ENTRIES, TOTAL_ATT,
MAX_ATT, AVG_ATT).
Thanks
Lalit Gupta -
Variable vs hardcoded value in SQL query
Hi Gurus,
I have a SQL query inside a function that looks similar (i'm showing the "where" clause here only) to the below:
WHERE ID = variable_id (by the way this two have exactly the same type, number(20))
and
WHERE ID = 100
In the first option that uses variable it takes 4 secs to complete the query, while the second one that uses hardcoded value completes in milliseonds. Im new to oracle but been to other dbms and havent seen such behaviour. Anyone encountered or know what maybe the cause? I thought of not pasting here the explain plan since its just a question of variable vs hardcoded value.
rgds.Just want to add something, here is the stats for the two queries:
Statistics for variable_id (15 secs)
29 recursive calls
0 db block gets
24324 consistent gets
21556 physical reads
0 redo size
20676 bytes sent via SQL*Net to client
613 bytes received via SQL*Net from client
25 SQL*Net roundtrips to/from client
17 sorts (memory)
0 sorts (disk)
358 rows processed
Statistics for hardcoded value (5 secs)
4 recursive calls
0 db block gets
2631 consistent gets
0 physical reads
0 redo size
20469 bytes sent via SQL*Net to client
613 bytes received via SQL*Net from client
25 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
358 rows processed
There are differences consistent gets and physical reads. What coul dbe the problem here?
tnx! -
How to use SQL Query in OBIEE Reports
Hi all,
I need to use direct sql query in report function column.. How can I implement that.
For example
Our report name is /shared/Automotive/Vehicle Services/Most Serviced Vehicle Models
we have to eliminate /shared/Automotive/Vehicle Services/ part from above report name.. I have done this in sql using the Query SUBSTR(COL,INSTR(COL,'/',1,4)+1).
So kindly help how to implement above sql query in Obiee.. Urgent.
Thanx in advance796797 wrote:
Hi all,
I need to use direct sql query in report function column.. How can I implement that.
For example
Our report name is /shared/Automotive/Vehicle Services/Most Serviced Vehicle Models
we have to eliminate /shared/Automotive/Vehicle Services/ part from above report name.. I have done this in sql using the Query SUBSTR(COL,INSTR(COL,'/',1,4)+1).
So kindly help how to implement above sql query in Obiee.. Urgent.
Thanx in advanceArrggh. I wish people wouldn't just answer a question without taking the time to actually think about what the user is asking for and if it makes sense. I like Diney's response best: Why not use the Title View? (i.e., asking questions until it is clear what is needed.) So along those lines, why are you trying to put the name of your report in a column of your report?? And why do you need to use direct sql to do this??
Kindly or not, urgent or not, state what you are trying to achieve and why you need it (if the obvious answer like "using the Title View" doesn't work for you), instead of simply assuming your method is right and you need to know how to do what envision. Your method may not be correct or necessary.
Maybe you are looking for
-
We recently updated to CU8. I went to test out the new Public Folder access to calendars and contacts. I first go to Calendars in OWA and I see a list of several calendars. I see one that is listed twice, one I can open and the other states "Couldn
-
How to create a demo with time limit? (timebomb)
Hello, I would like to create a demo of a game I made but want to limit the amount of time it will run once installed. (30 days). Is there an xtra or a straightforward way to do this in lingo?
-
BPM Scenario how to wait til file deleted in Target Directory
Hi Frnds, I am working on one JMS to File scenario,my requirement is i am sending JMS message to File Directory,when i placed meg in target directory some vent wil read the message it wil process in to SAP. When i receive once again mesage in JMS sce
-
SOLAR02 The document cannot be changed
Hello, I have developed a program that uploads files massively to Solution Manager, and the upload process works fine. But when i try to edit a document that i uploaded using this program, the systems shows me this popup message. The document cannot
-
How to display a rectangular ROI in a new image?
Hi, I want to display a rectangular ROI in a new image. I want the rest of the image to be cropped. I selected the ROI by using the 'IMAQ Select Rectangle' vi And changed the rectangle output generated into an ROI using 'IMAQ Convert Rectangle t