Pure SQL Select in BPEL 10.1.2.0.2
I'm running BPEL 10.1.2.0.2 with a DBAdapter defined against an Oracle table, and am trying to perform a SELECT similar to the following:
SELECT A, B FROM MYTABLE #whereClause ORDER BY A, B
This is the definition of the raw SQL string in the toplink-mappings.xml file, which in all other respects is nearly a direct clone of the PureSQLSelect tutorial file in 122.DBAdapter. The parameter #whereClause is passed in from the BPEL process. Looking at my server logs, I see that the SELECT statement becomes
SELECT A, B FROM MYTABLE ? ORDER BY A, B
followed by
bind=[the_string_contents_I_passed_via_whereClause]
but the bind never seems to occur, because the select errors out with an ORA-00933 error.
What can I do to make this work?
Thanks for your time,
Paul Camann
<bump>
No one has a clue about how to make this work?
Similar Messages
-
Hi ,
I have configued DB Adapter to Pure SQL Select, passing input parameter CART_KEY to select line items. There 10 line items for accart key. In my case there are 10 different records for CART_KEY = 607340. it is selecting 10 records but same record of 10 times(not unique).
I am not sure, is it caching the record ? do i need to turn caching off ?
I have excuted the query from logs, it is selecting 10 rows.
<2006-07-11 10:46:26,009> <DEBUG> <default.collaxa.cube.ws> <Database Adapter::Outbound> <oracle.tip.adapter.db.TopLinkLogger log> SELECT ACTIVE_FLAG_H, ACTIVE_FLAG_L, ANNUAL_FLAG, CART_LINE_KEY FROM CMGT.VW_QMT_TO_OTM_SPR_DATA WHERE (CART_KEY = ?)
bind => [607340]<bump>
No one has a clue about how to make this work? -
Reg: SQL select Query in BPEL process flow
<p>
Hi,
I am suppose to execute a SQL select query (in BPEL Process flow) as mention below in JDeveloper using Database adapter.
</p>
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE ITEM= <xyz>
</p>
<p>
AND OBJECT= (SELECT CASE_NAME FROM CUBE_SUPPLIER WHERE ITEM=<xyz> AND SUPP_IND = ‘Y')
<strong>Now my question is:
1.</strong> What does this "*" refer to in the query and how can I retrieve the value of LENGTH*WIDTH* HEIGHT from the query where LENGTH,WIDTH and HEIGHT are the individual field in the table.
2.What does this " AS" refer to? If " ITEM_CUBE " is the alies for the table name "ITEM" to retrieve the value, then query shoud be evaluated as
</p>
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE <strong>ITEM_CUBE.ITEM</strong>= <xyz>
</p>
<p>
AND <strong>ITEM_CUBE.OBJECT</strong>= (SELECT CASE_NAME FROM CUBE_SUPPLIER WHERE ITEM=<xyz> AND SUPP_IND = ‘Y')
Is my assumption correct?
Please suggest asap.
Thanks...
</p>
<p>
</p>Hi
Thank for your reply!
I have a nested select query which performs on two different table as shown below:
<p>
SELECT LENGTH, WIDTH, HEIGHT, WEIGHT,
</p>
<p>
LENGTH*WIDTH* HEIGHT AS ITEM_CUBE
</p>
<p>
FROM CUBE
</p>
<p>
WHERE ITEM= <abc>
</p>
<p>
AND OBJECT= (SELECT NAME FROM SUPPLIER WHERE ITEM=<Item> AND SUPP_IND = ‘Y')
I am using DB adapter of Oracle JDeveloper in BPEL process flow, where I can able to select only one master table in DB adapter say SUPPLIER and its attributes at a time.But as per my requirment I need to select both the table (CUBE and SUPPLIER) in a single adapter to execute my query.
It can be achievable by using two DB adapter , One to execute the nested query and another to execute the main qyery considering value of nested query as a parameter.But I want to achieve it by using a single one.
Am I correct with my concept?
Please suggest how to get it ?
</p>
Edited by: user10259700 on Oct 23, 2008 12:17 AM -
Pure SQL of Select query on multiple tables in DB Adapter
I am trying use pure sql approach for a custom sql query on multiple tables for a DB adapter by modifying toplink_mappings.xml. But i am not getting other tables in my xsd. Please help.
hi Ravi,
can you pls be a bit clear? what is this about? where you are using?
thanks,
sneha. -
Pure SQL and Border Use Cases?
Hi Gurus
I was developing a DB Adapter to select data from Shipping tables. I did it by polling as well as with Custom SQL. While using the custom SQL I got the following error in my domain.log
(my query that I wrote) failes, Caused by java.sql.SQLException: Invalid column index.
The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the "Perform an operation on a table" option instead.
What is a border use case, how do I decide that. So BPEL support the custom sql option very loosely?
ThxThe thing is that XSLT often doesn't deliver the functionality required when it comes to times.
You suggest appening "Z" to the time but this means that the time is now in UTC time. What if the system from where the date is being converted is running in NZ using local time? Other systems that recieve the date (and correctly handle the time zone) will now have a time that is out by a number of hours.
You often can't ignore the time zone (drop the 'Z') as if you send the time to a system it has to either assume the time is local to it (which may not be the case... the other system coudl be in a different time zone) or assume the time is UTC (I think crossfire does this by default).
Typically can't just append a time zone (e.g. +11:00) either as many places have daylight savings so the value to appended is variable (you then need some way of determining what the value is... either Java Embedding or a Service).
As you mention it does depend on the use case but in many circumstances using Jaba Embedding, not as suggested above but with the appropriate Java.util.Calendar classes, is the best way to handle date and time in BPEL. Even still you need to ascertain the format of times external to the system and ensure you parse them correctly.
ANd even if you do all this you can still run into problems. I've seen a real world example where two systems which both handled time zones correctly and had previously been working together for quite a while, satrted reporting different times. It turns out that only one of them had had the most recent Java Time Zone patches applied and there had been a change in the dates for daylight savings here (Australia). Be warned! -
DB Adapter Package call vs Pure SQL call
Hi ,
We need to call few SQL select statements from BPEL via DB adapter. The SQL may fetch few thousands (1k to 50k possibly) records. We are now analyzing the possible pros and cons in terms of performance of DB Adapter package call vs direct pure SQL call.
Can you pleas give us any suggestion on it.
Regards,
Debanjanyou can use the code as per your requirement
but you need to do some performance tuning
http://biemond.blogspot.com/2010/08/things-you-need-to-do-for-owsm-11g.html -
Calculating values from row to row with pure sql?
Hello,
I'm searching for a way to calculate values from row to row with pure sql. I need to create an amortisation table. How should it work:
Known values at start: (they can be derived with an ordinary sql-statement)
- redemption amount RA
- number of payment terms NT
- annuity P (is constant in every month)
- interest rate IR
What has to be calculated:
First row:
RA1 = RA - P
Z1 = (RA1 * (IR/100/12))
T1 = P - Z1
2nd row
RA2 = RA1 - T1
Z2 = (RA2 * (IR/100/12))
T2 = P - Z2
and so on until NT has reached.
It should look like
NT
P
Tn
Zn
RAn
1
372,17
262,9
109,27
22224,83
2
372,17
264,19
107,98
21961,93
3
372,17
265,49
106,68
21697,74
4
372,17
266,8
105,38
21432,25
5
372,17
268,11
104,06
21165,45
6
372,17
269,43
102,75
20897,34
7
372,17
270,75
101,42
20627,91
8
372,17
272,09
100,09
20357,16
9
372,17
273,42
98,75
20085,07
10
372,17
274,77
97,41
19811,65
11
372,17
276,12
96,06
19536,88
12
372,17
277,48
94,7
19260,76
13
372,17
278,84
93,33
18983,28
14
372,17
280,21
91,96
18704,44
15
372,17
281,59
90,59
18424,23
16
372,17
282,97
89,2
18142,64
17
372,17
284,36
87,81
17859,67
18
372,17
285,76
86,41
17575,31
19
372,17
287,17
85,01
17289,55
20
372,17
288,58
83,59
17002,38
21
372,17
290
82,18
16713,8
22
372,17
291,42
80,75
16423,8
23
372,17
292,86
79,32
16132,38
24
372,17
294,3
77,88
15839,52
25
372,17
295,74
76,43
15545,22
26
372,17
297,2
74,98
15249,48
27
372,17
298,66
73,52
14952,28
28
372,17
300,13
72,05
14653,62
29
372,17
301,6
70,57
14353,49
30
372,17
303,09
69,09
14051,89
31
372,17
304,58
67,6
13748,8
32
372,17
306,07
66,1
13444,22
33
372,17
307,58
64,6
13138,15
34
372,17
309,09
63,08
12830,57
35
372,17
310,61
61,56
12521,48
36
372,17
312,14
60,04
12210,87
37
372,17
313,67
58,5
11898,73
38
372,17
315,21
56,96
11585,06
39
372,17
316,76
55,41
11269,85
40
372,17
318,32
53,85
10953,09
41
372,17
319,89
52,29
10634,77
42
372,17
321,46
50,71
10314,88
43
372,17
323,04
49,13
9993,42
44
372,17
324,63
47,55
9670,38
45
372,17
326,22
45,95
9345,75
46
372,17
327,83
44,35
9019,53
47
372,17
329,44
42,73
8691,7
48
372,17
331,06
41,11
8362,26
I would appreciate every help and idea to solve the problem solely with sql.
Thanks and regards
CarstenIt's using Model Clause and / or Recursive With (sometimes maybe both)
Regards
Etbin
with
rec_proc(nt,i,ra,p,ir,z,t) as
(select nt,i,ra - p,p,ir,round((ra - p) * 0.01 * ir / 12,2),p - round((ra - p) * 0.01 * ir / 12,2)
from (select 48 nt,22597 ra,372.17 p,5.9 ir,0 z,0 t,1 i
from dual
union all
select nt,i + 1,ra - t,p,ir,round((ra - t) * 0.01 * ir / 12,2),p - round((ra - t) * 0.01 * ir / 12,2)
from rec_proc
where i < nt
select * from rec_proc
try to adjust initial values and rounding please
NT
I
RA
P
IR
Z
T
48
1
22224.83
372.17
5.9
109.27
262.9
48
2
21961.93
372.17
5.9
107.98
264.19
48
3
21697.74
372.17
5.9
106.68
265.49
48
4
21432.25
372.17
5.9
105.38
266.79
48
5
21165.46
372.17
5.9
104.06
268.11
48
6
20897.35
372.17
5.9
102.75
269.42
48
7
20627.93
372.17
5.9
101.42
270.75
48
8
20357.18
372.17
5.9
100.09
272.08
48
9
20085.1
372.17
5.9
98.75
273.42
48
10
19811.68
372.17
5.9
97.41
274.76
48
11
19536.92
372.17
5.9
96.06
276.11
48
12
19260.81
372.17
5.9
94.7
277.47
48
13
18983.34
372.17
5.9
93.33
278.84
48
14
18704.5
372.17
5.9
91.96
280.21
48
15
18424.29
372.17
5.9
90.59
281.58
48
16
18142.71
372.17
5.9
89.2
282.97
48
17
17859.74
372.17
5.9
87.81
284.36
48
18
17575.38
372.17
5.9
86.41
285.76
48
19
17289.62
372.17
5.9
85.01
287.16
48
20
17002.46
372.17
5.9
83.6
288.57
48
21
16713.89
372.17
5.9
82.18
289.99
48
22
16423.9
372.17
5.9
80.75
291.42
48
23
16132.48
372.17
5.9
79.32
292.85
48
24
15839.63
372.17
5.9
77.88
294.29
48
25
15545.34
372.17
5.9
76.43
295.74
48
26
15249.6
372.17
5.9
74.98
297.19
48
27
14952.41
372.17
5.9
73.52
298.65
48
28
14653.76
372.17
5.9
72.05
300.12
48
29
14353.64
372.17
5.9
70.57
301.6
48
30 -
Hi
I have Pure SQL DataBase name of Table as per given Coloumn Name.
User Name StartDate EndDate
Mr.Jack 01/04/2010 05/04/2010
Mr.Perlin 07/04/2010 10/04/2010
Mr.Tinklin 01/05/2010 05/05/2010
Mr.Kerlin 12/04/2010 15/04/2010
Now I am using asp.net Form Using C#...
Name --> TextBox
StartDate -> TextBox
EndDate --> TextBox
Now User enter the Dates after Click Save Button....
Here SQL Query Check Whether the User Dates Clause into Data Base Date's.
For Examble..
User Enter Start Date = 04/04/2010, EndDate =08/04/2010
Now Query it check SQL DataBase, Already 01/04/2010 to 10/04/2010 Available so Dont allow Save.... only allow various dates...
---------------- This is task Condition -------
i am using SQL Query
DECLARE @StartDate DATETIME
DECLARE @EndDate DATETIME
SET @StartDate ='02/04/2010' --// This is User Start Date coming from Text Box
SET @EndDate = '10/04/2010' --// This is User End Date coming from Text Box
IF NOT EXISTS (SELECT PollID FROM Polls WHERE (StartDate<= CAST (CONVERT(VARCHAR,@StartDate,101) AS DATETIME) OR EndDate <= CAST (CONVERT (VARCHAR,@EndDate,101) AS DateTime)) AND STATUS<>'D')
SELECT 'OK ALLLOW'
ELSE
SELECT 'NOT ALLOW'
But it is not working Correctly....
Pls give some correctful query for solve task Condition
By
Riyaz
Edited by: 798225 on Sep 28, 2010 10:37 PM
Edited by: 798225 on Sep 28, 2010 10:52 PMNow I am developing Polls Application in asp.net
I am using Polls Concept,
DateBase Name : Polls
Fields : PollID PollName StartDate EndDate UserID
In Asp.Form Having
User Name : TextBox
PollName: TextBox
StartDate: TextBox
EndDate: TextBox
Submit - Button
Task Details
Whenever User Click after fillup all data's... then SQL Query Check
if StartDate or EndDate is exists in Between DataBase Date's.....
Condition true means dont allow save.. else Save.....
Examble:
PollID PollName StartDate EndDate UserName
01 Sample 23/09/2010 26/09/2010 Klit
02 Sample 2 29/09/2010 30/09/2010 Jack
Now User given follwing details and click Submit,
User Name : James
PollName: Test
StartDate: 22/09/2010
EndDate: 27/09/2010
Submit - Button
Here User StartDate: 22/09/2010 , EndDate: 27/09/2010
SQL Query Check ,
Condtion 1 : Those dates are avilable in Datebase???
Result: Yes
Because, Sample Poll date is 23/09/2010 to 26/09/2010, here Start Date is Not Exists, But End Date Exists.
So dnt allow Save Operation....
Now User Again given follwing details and click Submit,
User Name : James
PollName: Test
StartDate: 27/09/2010
EndDate: 28/09/2010
Submit - Button
Here User StartDate: 27/09/2010 , EndDate: 28/09/2010
SQL Query Again Check ,
Condtion 1 : Those dates are avilable in Datebase???
Result: No
Because, Sample Poll date is 23/09/2010 to 26/09/2010,
Sample1 Poll Date is 29/09/2010 to 30/09/2010
here Start Date is Not Exists, But End Date Not Exists.
So Allow Save Operation....
This a My Task....
Could You give SQL Query for help to Check given condition??
regd
Riayz
Edited by: Riyaz on Sep 30, 2010 1:08 AM -
I am trying to execute a pure SQL statement. But my DB adapter is not fetching any output.
select installation_type from oid_staa_desc_mapping where Acode in ('A','B')
I am not sure why this doesn't work.
Regards,
BalajiHi,
Read the following blog post:
http://soa-howto.blogspot.com/2009/05/how-to-use-sql-query-having-in-clause.html
Regards.
D -
Pure SQL to partition date-time occurrences into non-overlapping windows?
i've a question that so far, i've never been able to solve via a pure SQL option.
it's hard to explain in words, but it's something like this:
given a set of date-time, i would like to partition the data into non-overlapping windows of 30 minutes each.
the data is supposed to be partitioned into windows of 30 minutes, meaning when the data is within 30 minutes of the first occurrence, only the first occurrence will be returned. in the next second after the 30th minute, the record will be considered as the start of a new window and is also returned. so those data that occurs within the window period are suppressed. the first occurrence is not necessarily occurring on the 00th minute, so the window start will never be constant.
run the below query to look at the dummy data.
SELECT 'A' AS ID
, TRUNC(SYSDATE) + 7 / 24 + 1 *(ROWNUM - 1) / 1440 AS datetime
FROM DUAL
CONNECT BY ROWNUM <= 50
UNION ALL
SELECT 'A' AS ID
, TRUNC(SYSDATE) + 9 / 24 + 8 / 1440 + 1 *(ROWNUM - 1) / 1440 AS datetime
FROM DUAL
CONNECT BY ROWNUM <= 35
UNION ALL
SELECT 'B' AS ID
, TRUNC(SYSDATE) + 7 / 24 + 5 *(ROWNUM - 1) / 1440 AS datetime
FROM DUAL
CONNECT BY ROWNUM <= 15this is supposed to be the output.
ID DATETIME
A 5/19/2010 07:00:00
A 5/19/2010 07:30:00
A 5/19/2010 09:08:00
A 5/19/2010 09:38:00
B 5/19/2010 07:00:00
B 5/19/2010 07:30:00
B 5/19/2010 08:00:00so far, i'm using a PL/SQL to pipe the records. but i would like to know if this is achievable via SQL or not.
i've tried looking at analytics, width_bucket, ntile and alll options i can think of, but i just can't solve this at all.hey Bob,
your answer is most definitely correct and does what i want. i've verified it again my data set and it returns the results as required!
you've definitely proven me wrong. i was always under the impression that this wasn't possible. thanks!
just a small note:
i need the windows to be binned by seconds, so have changed the numtodsinterval to raw numbers.
WITH t AS
(SELECT 'A' AS ID
, TRUNC(SYSDATE) +(6.75 / 24) AS datetime
FROM DUAL
UNION ALL
SELECT 'A' AS ID
, TRUNC(SYSDATE) +(6.75 / 24) AS datetime
FROM DUAL
UNION ALL
SELECT 'A' AS ID
, TRUNC(SYSDATE) + 7 / 24 + 1 *(ROWNUM - 1) / 1440 AS datetime
FROM DUAL
CONNECT BY ROWNUM <= 50
UNION ALL
SELECT 'A' AS ID
, TRUNC(SYSDATE) + 9 / 24 + 8 / 1440 + 1 *(ROWNUM - 1) / 1440 AS datetime
FROM DUAL
CONNECT BY ROWNUM <= 35
UNION ALL
SELECT 'B' AS ID
, TRUNC(SYSDATE) + 7 / 24 + 5 *(ROWNUM - 1) / 1440 AS datetime
FROM DUAL
CONNECT BY ROWNUM <= 15)
,a AS
(SELECT ID
,datetime
,LAG(datetime) OVER(PARTITION BY ID ORDER BY datetime) AS prevtime
,LAST_VALUE(datetime) OVER(PARTITION BY ID ORDER BY datetime RANGE BETWEEN CURRENT ROW AND 30 / 1440 + 1 / 86400 FOLLOWING) AS interval_end
FROM t)
,b AS
(SELECT ID
,datetime
,LEAD(datetime) OVER(PARTITION BY ID ORDER BY datetime) AS nexttime
FROM t)
,ab AS
(SELECT a.ID
,a.datetime
,a.prevtime
,a.interval_end
,b.datetime as b_datetime
,b.nexttime
FROM a JOIN b ON(a.ID = b.ID
AND a.interval_end = b.datetime)
SELECT ID
,datetime
FROM ab
START WITH prevtime IS NULL
CONNECT BY ID = PRIOR ID
AND datetime = PRIOR nexttime
ORDER BY ID
,datetime;this most definitely proves that i'm still not sure of how to use hierarchy queries.
Edited by: casey on May 20, 2010 11:20 AM -
DB Adapter Pure Sql Option urgent
Hi All,
I have query like this .
select
supp.segment1 supplier_number,
supp.vendor_name supplier_name,
ph.segment1 po_number,
ph.org_id,
ph.creation_date po_date,
pl.line_num po_line_number,
pl.unit_price,
pl.quantity line_quantity,
pl.line_type,
pl.item_number,
pl.item_description,
pl.UNIT_MEAS_LOOKUP_CODE UOM,
pll.shipment_num po_shipment_number,
pll.shipment_type,
pll.ship_to_organization_code,
pll.ship_to_location_code,
pll.quantity shipment_quantity,
pll.QUANTITY_ACCEPTED shipment_quantity_accepted,
pll.QUANTITY_BILLED shipment_quantity_billed,
pll.QUANTITY_CANCELLED shipment_quantity_cancelled,
pll.QUANTITY_RECEIVED shipment_quantity_received,
pll.QUANTITY_REJECTED shipment_quantity_rejected,
pll.need_by_date,
nvl(pll.inspection_required_flag,'N'), -- if its Yes then ites 4 Way Matching
nvl(pll.receipt_required_flag,'N'), -- If Its Yes then its 3 Way Matching
decode(nvl(pll.inspection_required_flag,'N'),'Y','4 WAY MATCHING',
decode(nvl(pll.receipt_required_flag,'N'),'Y','3 WAY MATCHING', '2 WAY MATCHING'))
matching_type,
pll.qty_rcv_tolerance,
pll.qty_rcv_exception_code,
pll.category item_category,
decode(pll.match_option,'P','Purchase Order','Receipt') Invoice_matching_option,
pll.AMOUNT_RECEIVED shipment_amount_received,
pll.AMOUNT_BILLED shipment_amount_billed,
pll.amount_cancelled shipment_amount_cancelled,
pll.amount_accepted shipment_amount_accepted,
pll.amount_rejected shipment_amount_rejected,
pd.distribution_num po_distribution_number,
pd.amount_billed dist_amount_billed,
pd.destination_context dist_destination,
pd.DESTINATION_SUBINVENTORY,
pd.quantity_ordered dist_quantity_ordered,
pd.quantity_delivered dist_quantity_delivered,
pd.quantity_cancelled dist_quantity_cancelled,
pd.quantity_billed dist_quantity_billed,
pd.amount_ordered dist_amount_ordered,
pd.amount_delivered dist_amount_delivered,
pd.amount_cancelled dist_amount_cancelled
from
po_headers_v ph,
po_lines_v pl,
po_line_locations_v pll,
po_distributions_v pd,
ap_suppliers supp,
ap_supplier_sites_all supp_site
where
ph.authorization_status = 'APPROVED' -- Po Must be Approved
and ph.po_header_id = pl.po_header_id
and ph.closed_code = 'OPEN' --PO is still Open
and pl.po_line_id = pll.po_line_id
and pll.line_location_id = pd.line_location_id
and ph.vendor_id = supp.vendor_id
and ph.vendor_site_id = supp_site.vendor_site_id
and pl.cancel_flag = 'N' --PO Line is not Cancelled
and pl.closed_flag = 'N' --PO Line is Still Open
and pll.approved_flag = 'Y' --Shipment is Approved
and nvl(pll.cancel_flag,'N') = 'N' --Shipment is not cancelled
and pll.closed_code = 'OPEN' --Shipment is still Open
Iam trying to use pure sql option , i have pasted the modified query in this way below >
select
supp.segment1 supplier_number,
supp.vendor_name supplier_name,
ph.segment1 po_number,
ph.org_id,
ph.creation_date po_date,
pl.line_num po_line_number,
pl.unit_price,
pl.quantity line_quantity,
pl.line_type,
pl.item_number,
pl.item_description,
pl.UNIT_MEAS_LOOKUP_CODE UOM,
pll.shipment_num po_shipment_number,
pll.shipment_type,
pll.ship_to_organization_code,
pll.ship_to_location_code,
pll.quantity shipment_quantity,
pll.QUANTITY_ACCEPTED shipment_quantity_accepted,
pll.QUANTITY_BILLED shipment_quantity_billed,
pll.QUANTITY_CANCELLED shipment_quantity_cancelled,
pll.QUANTITY_RECEIVED shipment_quantity_received,
pll.QUANTITY_REJECTED shipment_quantity_rejected,
pll.need_by_date,
nvl(pll.inspection_required_flag,'N'), -- if its Yes then ites 4 Way Matching
nvl(pll.receipt_required_flag,'N'), -- If Its Yes then its 3 Way Matching
decode(nvl(pll.inspection_required_flag,'N'),'Y','4 WAY MATCHING',
decode(nvl(pll.receipt_required_flag,'N'),'Y','3 WAY MATCHING', '2 WAY MATCHING'))
matching_type,
pll.qty_rcv_tolerance,
pll.qty_rcv_exception_code,
pll.category item_category,
decode(pll.match_option,'P','Purchase Order','Receipt') Invoice_matching_option,
pll.AMOUNT_RECEIVED shipment_amount_received,
pll.AMOUNT_BILLED shipment_amount_billed,
pll.amount_cancelled shipment_amount_cancelled,
pll.amount_accepted shipment_amount_accepted,
pll.amount_rejected shipment_amount_rejected,
pd.distribution_num po_distribution_number,
pd.amount_billed dist_amount_billed,
pd.destination_context dist_destination,
pd.DESTINATION_SUBINVENTORY,
pd.quantity_ordered dist_quantity_ordered,
pd.quantity_delivered dist_quantity_delivered,
pd.quantity_cancelled dist_quantity_cancelled,
pd.quantity_billed dist_quantity_billed,
pd.amount_ordered dist_amount_ordered,
pd.amount_delivered dist_amount_delivered,
pd.amount_cancelled dist_amount_cancelled
from
po_headers_v ph,
po_lines_v pl,
po_line_locations_v pll,
po_distributions_v pd,
ap_suppliers supp,
ap_supplier_sites_all supp_site
where
ph.authorization_status = 'APPROVED'
and ph.po_header_id = ?
and ph.closed_code = 'OPEN'
and pl.po_line_id = ?
and pll.line_location_id = ?
and ph.vendor_id = ?
and ph.vendor_site_id = ?
and pl.cancel_flag = 'N'
and pl.closed_flag = 'N'
and pll.approved_flag = 'Y'
and nvl(pll.cancel_flag,'N') = 'N'
and pll.closed_code = 'OPEN'
My Question is : The Pasted modified query is correct ???, and this type of below
nvl(pll.inspection_required_flag,'N'), -- if its Yes then ites 4 Way Matching
nvl(pll.receipt_required_flag,'N'), -- If Its Yes then its 3 Way Matching
decode(nvl(pll.inspection_required_flag,'N')
Is Allowed ???????
Edited by: anantwag on Apr 11, 2011 3:01 AMyeah , i was getting some error for that "--" but then i changed the query and now it does not have "---"
But i have a question here the xsd generated is like this ...
and query contains nvl(pll.cancel_flag,'N') which in xsd looks like below.
<xs:element name="nvl" type="xs:string" nillable="true"/>
<xs:element name="nvl" type="xs:string" nillable="true"/>
<?xml version = '1.0' encoding = 'UTF-8'?>
<xs:schema targetNamespace="http://xmlns.oracle.com/pcbpel/adapter/db/DBSelect" xmlns="http://xmlns.oracle.com/pcbpel/adapter/db/DBSelect" elementFormDefault="qualified" attributeFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="DBSelectInput" type="DBSelectInput"/>
<xs:complexType name="DBSelectInput">
<xs:sequence>
<xs:element name="arg1" type="xs:string" nillable="true"/>
<xs:element name="arg2" type="xs:string" nillable="true"/>
<xs:element name="arg3" type="xs:string" nillable="true"/>
<xs:element name="arg4" type="xs:string" nillable="true"/>
<xs:element name="arg5" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
<xs:element name="DBSelectOutputCollection" type="DBSelectOutputCollection"/>
<xs:complexType name="DBSelectOutputCollection">
<xs:sequence>
<xs:element name="DBSelectOutput" type="DBSelectOutput" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="DBSelectOutput">
<xs:sequence>
<xs:element name="supplier_number" type="xs:string" nillable="true"/>
<xs:element name="supplier_name" type="xs:string" nillable="true"/>
<xs:element name="po_number" type="xs:string" nillable="true"/>
<xs:element name="ph_org_id" type="xs:string" nillable="true"/>
<xs:element name="po_date" type="xs:string" nillable="true"/>
<xs:element name="po_line_number" type="xs:string" nillable="true"/>
<xs:element name="pl_unit_price" type="xs:string" nillable="true"/>
<xs:element name="line_quantity" type="xs:string" nillable="true"/>
<xs:element name="pl_line_type" type="xs:string" nillable="true"/>
<xs:element name="pl_item_number" type="xs:string" nillable="true"/>
<xs:element name="pl_item_description" type="xs:string" nillable="true"/>
<xs:element name="UOM" type="xs:string" nillable="true"/>
<xs:element name="po_shipment_number" type="xs:string" nillable="true"/>
<xs:element name="pll_shipment_type" type="xs:string" nillable="true"/>
<xs:element name="pll_ship_to_organization_code" type="xs:string" nillable="true"/>
<xs:element name="pll_ship_to_location_code" type="xs:string" nillable="true"/>
<xs:element name="shipment_quantity" type="xs:string" nillable="true"/>
<xs:element name="shipment_quantity_accepted" type="xs:string" nillable="true"/>
<xs:element name="shipment_quantity_billed" type="xs:string" nillable="true"/>
<xs:element name="shipment_quantity_cancelled" type="xs:string" nillable="true"/>
<xs:element name="shipment_quantity_received" type="xs:string" nillable="true"/>
<xs:element name="shipment_quantity_rejected" type="xs:string" nillable="true"/>
<xs:element name="pll_need_by_date" type="xs:string" nillable="true"/>
<xs:element name="nvl" type="xs:string" nillable="true"/>
<xs:element name="nvl" type="xs:string" nillable="true"/>
<xs:element name="matching_type" type="xs:string" nillable="true"/>
<xs:element name="pll_qty_rcv_tolerance" type="xs:string" nillable="true"/>
<xs:element name="pll_qty_rcv_exception_code" type="xs:string" nillable="true"/>
<xs:element name="item_category" type="xs:string" nillable="true"/>
<xs:element name="Invoice_matching_option" type="xs:string" nillable="true"/>
<xs:element name="shipment_amount_received" type="xs:string" nillable="true"/>
<xs:element name="shipment_amount_billed" type="xs:string" nillable="true"/>
<xs:element name="shipment_amount_cancelled" type="xs:string" nillable="true"/>
<xs:element name="shipment_amount_accepted" type="xs:string" nillable="true"/>
<xs:element name="shipment_amount_rejected" type="xs:string" nillable="true"/>
<xs:element name="po_distribution_number" type="xs:string" nillable="true"/>
<xs:element name="dist_amount_billed" type="xs:string" nillable="true"/>
<xs:element name="dist_destination" type="xs:string" nillable="true"/>
<xs:element name="pd_DESTINATION_SUBINVENTORY" type="xs:string" nillable="true"/>
<xs:element name="dist_quantity_ordered" type="xs:string" nillable="true"/>
<xs:element name="dist_quantity_delivered" type="xs:string" nillable="true"/>
<xs:element name="dist_quantity_cancelled" type="xs:string" nillable="true"/>
<xs:element name="dist_quantity_billed" type="xs:string" nillable="true"/>
<xs:element name="dist_amount_ordered" type="xs:string" nillable="true"/>
<xs:element name="dist_amount_delivered" type="xs:string" nillable="true"/>
<xs:element name="ph" type="xs:string" nillable="true"/>
<xs:element name="pl" type="xs:string" nillable="true"/>
<xs:element name="pll" type="xs:string" nillable="true"/>
<xs:element name="pd" type="xs:string" nillable="true"/>
<xs:element name="supp" type="xs:string" nillable="true"/>
<xs:element name="OPEN" type="xs:string" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Please help me out as, if the same thing will not work then i have to wrap the same query in the stored Procedure. -
Database Adapter Configuration Execute Pure SQL
Hii
I have following scenario in my Project.
I have ERRORCODE Details Table in Database which has following columns.
1)ERRORCODE VARCHAR2
2)PRIORITY VARCHAR2
3)QueueName Varchar2
I have one web service which takes errorcode as input parameter of string type in which i have to pass values like 1,2,3.
Web service treated these values as complete one string value but i want it should be treated like seperately.Beacuse i have to pass these values to the query.
I have configured database adapter for the following query using Execute Pure SQL.
SELECT DISTINCT QueueName FROM ErrorCodeDetails where priority= (select min (priority) from ErrorCodeDetails where ErrorCode In(#ERRORCODE))
So can anyone please help me what changes i have to make in this query so the sql query treat the errorcode string value as three different value rather than one single value??
Thanks in advance.
Regards,
PriyankaChange the query like this.
SELECT DISTINCT QueueName FROM ErrorCodeDetails where priority= (select min (priority) from ErrorCodeDetails where ErrorCode In(select csv from xmltable(#ERRORCODE)))
In case it is required to treat the individual comma separated values in #ERRORCODE as number use the to_number function.
SELECT DISTINCT QueueName FROM ErrorCodeDetails where priority= (select min (priority) from ErrorCodeDetails where ErrorCode In(select to_number(csv) from xmltable(#ERRORCODE)))
In case this helps , please mark the answer as correct/helpful.
Regards. -
Crosstab query using pure SQL only
Hi all,
Found a lot of threads on crosstab, but none seems to address what I need. I need to perform crosstab query using pure SQL only & the number of columns are dynamic. From a query, I obtained the below table:
Name Date Amount
Alex 2005-06-10 1000
Alex 2005-06-20 1000
Alex 2005-07-10 1000
Alex 2005-07-20 1000
Alex 2005-08-10 1000
Alex 2005-08-20 1000
John 2005-06-10 2000
John 2005-06-20 2000
John 2005-07-10 2000
John 2005-07-20 2000
John 2005-08-10 2000
John 2005-08-20 2000
And I need to transform it into:
Name 06-2005 07-2005 08-2005
Alex 2000 2000 2000
John 4000 4000 4000
Reason for the columns being dynamic is because they'll be a limit on the date ranges to select the data from. I'd have a lower & upper bound date say June-2005 to August-2005, which explains how I got the data from the above table.
Please advise.
Thanks!Hi,
I couldn't resist the intellectual challenge of a pure SQL solution for a pivot table with a dynamic number of columns. As Laurent pointed out, a SQL query can only have a fixed number of columns. You can fake a dynamic number of columns, though, by selecting a single column containing data at fixed positions.
<br>
<br>
If it were me, I'd use a PL/SQL solution, but if you must have a pure SQL solution, here is an admittedly gruesome one. It shows the sum of all EMP salaries per department over a date range defined by start and end date parameters (which I've hardcoded for simplicity). Perhaps some of the techniques demonstrated may help you in your situation.
<br>
<br>
set echo off
set heading on
set linesize 100
<br>
select version from v$instance ;
<br>
set heading off
<br>
column sort_order noprint
column sal_sums format a80
<br>
select -- header row
1 as sort_order,
'DEPTNO' as DEPTNO ,
sys_connect_by_path
( rpad
( to_char(month_column),
10
' | '
) as sal_sums
from
select
add_months( first_month, level - 1 ) as month_column
from
( select
date '1981-01-01' as first_month,
date '1981-03-01' as last_month,
months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
from dual
connect by level < total_months + 1
) months
where
connect_by_isleaf = 1
connect by
month_column = add_months( prior month_column, 1 )
start with
month_column = date '1981-01-01'
union all
select -- data rows
2 as sort_order,
deptno,
sys_connect_by_path( sum_sal, ' | ' ) sal_sums
from
select
dept_months.deptno,
dept_months.month_column,
rpad( to_char( nvl( sum( emp.sal ), 0 ) ), 10 ) sum_sal
from
select
dept.deptno,
reporting_months.month_column
from
dept,
( select
add_months( first_month, level - 1 ) as month_column
from
( select
date '1981-01-01' as first_month,
date '1981-03-01' as last_month,
months_between( date '1981-03-01', date '1981-01-01' ) + 1 total_months
from
dual
connect by level < total_months + 1
) reporting_months
) dept_months,
emp
where
dept_months.deptno = emp.deptno (+) and
dept_months.month_column = trunc( emp.hiredate (+), 'MONTH' )
group by
dept_months.deptno,
dept_months.month_column
) dept_months_sal
where
month_column = date '1981-03-01'
connect by
deptno = prior deptno and
month_column = add_months( prior month_column, 1 )
start with
month_column = date '1981-01-01'
order by
1, 2
<br>
VERSION
10.1.0.3.0
<br>
DEPTNO | 81-01-01 | 81-02-01 | 81-03-01
10 | 0 | 0 | 0
20 | 0 | 0 | 0
30 | 0 | 2850 | 0
40 | 0 | 0 | 0
<br>
Now, if we substitute '1981-03-01' with '1981-06-01', we see 7 columns instead of 4
<br>
DEPTNO | 81-01-01 | 81-02-01 | 81-03-01 | 81-04-01 | 81-05-01 | 81-06-01
10 | 0 | 0 | 0 | 0 | 0 | 2450
20 | 0 | 0 | 0 | 2975 | 0 | 0
30 | 0 | 2850 | 0 | 0 | 2850 | 0
40 | 0 | 0 | 0 | 0 | 0 | 0
<br>To understand the solution, start by running the innermost subquery by itself and then work your way outward. -
Strings comparision and get unique string in pure sql,
Dear all,
Here is two strings
S1='A,B,C,D,F';
s2='C,F,H,B,A,K';
output should be like unique string values ..
S3= A,B,C,D,F,H,K;
How to get this in pure sql..
thanks in advance,
RootsHi,
In a relational database, each column of each row should store one value, not a repleating group of values, such as a delimited list. This is so basic to database design that it is called "First Normal Form". You don't have to follow rules like this, but, if you don't, your code will be complicated, inefficient, and error-prone. It sould be best to re-design your application so that each value was on a separate row.
If you can't do that, then you can start by splitting your delimitd lists into separate rows. Then you can easily fond the distinct values, and use any String Aggregation technique to combine the results into one output row.
Here's one way to do all that:
WITH got_params AS
SELECT 'A,B,C,D,F' AS str, 1 AS str_id FROM dual UNION ALL
SELECT 'C,F,H,B,A,K', 2 FROM dual
, got_part_cnt AS
SELECT str
, 1 + LENGTH (str)
- LENGTH (REPLACE (str, ',')) AS part_cnt
FROM got_params
, cntr AS
SELECT LEVEL AS n
FROM (
SELECT MAX (part_cnt) AS max_part_cnt
FROM got_part_cnt
CONNECT BY LEVEL <= max_part_cnt
, got_substr AS
SELECT DISTINCT
REGEXP_SUBSTR ( p.str
, '[^,]+'
, 1
, c.n
) AS sub_str
FROM got_part_cnt p
JOIN cntr c ON c.n <= p.part_cnt
, got_r_num AS
SELECT sub_str
, ROW_NUMBER () OVER (ORDER BY sub_str) AS r_num
, ROWNUM AS r
FROM got_substr
SELECT MIN ( SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
, 2
) AS unique_sub_strs
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
-- START WITH r_num = 1
CONNECT BY r_num = 1 + PRIOR r_num
;This works in Oracle 10.2.0.2.0 Express Edition, which is the only database I can use right now. For the main query, you should be able to say:
SELECT SUBSTR ( SYS_CONNECT_BY_PATH (sub_str, ',')
, 2
) AS unique_sub_strs
FROM got_r_num
WHERE CONNECT_BY_ISLEAF = 1
START WITH r_num = 1
CONNECT BY r_num = 1 + PRIOR r_num
;but, when I try that on my database, I only get 'A,B' as the output. CONNECT BY is very buggy in Oracle 10.2; if you have Oracle 10.1, the simpler form might work.
The query above can be shortened some, but I wrote it this way to make it easier to understand.
You can, for example, combine the sub-queries got_sub_str and got_r_num. If you do, use DENSE_RANK instead of ROW_NUMBER.
This does not assume that the sub-qtrings are all 1-character long. If they are, then the query can be simplified.
For more about string aggregation, see
http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php -
Oracle SQL Select query takes long time than expected.
Hi,
I am facing a problem in SQL select query statement. There is a long time taken in select query from the Database.
The query is as follows.
select /*+rule */ f1.id,f1.fdn,p1.attr_name,p1.attr_value from fdnmappingtable f1,parametertable p1 where p1.id = f1.id and ((f1.object_type ='ne_sub_type.780' )) and ( (f1.id in(select id from fdnmappingtable where fdn like '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#%')))order by f1.id asc
This query is taking more than 4 seconds to get the results in a system where the DB is running for more than 1 month.
The same query is taking very few milliseconds (50-100ms) in a system where the DB is freshly installed and the data in the tables are same in both the systems.
Kindly advice what is going wrong??
Regards,
PurushothamSQL> @/alcatel/omc1/data/query.sql
2 ;
9 rows selected.
Execution Plan
Plan hash value: 3745571015
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | SORT ORDER BY | |
| 2 | NESTED LOOPS | |
| 3 | NESTED LOOPS | |
| 4 | TABLE ACCESS FULL | PARAMETERTABLE |
|* 5 | TABLE ACCESS BY INDEX ROWID| FDNMAPPINGTABLE |
|* 6 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
|* 7 | TABLE ACCESS BY INDEX ROWID | FDNMAPPINGTABLE |
|* 8 | INDEX UNIQUE SCAN | PRIMARY_KY_FDNMAPPINGTABLE |
Predicate Information (identified by operation id):
5 - filter("F1"."OBJECT_TYPE"='ne_sub_type.780')
6 - access("P1"."ID"="F1"."ID")
7 - filter("FDN" LIKE '0=#1#/14=#S0058-3#/17=#S0058-3#/18=#1#/780=#5#
8 - access("F1"."ID"="ID")
Note
- rule based optimizer used (consider using cbo)
Statistics
0 recursive calls
0 db block gets
0 consistent gets
0 physical reads
0 redo size
0 bytes sent via SQL*Net to client
0 bytes received via SQL*Net from client
0 SQL*Net roundtrips to/from client
0 sorts (memory)
0 sorts (disk)
9 rows processed
SQL>
Maybe you are looking for
-
Clearly something is blocking the main user(administrator) from opening the iTunes programme and I cannot find a solution.
-
Loading xml file into external tables
emp.xml is xml file namewhich is saved in C:\Documents and Settings\james\Desktop\emp.xml xml file <EMPLOYEES> <EMP> <EMPNO>7369</EMPNO> <ENAME>SMITH</ENAME> <JOB>CLERK</JOB> <HIREDATE>17-DEC-80</HIREDATE> <SAL>800</SAL> </EMP> <EMP> <EMPNO>7499</EMP
-
Resulting in Dump with HR Function module
Hi all, I am trying to update the work schedules of an employee using the function module <b>'HR_DV_WORKSCHEDULE_MODIFY'</b>. The Dump is <b>'Access Not possible using 'NULL' object interface'.</b>. Can anybody solve this... Thanks in advance. Suva
-
Input taxes for zambia, southafrica
Hi Consultants, Does anybody know how to configure the input taxes flike customs,excise & vat or zambia country, south africa. If any has some document kindly requesting you to forward me. with regards GNK
-
I have created a pdf form from Indesign. Is there a way to enable the person filling out the form to then click a button (created in indesign) that collects their answers and exports them in a preformatted pdf? It's not something I'm aware of but a c