SQL query that change item input
Hi,
I have an application with a region that displays data from a database through a dblink in which the query is dependent on a value input into a couple of items in the application.
Here is the SQL:
SELECT
FROM
rem_rp_tract@DBLINK_WPC29_G6CEFMP1.NWO.USACE.ARMY.MIL "REM_RP_TRACT"
WHERE
"REM_RP_TRACT"."PROJ_ID" = upper(:P2_PROJECT_CODE)
AND "REM_RP_TRACT"."TRACT_NO" = upper(:P2_TRACTNO)
The P2_PROJECT_CODE and P2_TRACTNO values correspond to locations in a map layer in oracle spatial and data in the dblink indicated in the SQL. The problem is that the TRACT is designated with a dash (J-840) in oracle spatial and in the database it is designated without a dash (J840). Therefore, if I input Tract Number J-840 into the item have developed the app and map to zoom to the tract but no data is displayed because the database does not recognize the value. On the other hand, if I input J840 the data from the database will displayed but oracle spatial doesn't recognize it so the map does not zoom to the tract.
What I would like to do is be able to input the value with the dash (J-840) but change the SQL above so that it queries J840, i.e. all values without a dash. Is this possible?
Any help is greatly appreciated,
Kirk
Try This
SELECT *
FROM rem_rp_tract@DBLINK_WPC29_G6CEFMP1.NWO.USACE.ARMY.MIL "REM_RP_TRACT"
WHERE "REM_RP_TRACT"."PROJ_ID" = upper(:P2_PROJECT_CODE)
AND "REM_RP_TRACT"."TRACT_NO" = REPLACE(upper(:P2_TRACTNO),'-')
SQL> var myvar varchar2(20);
SQL> exec :myvar:='J-840' ;
PL/SQL procedure successfully completed.
SQL> select :myvar , replace(:myvar,'-') from dual ;
:MYVAR REPLACE(:MYVAR,'-')
J-840 J840Replace the - in the string to null.
SS
Similar Messages
-
Executing SQL-query based on user input in text-box on APEX page
Hi,
I'm new to developing in APEX, and I encountered a problem...
Is it even possible to make such thing: use text area for input of some SQL-query and then execute it on my schema and show results in report item? And if the answer is yes, can somebody provide me tips on how to do that?
Thanks in advance.Denes Kubicek wrote:
I think this example shows something similar:
https://apex.oracle.com/pls/apex/f?p=31517:91
Denes Kubicek
http://deneskubicek.blogspot.com/
http://www.apress.com/9781430235125
https://apex.oracle.com/pls/apex/f?p=31517:1
http://www.amazon.de/Oracle-APEX-XE-Praxis/dp/3826655494
-------------------------------------------------------------------I see there is executing stored queries example, and text area showing executed one, but not quite understand how to sent sql-query directly from text input, based on your example :/ -
Not to able add sql query in the item source
Hi,
I am getting this error when i am trying to add the sql query in the item source
ORA-20505: Error in DML: p_rowid=3206911131098131, p_alt_rowid=ID, p_rowid2=, p_alt_rowid2=. ORA-01461: can bind a LONG value only for insert into a LONG column
SELECT
"UCL"
FROM
SELECT
TRUNC((
(SUM("EV FINAL" / 100) / COUNT("Object_Name") )
+
3 *
SQRT
(SUM("EV FINAL" / 100) * SUM("EV FINAL" / 100) ) / COUNT("Object_Name") -
(SUM("EV FINAL" / 100) / COUNT("Object_Name")) * (SUM("EV FINAL" / 100) / COUNT("Object_Name"))
),3) "UCL"
FROM
SELECT
Pro.Project_Name "Project Name",
POBJ.NAME "Object_Name",
TRUNC((
( ( NVL(AEV."Total Actual",0) - (NVL( (NVL( (MAX(X."Incoming-Doc") / 100),0) * NVL(ID."INCOMMING_DOC",0) ) ,0 ) +
NVL( (NVL( (MAX(X."Design") / 100),0) * NVL(D."DESIGN",0) ), 0 ) +
NVL( (NVL( (MAX(X."Build") / 100) ,0) * NVL(B."BUILD",0) ),0 ) +
NVL( (NVL( (MAX(X."Testing") / 100),0) * NVL(T."TESTING",0) ),0 ) +
NVL( (NVL( (MAX(X."Release") / 100),0) * NVL(R."RELEASE",0) ),0 ) ) )
DECODE(
(NVL( (NVL( (MAX(X."Incoming-Doc") / 100),0) * NVL(ID."INCOMMING_DOC",0) ) ,0 ) +
NVL( (NVL( (MAX(X."Design") / 100),0) * NVL(D."DESIGN",0) ), 0 ) +
NVL( (NVL( (MAX(X."Build") / 100) ,0) * NVL(B."BUILD",0) ),0 ) +
NVL( (NVL( (MAX(X."Testing") / 100),0) * NVL(T."TESTING",0) ),0 ) +
NVL( (NVL( (MAX(X."Release") / 100),0) * NVL(R."RELEASE",0) ),0 ) ),0,NULL,
(NVL( (NVL( (MAX(X."Incoming-Doc") / 100),0) * NVL(ID."INCOMMING_DOC",0) ) ,0 ) +
NVL( (NVL( (MAX(X."Design") / 100),0) * NVL(D."DESIGN",0) ), 0 ) +
NVL( (NVL( (MAX(X."Build") / 100) ,0) * NVL(B."BUILD",0) ),0 ) +
NVL( (NVL( (MAX(X."Testing") / 100),0) * NVL(T."TESTING",0) ),0 ) +
NVL( (NVL( (MAX(X."Release") / 100),0) * NVL(R."RELEASE",0) ),0 ) ) ) ) * 100),2)
|| '%' "EV_INITIAL",
TRUNC((
( (NVL(AEV."Total Actual",0) - ( NVL( (NVL( (MAX(X."Incoming-Doc") / 100),0) * NVL(IDR."INCOMMING_DOC_REPLAN",0) ),0) +
NVL( (NVL( (MAX(X."Design") / 100),0) * NVL(DR."DESIGN_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Build")/100),0) * NVL(BR."BUILD_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Testing") / 100),0) * NVL(TR."TESTING_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Release")/100),0) * NVL(RR."RELEASE_REPLAN",0)),0) ) )
DECODE(
( NVL( (NVL( (MAX(X."Incoming-Doc") / 100),0) * NVL(IDR."INCOMMING_DOC_REPLAN",0) ),0) +
NVL( (NVL( (MAX(X."Design") / 100),0) * NVL(DR."DESIGN_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Build")/100),0) * NVL(BR."BUILD_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Testing") / 100),0) * NVL(TR."TESTING_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Release")/100),0) * NVL(RR."RELEASE_REPLAN",0)),0) ) ,0,NULL,
( NVL( (NVL( (MAX(X."Incoming-Doc") / 100),0) * NVL(IDR."INCOMMING_DOC_REPLAN",0) ),0) +
NVL( (NVL( (MAX(X."Design") / 100),0) * NVL(DR."DESIGN_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Build")/100),0) * NVL(BR."BUILD_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Testing") / 100),0) * NVL(TR."TESTING_REPLAN",0)),0) +
NVL( (NVL( (MAX(X."Release")/100),0) * NVL(RR."RELEASE_REPLAN",0)),0) ) ) ) * 100),2) "EV FINAL",
TRUNC(BRV."RSV",2) "Revised SV"
FROM
PROJECTS PRO,
PROJECT_OBJECTS POBJ,
INITIAL_EFFORT IE,
SCHEDULE_VARIANCES SV,
INITIAL_EFFORT_VIEW IEV,
INCOMMING_DOC ID,
DESIGN D,
BUILD B,
TESTING T,
RELEASE R,
INCOMMING_DOC_REPLAN IDR,
DESIGN_REPLAN DR,
BUILD_REPLAN BR,
TESTING_REPLAN TR,
RELEASE_REPLAN RR,
ACTUAL_EFFORT_VIEW AEV,
REPLAN_INITIAL_EFFORT_VIEW RIEV,
BSV_RSV_VIEW BRV,
SELECT
distinct
pro.project_name "Project Name",
pobj.name "Object Name",
PRO.ID "PRO_ID",
POBJ.ID "POBJ_ID",
CASE
WHEN
ts.status in ('CLOSE','CLOSED','Closed') AND
tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review') THEN
TO_CHAR('100')
WHEN
upper(ts.status) like upper('ACCEPTED') AND
tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review') THEN
TO_CHAR('75')
WHEN
ts.status IN ('RIP','WIP','REJECTED','Rejected') AND
tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review') THEN
TO_CHAR('50')
WHEN
POBJ.ID IN (SELECT POBJ.ID FROM projects pro,project_objects pobj,task tsk,skip_phase sp,employees
emp,employee_project_pairs epp
WHERE pobj.pro_id = pro.id and epp.pro_id = pro.id AND sp.tas_id = tsk.id and
pobj.id = sp.OBJ_ID and pro.id = sp.pro_id
and tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review')
AND PRO.ID = :p2_projects ) THEN
TO_CHAR('100')
END "Incoming-Doc",
CASE
WHEN
ts.status in ('CLOSE','CLOSED','Closed') AND
tsk.name in ('Design Review','Design - Review','TDD - Review') THEN
TO_CHAR('100')
WHEN
UPPER(ts.status) LIKE UPPER('ACCEPTED') AND
tsk.name in ('Design Review','Design - Review','TDD - Review') THEN
TO_CHAR('75')
WHEN
ts.status IN ('RIP','WIP','REJECTED','Rejected') AND
tsk.name in ('Design Review','Design - Review','TDD - Review')
THEN
TO_CHAR('50')
WHEN
POBJ.ID IN (SELECT POBJ.ID FROM projects pro,project_objects pobj,task tsk,skip_phase sp,employees
emp,employee_project_pairs epp
WHERE pobj.pro_id = pro.id and epp.pro_id = pro.id AND sp.tas_id = tsk.id and
pobj.id = sp.OBJ_ID and pro.id = sp.pro_id
and tsk.name in ('Design Review','Design - Review','TDD - Review')
AND PRO.ID = :p2_projects ) THEN
TO_CHAR('100')
END "Design",
CASE
WHEN
ts.status in ('CLOSE','CLOSED','Closed') AND
tsk.name in ('Build Review','Build - Review','Code - Review','Code') THEN
TO_CHAR('100')
WHEN
UPPER(ts.status) LIKE UPPER('ACCEPTED') AND
tsk.name in ('Build Review','Build - Review','Code - Review','Code') THEN
TO_CHAR('75')
WHEN
ts.status IN ('RIP','WIP','REJECTED','Rejected') AND
tsk.name in ('Build Review','Build - Review','Code - Review','Code') THEN
TO_CHAR('50')
WHEN
POBJ.ID IN (SELECT POBJ.ID FROM projects pro,project_objects pobj,task tsk,skip_phase sp,employees
emp,employee_project_pairs epp
WHERE pobj.pro_id = pro.id and epp.pro_id = pro.id AND sp.tas_id = tsk.id and
pobj.id = sp.OBJ_ID and pro.id = sp.pro_id
and tsk.name in ('Build Review','Build - Review','Code - Review','Code')
AND PRO.ID = :p2_projects ) THEN
TO_CHAR('100')
END "Build",
CASE
WHEN
ts.status in ('CLOSE','CLOSED','Closed') AND
tsk.name in ('Test Result Review','Test Result - Review','UTR - Review') THEN
TO_CHAR('100')
WHEN
UPPER(ts.status) LIKE UPPER('ACCEPTED') AND
tsk.name in ('Test Result Review','Test Result - Review','UTR - Review') THEN
TO_CHAR('75')
WHEN
ts.status IN ('RIP','WIP','REJECTED','Rejected') AND
tsk.name in ('Test Result Review','Test Result - Review','UTR - Review') THEN
TO_CHAR('50')
WHEN
POBJ.ID IN (SELECT POBJ.ID FROM projects pro,project_objects pobj,task tsk,skip_phase sp,employees
emp,employee_project_pairs epp
WHERE pobj.pro_id = pro.id and epp.pro_id = pro.id AND sp.tas_id = tsk.id and
pobj.id = sp.OBJ_ID and pro.id = sp.pro_id
and tsk.name in ('Test Result Review','Test Result - Review','UTR - Review')
AND PRO.ID = :p2_projects ) THEN
TO_CHAR('100')
END "Testing",
CASE
WHEN
ts.status in ('CLOSE','CLOSED','Closed') AND
tsk.name in ('Release-Review','Release - Verification',
'Migration & Release - Review') THEN
TO_CHAR('100')
WHEN
UPPER(ts.status) LIKE UPPER('ACCEPTED') AND
tsk.name in ('Release-Review','Release - Verification',
'Migration & Release - Review') THEN
TO_CHAR('75')
WHEN
ts.status IN ('RIP','WIP','REJECTED','Rejected') AND
tsk.name in ('Release-Review','Release - Verification','Migration & Release - Review') THEN
TO_CHAR('50')
WHEN
POBJ.ID IN (SELECT POBJ.ID FROM projects pro,project_objects pobj,task tsk,skip_phase sp,employees
emp,employee_project_pairs epp
WHERE pobj.pro_id = pro.id and epp.pro_id = pro.id AND sp.tas_id = tsk.id and
pobj.id = sp.OBJ_ID and pro.id = sp.pro_id
and tsk.name in ('Release-Review','Release - Verification','Migration & Release - Review' )
AND PRO.ID = :p2_projects ) THEN
TO_CHAR('100')
END "Release"
FROM
task_status ts,projects pro,project_objects pobj,task tsk
,employees emp,employee_project_pairs epp,REVIEW_ITEMS RI
WHERE
pobj.pro_id = pro.id
and pro.id = ts.pro_id
and pobj.id = ts.pro_obj_id
and tsk.id = ts.task_id
and emp.id = epp.emp_id
and epp.pro_id = pro.id
and ts.id = ri.ts_id
AND PRO.ID = :p2_projects
and tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review','Design Review','Design - Review','TDD - Review',
'Build Review','Build - Review','Code - Review','Code',
'Test Result Review','Test Result - Review','UTR - Review',
'Release-Review','Release - Verification','Migration & Release - Review')
and ri.open_timestamp in
SELECT
distinct
max(ri.open_timestamp)
FROM
task_status ts,projects pro,project_objects pobj,task tsk
,employees emp,employee_project_pairs epp,REVIEW_ITEMS RI
WHERE
pobj.pro_id = pro.id
and pro.id = ts.pro_id
and pobj.id = ts.pro_obj_id
and tsk.id = ts.task_id
and emp.id = epp.emp_id
and epp.pro_id = pro.id
and ts.id = ri.ts_id
and tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review','Design Review','Design - Review','TDD - Review',
'Build Review','Build - Review','Code - Review','Code',
'Test Result Review','Test Result - Review','UTR - Review',
'Release-Review','Release - Verification','Migration & Release - Review')
AND PRO.ID = :p2_projects
GROUP BY POBJ.NAME,TSK.NAME )
UNION
select
distinct
pro.project_name "Project Name",
pobj.name "Object Name",
PRO.ID "PRO_ID",
POBJ.ID "POBJ_ID",
case
when
tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review') THEN
TO_CHAR('100')
end "Incoming-Doc",
case
when
tsk.name in ('Design Review','Design - Review','TDD - Review') THEN
TO_CHAR('100')
end "Design",
case
when
tsk.name in ('Build Review','Build - Review','Code - Review','Code') THEN
TO_CHAR('100')
end "Build",
case
when
tsk.name in ('Test Result Review','Test Result - Review','UTR - Review') THEN
TO_CHAR('100')
end "Testing",
case
when
tsk.name in ('Release-Review','Release - Verification',
'Migration & Release - Review') THEN
TO_CHAR('100')
end "Release"
FROM
projects pro
,project_objects pobj
,task tsk
,skip_phase sp
,employees emp
,employee_project_pairs epp
WHERE
pobj.pro_id = pro.id
and epp.pro_id = pro.id
AND sp.tas_id = tsk.id
and pobj.id = sp.OBJ_ID
and pro.id = sp.pro_id
and tsk.name in ('Incomming-Doc Review','Incoming Doc- Review',
'Incoming Doc- Review','FDD - Review','Design Review','Design - Review',
'TDD - Review','Build Review','Build - Review','Code - Review','Code',
'Test Result Review','Test Result - Review','UTR - Review',
'Release-Review','Release - Verification','Migration & Release - Review')
and pro.id = :p2_projects ) X
WHERE
PRO.ID = POBJ.PRO_ID AND
PRO.ID = IE.PROJECT_NAME AND
UPPER(POBJ.NAME) = UPPER(IE.OBJECT_NAME) AND
PRO.ID = SV.PROJECT_NAME AND
UPPER(POBJ.NAME) = UPPER(SV.OBJECT_NAME) AND
PRO.ID = :p2_projects
AND PRO.ID = X."PRO_ID"
AND POBJ.ID = X."POBJ_ID"(+)
AND PRO.ID = IEV."PRO_ID"
AND POBJ.ID = IEV."POBJ_ID"
AND PRO.ID = ID."PRO_ID"
AND POBJ.ID = ID."POBJ_ID"
AND PRO.ID = D."PRO_ID"
AND POBJ.ID = D."POBJ_ID"
AND PRO.ID = B."PRO_ID"
AND POBJ.ID = B."POBJ_ID"
AND PRO.ID = T."PRO_ID"
AND POBJ.ID = T."POBJ_ID"
AND PRO.ID = R."PRO_ID"
AND POBJ.ID = R."POBJ_ID"
AND PRO.ID = IDR."PRO_ID"
AND POBJ.ID = IDR."POBJ_ID"
AND PRO.ID = DR."PRO_ID"
AND POBJ.ID = DR."POBJ_ID"
AND PRO.ID = BR."PRO_ID"
AND POBJ.ID = BR."POBJ_ID"
AND PRO.ID = TR."PRO_ID"
AND POBJ.ID = TR."POBJ_ID"
AND PRO.ID = RR."PRO_ID"
AND POBJ.ID = RR."POBJ_ID"
AND PRO.ID = AEV."PRO_ID"
AND POBJ.ID = AEV."POBJ_ID"
AND PRO.ID = RIEV."PRO_ID"
AND POBJ.ID = RIEV."POBJ_ID"
AND PRO.ID = BRV."PRO_ID"
AND POBJ.ID = BRV."POBJ_ID"
group by
PRO.PROJECT_NAME,
POBJ.NAME,
SV.status,
sv.comments,
ID."INCOMMING_DOC",D."DESIGN",B."BUILD",T."TESTING",R."RELEASE",
IDR."INCOMMING_DOC_REPLAN",DR."DESIGN_REPLAN",BR."BUILD_REPLAN",TR."TESTING_REPLAN",RR."RELEASE_REPLAN",
AEV."Total Actual",IEV."Total Plan",RIEV."Total Plan",
BRV."BSV",BRV."RSV",POBJ.Complexity,POBJ.PROGRAM_TYPE,pro.id,pobj.id,BRV."Status"
wht is the mistake i am doing here please suggets
thanks
SudhirCan you just setup an Excel/Essbase retrieval to get the data you need? You can't use SQL to query Essbase; here is a blog post that talks about it:
http://timtows-hyperion-blog.blogspot.com/2008/01/why-you-cant-use-sql-to-query-essbase.html
Since I made that post, I have found out that Essbase has now been integrated into the latest version of the Oracle BI Server and, technically, you could use SQL to query the data in Essbase via the Oracle BI Server if you have the right version.
Tim Tow
Applied OLAP, Inc -
Hi
I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
Thanks
RubyRuby,
you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP. -
Reg: sql query that prints all sundays in the year
Hi all,
Please give me sql query that prints all sundays in year. And when ever we execute that query then that will prints the sysdate(that is execution date).
Thanks in Advance,
-prasad.
Edited by: prasad_orcl on Jun 5, 2009 9:13 PMHi,
Plz try this and let me know this works or not...
SELECT DATE DATES,TO_CHAR(DATE,'DAY') DAYS FROM FISCAL_CALENDAR
WHERE DATE_YEAR = 2009 AND
DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND
ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12) -1 AND
TRIM(TO_CHAR(DATE,'DAY')) = 'SUNDAY'
ORDER BY DATE
OUTPUT:
DATES DAYS
1/4/2009 SUNDAY
1/11/2009 SUNDAY
1/18/2009 SUNDAY
1/25/2009 SUNDAY
2/1/2009 SUNDAY
2/8/2009 SUNDAY
2/15/2009 SUNDAY
2/22/2009 SUNDAY
3/1/2009 SUNDAY
3/8/2009 SUNDAY
3/15/2009 SUNDAY
3/22/2009 SUNDAY
3/29/2009 SUNDAY
4/5/2009 SUNDAY
4/12/2009 SUNDAY
4/19/2009 SUNDAY
4/26/2009 SUNDAY
5/3/2009 SUNDAY
5/10/2009 SUNDAY
5/17/2009 SUNDAY
5/24/2009 SUNDAY
5/31/2009 SUNDAY
6/7/2009 SUNDAY
6/14/2009 SUNDAY
6/21/2009 SUNDAY
6/28/2009 SUNDAY
7/5/2009 SUNDAY
7/12/2009 SUNDAY
7/19/2009 SUNDAY
7/26/2009 SUNDAY
8/2/2009 SUNDAY
8/9/2009 SUNDAY
8/16/2009 SUNDAY
8/23/2009 SUNDAY
8/30/2009 SUNDAY
9/6/2009 SUNDAY
9/13/2009 SUNDAY
9/20/2009 SUNDAY
9/27/2009 SUNDAY
10/4/2009 SUNDAY
10/11/2009SUNDAY
10/18/2009SUNDAY
10/25/2009SUNDAY
11/1/2009 SUNDAY
11/8/2009 SUNDAY
11/15/2009SUNDAY
11/22/2009SUNDAY
11/29/2009SUNDAY
12/6/2009 SUNDAY
12/13/2009SUNDAY
12/20/2009SUNDAY
12/27/2009SUNDAY
Regards
Thiyag -
Need Sql Query that Suppress the repeating rows.
Hi Sir,
I have below data set.
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
10 2450 1300
10 5000 1300
20 800 800
20 1100 800
20 2975 800
20 3000 800
30 800 800
30 1100 800
30 2975 800
40 3000 800
40 4000 900
I Need SQL query that can remove the duplicate or suppress.Just like below data set.
Output:
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
2450 1300
5000 1300
20 800 800
1100 800
2975 800
3000 800
800 800
30 1100 800
2975 800
40 3000 800
4000 900
Could you please help me on this..Your requiremnt is more of a reporting request which should not be handled in SQL. For example in SQL Plus you can use the BREAK command
SQL> break on deptno
SQL> select deptno, ename from emp order by deptno;
DEPTNO ENAME
10 KING
CLARK
20 JONES
SCOTT
SMITH
ADAMS
30 TURNER
MARTIN
WARD
ALLEN
BLAKE
11 rows selected.
SQL>
But if you still wish to do it in SQL you can use ROW_NUMBER analytic function and achieve it like this
select decode(rno, 1, deptno) deptno
, ename
from (
select row_number() over(partition by deptno order by ename) rno
, deptno
, ename
from emp -
Using SQL Query for page item source does not insert populated value
Hi All,
Following are the attribute details of a certain page item on an edit form:
Display As: Text Field
Page Item Source Type: SQL Query
Source value Expression: SELECT a from tab where id = 'ABC'
Although the field appears populated on the screen, but the value is not inserted in the table.
Can anyone help on this?
Thanks in advance,
AnnieAnnie:
One solution is to define a pl/sql function that given a date will return the 'run-date'. Something like create or replace function get_prod_date(p_date in date) return date is
retval date;
begin
select run_date into retval from tab_x where run_date=p_date;
return retval;
end;Change the Source Type for the page-item back to 'Database Column'
Set Source value or expression to the 'database column name'
Set 'Post calculation computation' to be
get_prod_date(:pxx_date)
Varad -
Report- Pl/sql function returning sql query parsing page items as text?
Hi Team,
I am facing a strange issue .
I have four page items namely
1)JOB_CODE
2)MIN_EXP
3) MAX_EXP
4) SOURCES1
I have a report of the type "Pl/sql function returning sql query"
declare
v_sql varchar2(4000);
begin
if (:JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql:= 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:JOB_CODE IS NULL and :MIN_EXP IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MIN_EXP IS NULL and :JOB_CODE IS NOT NULL and :MAX_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where v_experience_years <= :MAX_EXP and V_REQUIREMENT = :JOB_CODE and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
elsif (:MAX_EXP is null and :JOB_CODE IS NOT NULL and :MIN_EXP IS NOT NULL and :SOURCES1 IS NOT NULL) then
v_sql := 'select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and source like ' || '''' || '%'|| ':SOURCES1' || '%' || '''';
end if;
insert into query_list values (v_sql);
insert into debug values (:JOB_CODE , :MIN_EXP , :MAX_EXP , :SOURCES1);
return v_sql;
end;
Please not that I am insertin the query into a table called Query_list and the page item values into the table called Debug thru the pl/sql function which returns teh query.
Now I select the data from the debug tables.
select unique(query) from query_list;
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = :JOB_CODE and v_experience_years >= :MIN_EXP and v_experience_years <= :MAX_EXP and source like '%:SOURCES1%'
select * from debug;
JOBCODE MINEX MAXEX SOURCE
21 1 10 donkeyHire
And if I run the query in sql I get some records returned
select v_candidate_id, v_fname,v_current_employer,v_Experience_years from candidature where V_REQUIREMENT = 21 and v_experience_years >= 1 and v_experience_years <= and source like 'donkeyHire'
V_CANDIDATE_ID V_FNAME V_CURRENT_EMPLOYER V_EXPERIENCE_YEARS
2 Vengu Andale Tech 4
But the record does not show up in the report!
does this type of report parse page items as text?
Why is it so?
Waiting for an early reply.
Thanks,
venkatVenkat - You don't want to put ':SOURCES1' in quotes like that.
Scott -
How to overcome the standard program check that changes my input file data?
Hi
when we r uploading PO thru bapi_po_create1, we give tax codes in the input file...but when the code gets into this MM06EFKO_PREISFINDUNG include of SAPLMEPO, there is a logic that changes the tax code (ekpo-mwskz = tkomv-mwsk1) and hence it gets reflected in the PO created...is there any way where i can by pass this one for the POs that i create thru my prog...pl shed some light on this
Sathish Renter the program name in the SE38 editor
click on copy button
then it will ask you for the new name
when ever you click on the copy transfer buton
then it will raise a pop and saying that what ever you want from the program like
1) INCLUDES
2)SCREENS
3)USER INTERFACES
4)VARIANTS
5) DOCUMANTATION
ETC..
hat ever you clcik on that check box
thats all
rewar dif usefull -
Get column names into a VB program, for an SQL query that joins tables
use [mydatabase]
select * from InvNum inum
left join _btblInvoiceLines ilin
on inum.autoindex = ilin.iinvoiceid
left join stkitem s
on ilin.istockcodeid = s.stocklink where InvNumber = 'IVQ0834' or InvNumber = 'IVQ0835'
I need to get out the column names in a VB program in the same order they would appear in the SQL query above...
I want to use something like:
select column_name from information_schema.columns where TABLE_NAME = ....
except there are several tables involved above so I dont know the format!If you execute the query in your program using the SqlDataReader.ExecuteReader method, the column names will be available via the GetName method of the returned reader. But note that your query may return multiple columns with the same name.
Dim reader As SqlDataReader = command.ExecuteReader()
For x = 0 To reader.FieldCount - 1
Console.WriteLine(reader.GetName(x))
Next x
Dan Guzman, SQL Server MVP, http://www.dbdelta.com -
SQL query in some item.
I have a string item with this example value:
"SELECT 1 FROM dual"
Yes, this is SQL query.
Now I want to create PDF Report (Shared Components > Report Queries...) based on this SQL. I want to use this item (exactly, value from this item).
How can I do it? Is this possible?
regards,
JarekHello,
You can’t use “dynamic” SQL query within the Report Queries technique.
You can use, as Luis suggested, a report region based on function returning query, in order to construct your SQL query. You can read some more details in the following:
Re: ApEx PDF printing with Advanced support.
Re: Dynamic Column in SQL-Statement
Hope this helps,
Arie. -
PL/SQL query that has a link to other website
I want to do a query that list books info (Date published, name, category, etc). The part I can't figure out is how would I create an HTML link on the "Name?" The website is on a separate server (i.e. http://mybookstore.com). The links are in the table with the Name and category.
I would like to use PL/SQL or Java (but prefer PL/SQL).
Any help would be appreciated.
KenHi Ken,
try the following for the query .....
select category , <A href = 'target_page'>name </A>, date_published from table_name;
Where exactly you want to use the query ... Is it for a report in Portal ...
Regds..
Sajith -
SQL query that returns exclusive rows from groups
I'm using modified scott/tiger data for this.
I've got two tables
DEPT_X
DEPTNO DNAME LOC CODE_ID SUB_DEPTNO
10 ACCOUNTING NEW YORK 111 101
10 SALES ATWN 111 102
10 SALES BTWN 112 103
20 RESEARCH DALLAS 111 201
20 RESEARCH CTWN 111 202
30 SALES CHICAGO 111 301
40 OPERATIONS BOSTON 112 401and
BI_PD
CODE_ID PD_TYPE BI_TYPE
111 -1
112 -1 I want to write a query that joins the code_ids of the two tables and lists out either only the records from DEPT_X who's code_ids have a -1 in the PD_TYPE(112) column and none of the code_ids that have a -1 in the BI_TYPE(111) column for each department or if that department has code_ids for the BI_TYPE (111), list out those rows. So for Deptno 10 you'll only get the row with SUB_DEPTNO = 103. But if for that DEPTNO= 20 you'll get the rows for both SUB_DEPTNO = 201 and 202.
So the result should look like
DEPTNO SUB_DEPTNO
10 103
20 201
20 202
30 301.
Basically I just want rows from each department that have code_ids = 111 not to show up if there are code_ids = 112.
What is the query to do this?
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359One way could be:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> with dept_x as (
2 select 10 deptno, 'ACCOUNTING' dname, 'NEW YORK' loc, 111 code_id, 101 sub_deptno from dual
union all
3 select 10, 'SALES', 'ATWN', 111, 102 from dual union all
4 select 10, 'SALES', 'BTWN', 112, 103 from dual union all
5 select 20, 'RESEARCH', 'DALLAS', 111, 201 from dual union all
6 select 20, 'RESEARCH', 'CTWN', 111, 202 from dual union all
7 select 30, 'SALES', 'CHICAGO', 111, 301 from dual union all
8 select 40, 'OPERATIONS', 'BOSTON', 112, 401 from dual ),
9 --
10 bi_pd as(
11 select 111 code_id, null pd_type, -1 bi_type from dual union all
12 select 112, -1, null from dual),
13 --
14 t as(
15 select a.deptno,a.sub_deptno from dept_x a, bi_pd b
16 where a.code_id = b.code_id and b.pd_type = -1)
17 --
18 select a.deptno,a.sub_deptno
19 from dept_x a, bi_pd b
20 where a.code_id = b.code_id and b.bi_type = -1 and
21 (a.deptno) not in (select deptno from t)
22 union
23 select deptno,sub_deptno from t;
DEPTNO SUB_DEPTNO
10 103
20 201
20 202
30 301
40 401 -
GREP query that changes to character format
I am trying to create a GREP query that finds a single capital letter K surrounded by parenthesis -- like this: (K). I was able to get that far, so that in the GREP Find What I have \(K\)
I need to change this to (K) with only the letter K changing to a different font or character style; the parenthesis need to remain in the same font as before, matching the rest of the paragraph. I see that I can change the format in the GREP dialog, but if I do, it changes the format of the parenthesis as well as the K. The font that I need to change the K to is a picture font.
If anyone can help with a suggestion on this, I'd really appreciate it.Positive Lookbehind/Lookahead. This GREP expression
(?<=\()K(?=\))
does the trick. I've coloured the different parts: red is the lookbehind, green is the lookahead, black is regular text.
In essence, it finds (selects) any capital K which is preceded and succeeded by parentheses. Replace with what you like -- the parentheses are not touched.
It's useful to know there is also a negative lookbehind/lookahead. The expression
(?<!\()K(?!\))
will find any capital K except those surrounded by parentheses. -
SQL- Query that return only one record
Hello,
is it possible to execute a pure SQL-Query which returns only one row although multiple rows are found.
It is no problem in PL/SQL, but I have no idea if the same is also possible in SQL.
thanks in advance
MichaelWhy not? There are 4 records in this table, but only selected one.
SQL> with t
2 as
3 (
4 select '#%$@#$@$@##$' Addr from dual
5 union all
6 select '18 Jalan Scott' from dual
7 union all
8 select '18 Lemana St' from dual
9 union all
10 select '32-penstation' from dual
11 union all
12 select '99999999999' from dual
13 )
14 select addr
15 from t
16 where rownum =1
17 /
ADDR
#%$@#$@$@##$
SQL>Cheers
Sarma.
Maybe you are looking for
-
II've just created a new apple Id & account but when I try to download an app the box that appears on your I pad defaults back to my old apple id to which I had to close down as this was a mail address that got hacked. how do I change this to show my
-
Hi All, How do I get Vendors maintained ONLY in a certain Company Code? MKVZ only shows vendors listed in Purchasing Orgs. Is there another std report users can run to see a list of vendors in CoCd? Thanks in advance.
-
Report for equipment hierarchy using IH03
In IH03 what is the significance of the fields display as graphic and Bom Application and Bom group? Edited by: Pallavi Kakoti on Jul 19, 2011 8:43 AM
-
Hi, I am using WLPI. I need to define the data access layer. As workflows deal in XML and for JDBC calls I need value objects. I have few questions: Is there any proffered way of communication between BPM and database? Does BEA/Sun/BPM Users recommen
-
Number filter error emerged when updating OBIEE to 10.1.3.4
After updating OBIEE version to 10.1.3.4. one more bug-like situation was discovered. we have an a double column. in Admin tool it was designated as double. If shown in a report it is correctly shown as double number. but when i tried to make a filte