How to use "with clause query" in DBadapter
Hi all,
I need to implement a "with clause" query in oracle soa 11g bpel. When i put the query in db adapter in pure sql, the schema is not getting generated properly. Can any one suggest a solution to my problem.
Regards,
Kaushik
Pure SQL won't work because it is expecting the first word in the SQL to be SELECT (or INSERT,UPDATE,DELETE).
If your query is WITH ... SELECT ...
try this:
delete everything before SELECT. Copy and paste the generated XSD to another window. The SQL test may fail, but that will just mean that it couldn't fill in the types of the columns in the SELECT ... FROM list. You can always do that yourself by hand editing the XSD (including in the wizard before you hit next). Then put back the WITH ... clause before the remaining SELECT .... If the XSD gets overwritten, copy the version you saved in the other window and paste it over top. Then hit next and the runtime should still work.
Keep in mind that SQL is very complex and hard to fully parse in the UI. However the minimum information the DbAdapter needs is quite limited; basically just the name and number of columns that are coming back. The XSD is meant to be editable in the wizard if the SQL is too complex.
Thanks
Steve
Similar Messages
-
Please help how to use WITH query in UPDATE
Hi Experts,
Please help me.
Thanks.Not sure about your required output. But try using WITH clause query inside SET clause of UPDATE statement.
UPDATE SALES_REVENUE SR
SET
(SR.TODAY_REV,
SR.TODAY_MARGIN,
SR.TODAY_UNIT
) =
(WITH result_sum_temp
AS(
SELECT SALE_ID, IN_TEAM, 1 SALE_FLAG, loc, seg,
SUM(REV * rate) AS sum_rev,
SUM(MARGIN * rate) AS sum_mar,
SUM(UNIT) AS SUM_UNIT
FROM SALES
WHERE (IGNORED IS NULL OR IGNORED <> 'Y')
AND SALE_SPOT = 7
AND SALE_ID = 375
AND SALE_MODEL = 'D'
AND IN_TEAM IS NOT NULL AND loc IS NOT NULL
GROUP BY SALE_ID, IN_TEAM, loc, seg
UNION ALL
SELECT SALE_ID, OUT_TEAM, 2 SALE_FLAG, loc, seg,
SUM(REV * rate) AS sum_rev,
SUM(MARGIN * rate) AS sum_mar,
SUM(UNIT) AS SUM_UNIT
FROM SALES
WHERE (IGNORED IS NULL OR IGNORED <> 'Y')
AND SALE_SPOT = 2
AND SALE_ID = 375
AND SALE_MODEL = 'D'
AND OUT_TEAM IS NOT NULL AND loc IS NOT NULL
GROUP BY SALE_ID, OUT_TEAM, loc, seg)
(SELECT t.sum_rev, t.sum_mar, t.sum_unit
FROM result_sum_temp t
WHERE SR.SALE_ID = t.SALE_ID
AND SR.team_id = t.team_id
AND SR.SALE_FLAG = t.SALE_FLAG
AND SR.SEG = t.seg
AND SR.loc = t.loc
AND t.SALE_ID = 255)
WHERE SR.SALE_SPOT = 890
AND SR.SALE_ID = 255
AND (SR.SALE_ID, SR.team_id, SR.sale_flag, SR.SEGMENT, SR.LOB) IN
(SELECT SALE_ID,
team_id,
sale_flag,
seg,
loc
FROM result_sum_temp)); -
'Missing select' error for update statement using WITH clause
Hi,
I am getting the below error for update statement using WITH clause
SQL Error: ORA-00928: missing SELECT keyword
UPDATE A
set A.col1 = 'val1'
where
A.col2 IN (
WITH D AS
SELECT col2 FROM
(SELECT col2, MIN(datecol) col3 FROM DS
WHERE <conditions>
GROUP BY PATIENT) D2
WHERE
<conditions on A.col4 and D2.col3>Hi,
The format of a query using WITH is:
WITH d AS
SELECT ... -- sub_query
SELECT ... -- main query
You don't have a main query. The keyword FROM has to come immediately after the right ')' that ends the last WITH clause sub-query.
That explains the problem based on what you posted. I can't tell if the real problem is in the conditions that you didn't post.
I hope this answers your question.
If not, post a complete test script that people can run to re-create the problem and test their ideas. Include a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002 -
WITH Clause query doesn't work in Oracle Reports.
Hi Gurus,
I'm using a WITH clause query and need to build a report using the same query.
But when i'm trying to build a report, query is giving error as "WITH clause table or view doesn't exists".
But the same query perfectly works in sql prompt.
Oracle Reports doesn't supports WITH clause query?
Please suggest.
Thanks,
OnkarI ran into a similar problem before and worked around it by moving the query to a pipelined function in the database as described at WITH clause unexpectedly causes ORA-00942 in Reports Builder
Hope this helps. -
I have an update statement that is using the same suquery twice.
I am not usre if WITh clause be used in update statements?
Is there a way the below statement can be modified to use WITH clause?
UPDATE EMP_TRACKING_LIST L
SET ACTIVE_FLAG = DECODE((SELECT COUNT(*)
FROM EMP_TRACKING_LIST L2
WHERE L.NAME = L2.NAME AND
L.EMP_CODE = L2.EMP_CODE AND
L2.EMP_FLAG = 'Y'), 0, 'N', 'Y')
WHERE ACTIVE_FLAG != DECODE((SELECT COUNT(*)
FROM EMP_TRACKING_LIST L2
WHERE L.NAME = L2.NAME AND
L.EMP_CODE = L2.EMP_CODE AND
L2.EMP_ACTIVE_FLAG = 'Y'), 0, 'N', 'Y')
OR EMP_ACTIVE_FLAG IS NULL;
I would really appreciate your input
Edited by: user10937534 on Sep 2, 2009 4:47 PMHi,
WITH comes immediately before SELECT, not before UPDATE.
To use WITH in an UPDATE statement, you would say something like:
UPDATE EMP_TRACKING_LIST L
SET ACTIVE_FLAG =
WITH sub_q AS
SELECT ...
SELECT ...
FROM sub_q ...
;I don't think there's any way to use values from the sub-query in the WHERE clause of the UPDATE statement itself; MERGE is a much better bet for eliminating redundancy there.
Sorry, I'm not at a database now, so I can test anything. -
How to use From clause as a block datasources
Hi,
I want to know how to use from clause as a block datasource.
Could anyone give me an example to do that? I couldn't find it
in the help file.
I sincerely ask someone help me.
Many thanks
DianaDiana,
I presume you are getting a "FRM-40505: error unable to perform
query" when you try to execute query. I suggest you select the
"Display Error" item from the "Help" menu to see the query that
Oracle is generating. If the query that Oracle generates as a
result of your "Query data source name" is not formed correctly,
you will get the FRM-40505 error.
Copy and paste the query that is displayed into SQLPLUS and test
to see what happens when you try to execute the query from
SQLPLUS. That will give you a better idea of what the cause of
the problem is.
From your example, a query that works should look like "select
c_no from (select c_no from books)".
Keep in mind that for blocks based on FROM clause, the query that
produces the data is of the form :
SELECT <all columns in the block>
FROM <select statement entered in the "Query Data Source Name"
blockproperty>
The data source for the block is the select statement embedded in
the from clause.
Hope this helps. -
Can any one tell me how to use EXISTS clause inplace of IN operator.
Hi All,
Can any one tell me how to use EXISTS clause AND (JC.EMPL_ID, JC.EMPL_RCD) inplace of IN operator.
SELECT COUNT (1)
FROM SYSADM.OHR_PERS_CURR PC
, SYSADM.OHR_JOB_CURR JC
WHERE PC.EMPL_ID = JC.EMPL_ID
AND (JC.EMPL_ID, JC.EMPL_RCD) in (
SELECT HS.EMPL_ID, HS.EMPL_RCD
FROM SYSADM.HU_SCRTY_JOB HS, ODSHR.OHR_SCRTY_USER_CFG OS
WHERE HS.HU_SCRTY_CFG_ID = OS.HU_SCRTY_CFG_ID
AND OS.DB_LOGIN = USER)
Thank you.SELECT COUNT (1)
FROM SYSADM.OHR_PERS_CURR PC
, SYSADM.OHR_JOB_CURR JC
WHERE PC.EMPL_ID = JC.EMPL_ID
AND EXISTS (
SELECT null
FROM SYSADM.HU_SCRTY_JOB HS, ODSHR.OHR_SCRTY_USER_CFG OS
WHERE HS.HU_SCRTY_CFG_ID = OS.HU_SCRTY_CFG_ID
AND OS.DB_LOGIN = USER
AND HS.EMPL_ID = JS.EMPL_ID AND HS.EMPL_RCD = JC.EMPL_RCD)
But why ?
Rgds. -
HOW TO USE "WITH" STATEMENT IN MESSAGES
MESSAGE e001 WITH WERKS SY-REPID
TELL ME HOW TO USE "WITH" IN MESSAGES SEND SYANTAX AND EXAMPLE CODEMessages e001(zz) with Var1 var2 var3.
For this statement to be valie, the variables var1 var2 var3 should be defined alrteady in the program.
and in se91, you should define a message class (Say ZZ ).
In that message class you can create a message with number (Say 001) with place holders (&).
001: & is a sampele message for & hgh & hjknkn
The & will get replaced by the variables var1 var2 var3 in the run time.
YOu can also create success messages if yo say:
Messages S001(zz) with Var1 var2 var3.
Information
Messages I001(zz) with Var1 var2 var3.
Warning:
Messages W001(zz) with Var1 var2 var3.
Abend:
Messages a001(zz) with Var1 var2 var3.
REFER sample programs : DEMO_MESSAGES
DEMO_MESSAGES_SIMPLE
Regards,
Ravi
Message was edited by:
Ravi Kanth Talagana -
Construct a Sql block using With Clause to improve the performance
I have got four diff parametrized cursor in my Pl/Sql Procedure. As the performance of the Procedure is very pathetic,so i have been asked to tune the Select statements used in those cursors.
So I am trying to use the With Clause in order to club all those four Select Statements.
I would appreciate if anybody can help me to construct the Sql Block using With Clause.
My DB version is..
Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
PL/SQL Release 11.1.0.7.0 - Production
Four Diff cursors are defined below.
CURSOR all_iss (
b_batch_end_date IN TIMESTAMP,
IS
SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND ewo_no IN
(SELECT TO_CHAR(wo_no)
FROM MGO_PLANT_AUDIT
WHERE dml_status = 'U' OR dml_status = 'I')
UNION ALL
SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
b_batch_end_date;
CURSOR ewo_plant ( p_ewo_no IN IMPLMN_STEP_BREKPN.ewo_no%TYPE)
IS
SELECT DISTINCT wo_no ,
plant_code
FROM MGO_PLANT
WHERE TO_CHAR(wo_no) = p_ewo_no;
CURSOR iss_ewo_plnt (
p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
IS
SELECT *
FROM IMPLMN_STEP_BREKPN
WHERE issue_id = p_issue_id
AND ewo_no = p_ewo_no
AND
(plt_faclty_id = p_plnt_code
OR
plt_faclty_id IS NULL);
CURSOR iss_ewo_plnt_count (
p_issue_id IN IMPLMN_STEP_BREKPN.issue_id%TYPE ,
p_ewo_no IN IMPLMN_STEP_BREKPN.EWO_NO%TYPE,
p_plnt_code IN IMPLMN_STEP_BREKPN.PLT_FACLTY_ID%TYPE)
IS
SELECT COUNT(*)
FROM IMPLMN_STEP_BREKPN
WHERE issue_id = p_issue_id
AND ewo_no = p_ewo_no
AND
(plt_faclty_id = p_plnt_code
OR
plt_faclty_id IS NULL);Not tested. Some thing like below. i just made the queries as tables and given name as a,b,c and substituted columns for the parameters used in the 2nd cursor and third cursor. Try like this.
CURSOR all_iss (
b_batch_end_date IN TIMESTAMP,
IS
select a.*,b.*,c.* from
( SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND ewo_no IN
(SELECT TO_CHAR(wo_no)
FROM MGO_PLANT_AUDIT
WHERE dml_status = 'U' OR dml_status = 'I')
UNION ALL
SELECT isb.*
FROM IMPLMN_STEP_BREKPN isb
, ISSUE iss
WHERE isb.issue_id = iss.issue_id
AND iss.issue_status_id = 50738
AND CAST (isb.last_updt_timstm AS TIMESTAMP) >=
b_batch_end_date) a,
( SELECT DISTINCT wo_no ,
plant_code
FROM MGO_PLANT
WHERE TO_CHAR(wo_no) = p_ewo_no) b,
( SELECT *
FROM IMPLMN_STEP_BREKPN
WHERE issue_id = p_issue_id
AND ewo_no = p_ewo_no
plt_faclty_id IS NULL) c
where b.wo_no = c.ewo_no and
c.issue_id = a.issue_id ;
vinodh
Edited by: Vinodh2 on Jul 11, 2010 12:03 PM -
How to use WMI to query to distinguish legacy and UEFI mode Windows?
How to use WMI to query to distinguish legacy and UEFI mode Windows?
This document covers requirements for UEFI support.
http://msdn.microsoft.com/en-us/windows/hardware/gg463144.aspx
One of the requirements seems to be ACPI. The Win32_BIOS class of WMI has a BIOSCharacteristics property that indicates if ACPI is supported. See this link for properties exposed by Win32_BIOS:
http://msdn.microsoft.com/en-us/library/aa394077(v=VS.85).aspx
There is a PowerShell example showing how to get this information at the bottom. You will need to study the document in the first link to see what else is required.
Richard Mueller - MVP Directory Services -
How to use hint on with clause query
Hi all,
I have a query and it consits full of tabs with WITH clause. Top level I am just selecting all the tabs (queries with WITH clause) by saying select * from tab1,tab2,.....so on .
Now my question is If I want to use hint on my SQL can I use the same by using tab1,tab2...
tab1, tab2 are not actually tables ....each tab represents one SQL with WITH clause.
Please let me know if there is any confusion on my post.What's stopping you from trying it yourself?
Post your results here to help others. -
How to use where clause with get statement in LDB programs
Hi All,
I am using logical databse in my report program.I am not getting how to use the where clause in the get statement is it possible to use?or if not possible only option is we should filter it after get statment is right?Can you please some body throw some idea on this?
Regards
MaheshHi,
Reffer these links
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm
http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm
http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm
/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases
reward if helpful
Thanks,
Suma. -
How to use one af:query for multiple VOs
Hi all,
How can we use an af:query component to query on multiple VOs?
Think of a page with search area and a tabbed pannel with two tables based on different view objects.
Any ideas?
Thanks
Version
ADF Business Components 11.1.1.56.60
Java(TM) Platform 1.6.0_18
Oracle IDE 11.1.1.3.37.56.60
Edited by: Barbara Gelabert on 28-dic-2010 6:55Hi Santosh,
Not yet implemented, but I was thinking on overriding the query listener and creating a view critera on the second view object as a copy of the first one. That involves capturing operands, operators and values set and then applying the criteria and executing the query.
Anyway, in case you don't need complex operators in the search area but can add them as where clauses to the query statement, you can use search forms instead of query components as Shay Shmeltzer suggests in [url http://blogs.oracle.com/shay/2010/12/combining_multiple_queries_and.html?goback=.gde_1002457_news_308820955]his post.
Regards,
Barbara -
How to use WHERE Clause in BPEL
Hi ,
i am trying to use where clause in DB adapter but its not working.
my query is "select empname from employee where empid = &a"
can any body tell me what is the reason its npt working?
and how can i retrive data form DB?Hi,
You are thinking perfectly fine. The solution what I suggested was
select ename from emp where empno=?
And the solution provided by you was
SELECT first_name, last_name FROM per_all_people_f WHERE person_id = #p_person_id
There is no problem with the above mentioned select statements.
I just want to say that if you see closely, internal logic changes #parameter name to ?. So both the logics are right.
Cheers,
Abhi... -
WITH clause query:- Returns No Rows
Hi,
I am using the following query with, WITH clause, but some how it give "0 rows" returned,
The underlying query does returns row when run in stand alone mode,
With v_score_his_old
As
SELECT schs_run_date,schs_loc_shortcut_source,schs_lot_number,schs_facility_new,schs_facility_old, schs_operation_new,
schs_operation_old,schs_route_new,schs_route_old,schs_product_new,schs_product_old,schs_owner_old,schs_intransit,
schs_date,schs_transaction,schs_quantity_1_new,schs_quantity_1_old,/*0,*/schs_if_count_new,schs_if_count_old,
schs_preprocessed,schs_consumed_quantity,/*'Y',*/schs_if_id,schs_if_id_old,fif_fac_loc_id
FROM scm_score_his,full_item_facilities,location_params
WHERE schs_state = 0
AND fif_if_id = schs_if_id_old
AND lopo_param_value = to_char(fif_site_id_fm)
AND lopo_param_name IN ('SITE_FAB', 'SITE_SORT')
AND (schs_loc_shortcut_source = 'MP' OR schs_loc_shortcut_source = 'RE' OR schs_loc_shortcut_source = 'VI')
UNION ALL
SELECT schb_run_date,schb_loc_shortcut_source,schb_lot_number,schb_facility_new,schb_facility_old,schb_operation_new,
schb_operation_old,schb_route_new,schb_route_old,schb_product_new,schb_product_old,schb_owner_old,schb_intransit,
schb_date,schb_transaction,schb_quantity_1_new,schb_quantity_1_old,/*0,*/schb_if_count_new,schb_if_count_old,schb_preprocessed,
schb_consumed_quantity,/*'Y',*/schb_if_id,schb_if_id_old,fif_fac_loc_id
FROM scm_score_his_backups,full_item_facilities,location_params
WHERE schb_state = 0
AND fif_if_id = schb_if_id_old
AND lopo_param_value = to_char(fif_site_id_fm)
AND lopo_param_name IN ('SITE_FAB', 'SITE_SORT')
AND schb_date >= trunc(sysdate - 84)
AND (schb_loc_shortcut_source = 'MP' OR schb_loc_shortcut_source = 'RE' OR schb_loc_shortcut_source = 'VI')
Select schs_run_date,schs_loc_shortcut_source,schs_lot_number
From v_score_his_old
Where schs_loc_shortcut_source = 'MP';
Oracle version is Oracle9i Enterprise Edition Release 9.2.0.6.0
I am not able to get where I can going wrong.
Please help me to understand this issue,
Regards
Umesh..With v_score_his_old
As
SELECT
schs_run_date,schs_loc_shortcut_source,schs_lot_numbe
,schs_facility_new,schs_facility_old,
schs_operation_new,
chs_operation_old,schs_route_new,schs_route_old,schs_p
roduct_new,schs_product_old,schs_owner_old,schs_intran
sit,
chs_date,schs_transaction,schs_quantity_1_new,schs_qua
ntity_1_old,/*0,*/schs_if_count_new,schs_if_count_old,
chs_preprocessed,schs_consumed_quantity,/*'Y',*/schs_i
f_id,schs_if_id_old,fif_fac_loc_id
FROM
cm_score_his,full_item_facilities,location_params
WHERE schs_state = 0
AND fif_if_id = schs_if_id_old
AND lopo_param_value =
to_char(fif_site_id_fm)
AND lopo_param_name IN ('SITE_FAB',
'SITE_SORT')
AND (schs_loc_shortcut_source = 'MP' OR
schs_loc_shortcut_source = 'RE' OR
schs_loc_shortcut_source = 'VI')
UNION ALL
SELECT
schb_run_date,schb_loc_shortcut_source,schb_lot_number
,schb_facility_new,schb_facility_old,schb_operation_ne
w,
chb_operation_old,schb_route_new,schb_route_old,schb_p
roduct_new,schb_product_old,schb_owner_old,schb_intran
sit,
chb_date,schb_transaction,schb_quantity_1_new,schb_qua
ntity_1_old,/*0,*/schb_if_count_new,schb_if_count_old,
schb_preprocessed,
chb_consumed_quantity,/*'Y',*/schb_if_id,schb_if_id_ol
d,fif_fac_loc_id
FROM
cm_score_his_backups,full_item_facilities,location_par
ams
WHERE schb_state = 0
AND fif_if_id = schb_if_id_old
AND lopo_param_value =
to_char(fif_site_id_fm)
AND lopo_param_name IN ('SITE_FAB',
'SITE_SORT')
AND schb_date >= trunc(sysdate - 84)
AND (schb_loc_shortcut_source = 'MP' OR
schb_loc_shortcut_source = 'RE' OR
schb_loc_shortcut_source = 'VI')
ect
schs_run_date,schs_loc_shortcut_source,schs_lot_number
From v_score_his_old
Where schs_loc_shortcut_source = 'MP';
Hi!
I've a doubt. If u finally picking all the values which matched with field schs_loc_shortcut_source and which is 'MP' - then why r u using multiple condition in the WITH part? So, in that case, u don't have to write that additional filtering of the following lines in the outer query -
Where schs_loc_shortcut_source = 'MP';Regards.
Satyaki De.
Maybe you are looking for
-
Windows Deployment Service. Network Profile Radio Buttons greyed out with R2
Hi All I have downloaded and setup Server 2008 R2 (not yet activated). I have added the following roles "DHCP Server", "DNS Server", "Active Directory Domain Services" and "Windows Deployment Services". I can PXE boot a test client machine and (using
-
Error installing Camera Raw 7.2 Update
I am trying to install the Camera Raw 7.2 Update for Photoshop CS6. When I try to install I get this error message: Photoshop Camera Raw 7.2 There was an error installing this update. Please quit and try again later. Error Code: U44M2I218 I have rebo
-
IPhoto '11 vs. Aperture 3 for Jumbo Library?
My iPhoto library has 58,674 photos (196 GB large). It seems to get slower and slower. If I switch to Apeture 3 will I get any speed/performance gains? If not are there any other ways to speed up my sluggish library?
-
Open Dataset No Authority runtime error
Hi friends I am getting error like this No Authorization to open the file 'HCM_PAYROLL_MDATA_IT2010.LSMW.READ'. Can anyone help me . whay i am getting . Error in the abap program /1cadmc/sap_lsmw_read_00000036' had to be terminated coz it has come cr
-
Which bars and tones to use? Generic Slate setup?
Newbie here Can someone please tell me the proper order on how to setup the bars/tones/slate before a 30 second TV spot. There are several options within FCP, which one do i use? I am sending 16:9 HDV footage (1080i60) to mini DV to be broadcast as S