Conditional exists in pure SQL.
Hi,
I'm on 10.2.0.3 and got problem like this
create table big (id number , words varchar2(22));
insert into big values (1, 'aaa');
insert into big values (1, 'abc');
insert into big values (1, 'bbb');
insert into big values (1, 'ccc');
insert into big values(2, 'eee');
select * from big;
ID WORDS
1 aaa
1 abc
1 bbb
1 ccc
2 eee
create table dic1 (data varchar2(22));
insert into dic1 values('aaa');
insert into dic1 values('bbb');
create table dic2 (data varchar2(22));
insert into dic2 values('eee');
SQL> select * from dic1;
DATA
aaa
bbb
SQL> select * from dic2;
DATA
eee
select * from big
where
exists (select null from dic1 where instr(words,data) > 0);Now I want to compare big table with dic2 as well but only if column id from table big equals (id = 2) .
So I need kind of case statement with two exists subquery :
1- for dict1 and 2nd for dic2 but only if id = 2 .
Please advice.
Regards
GregG
Sorry for not being clear , actually I need that record too so first answer is ok
select *
2 from big
3 where
4 exists (
5 select null
6 from (
7 select 1 id1, data from dic1
8 union all
9 select 2 id1, data from dic2
10 )
11 where id = id1 and instr(words,data) > 0
12* )
ID WORDS
1 aaa
1 bbb
2 eeeRegards
GregG
Edited by: GregG on Jul 27, 2011 1:20 PM
Similar Messages
-
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 -
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 -
Conditional display in a SQL-Report/Report Region
Hi,
here I have an example for "Conditional display in a SQL-Report/Report Region". I figured it out in Firefox 3.6.2 using Firebug as development tool on Apex 3.2.1.00.12.
First you have to put the following javascript code in the Page HTML-Header:
<script type="text/javascript">
<!--
// SOURCE
// W:\oracle\PRJ DWLS\javascript.07.js
// Beispiel Funktion zur bedingten Formatierung einer Tabellenzelle.
// Help (Substitution Strings):
// http://htmldb.oracle.com/pls/otn/wwv_flow_help.show_help?p_lang=de&p_session=2412201185523196&p_flow_id=4003&p_step_id=420,4003
// HTML Expression:
// <script>ex_conditional_td('R094260001010', #ROWNUM#, #COLNUM#-1);</script>#DFT_COND1#
function ex_conditional_td
( p_id
, p_rownum
, p_cellnum
var l_td;
l_td = vd_getColumn(p_id, p_rownum, p_cellnum);
// hier die Bedingung definieren
if (true) {
l_td.style.color = '#808080';
} // -- eof ex_conditional_td -- //
// Beispiel Funktion zum Abstellen der onMouse Funktionalität der Tabellenzeile
// HTML Expression:
// <script>ex_conditional_tr('R094260001010', #ROWNUM#);</script>#DFT_ID#"
function ex_conditional_tr
( p_id
, p_rownum
var l_tr; // TABLE.TR
var l_td; // TABLE.TR.TD
if (true) {
l_tr = vd_getRow(p_id, p_rownum);
l_tr.onmouseover = null;
l_tr.onmouseout = null;
for (var i=0; i<l_tr.cells.length; i++) {
l_td = l_tr.cells;
l_td.style.backgroundColor = '#DDDDDD';
} // -- eof ex_conditional_tr() -- //
var g_DEBUG = false;
var g_TBODY = null;
// Liefert das Body-Element der Tabelle mit der ID <p_id>.
// Parameter
// p_id - die Id der HTML-Tabelle
// Return
// das Body-Element oder NULL, wenn die Zeile nicht gefunden wurde
function vd_getBody
( p_id
if (g_TBODY == null) {
var l_table = null;
l_table = document.getElementById( p_id );
if (l_table == null) {
l_table = document.getElementByName( p_id );
if (l_table != null) {
if (vd_debug()) {
alert("Tabelle gefunden, " + l_table.nodeName);
g_TBODY = vd_search( l_table, 'TD', 't10data', 'TBODY');
return g_TBODY;
} // -- eof vd_getBody() -- //
// Liefert die Zeile <p_rownum> der HTML-Tabelle mit der Id <p_id>.
// Parameter
// p_id - die Id der HTML-Tabelle
// p_rownum - die Zeilennummer
// Return
// die Zeile oder NULL, wenn die Zeile nicht gefunden wurde
function vd_getRow
( p_id
, p_rownum
var l_body = vd_getBody(p_id);
if ( l_body != null
&& l_body.nodeName == 'TBODY'
&& l_body.children[p_rownum].nodeName == 'TR') {
return l_body.children[p_rownum];
else {
return null;
} // -- eof vd_getRow() -- //
// Liefert die Spalte <p_column> der Zeile <p_rownum> der HTML-Tabelle mit der
// Id <p_id>.
// Parameter
// p_id - die Id der HTML-Tabelle
// p_rownum - die Zeilennummer
// p_column - der Index der Spalte / Zelle
// Return
// die Zelle oder NULL, wenn die Zelle nicht gefunden wurde
function vd_getColumn
( p_id
, p_rownum
, p_column
var l_tr = vd_getRow(p_id, p_rownum);
if ( l_tr != null
&& l_tr.nodeName == 'TR'
&& l_tr.children.length >= p_column
&& l_tr.children[p_column].nodeName == 'TD') {
return l_tr.children[p_column];
else {
return null;
} // -- eof vd_getColumn() -- //
// Rekursives Suchen nach einem Node.
// Zweck: Das bedingte Formatieren einer Tabellenzelle in einem Apex Standard
// SQL-Report.
// Diese Funktion durchsucht rekursiv, ab einem Ausgangsknoten <p_node>, alle
// darunter befindlichen Elemente, ob in dem Element <p_seachIn> sich die
// Klasse <p_class> befindet.
// Bei Standard-Reports ist die Reportzelle (TD) mit der Klasse
// "t10data" formatiert.
// Zunächst muss dazu die Tabellenzelle (TD) selbst, die übergeordnete
// Tabellenzeile (TR), der Tabellenbody (TBODY) oder die Tabelle (TABLE)
// selbst ermittelt werden.
// Der Beispielaufruf:
// var l_body;
// var l_node = document.getElementById( 'R112233' );
// l_body = search( l_node, 'TD', 't10data', 'TBODY');
// durchsucht also das mit der Id "R112233" versehene Element [der Report, für
// den in Apex eine statischen ID vergeben werden musste] rekursiv, bis er
// die [erste] Tabellenzelle "TD" findet, die als Klasse "t10data"
// definiert hat. Für diese ermittelt er dann das übergeordnete TBODY-Element.
// Parameter
// p_node - das Ausgangselement
// p_searchIn - der Knotenname, der durchsucht werden soll
// [node.nodeName == p_searchIn]
// p_class - der Name der CSS Klasse
// [node.classList[<index>] == p_class
// p_parentName - der Name [node.parentNode.nodeName == p_parentName]
// des Elements, das zurückgeliefert werden soll. Wird als
// p_parentName der Suchname p_searchIn angegeben, wird
// das Element selbst zurückgegeben.
// Return
// das per p_parentName gesuchte Element (TD, TR, TBODY, TABLE)
function vd_search
( p_node
, p_searchIn
, p_class
, p_parentName
var LN = "vd_search";
var l_element = null;
// DEBUG
if (vd_debug()) {
alert(LN + ":" + "Untersuche " + p_node.nodeName + ", id=" + p_node.id);
// 1) der aktuelle Knoten ist der, der durchsucht werden soll
if (p_node.nodeName == p_searchIn) {
if (p_node.classList.length > 0) {
for(var c=0; c<p_node.classList.length; c++) {
if (p_node.classList[c] == p_class) {
// Parent Node dynmisch suchen
l_node = p_node;
if (l_node.nodeName == p_parentName) {
return l_node;
while(l_node != null && l_node.parentNode != null) {
if (l_node.parentNode.nodeName == p_parentName) {
return l_node.parentNode;
else {
l_node = l_node.parentNode;
// 2) wenn nicht 1) oder nicht in 1) gefunden, dann in den Kindelementen
// weitersuchen
if (p_node.children.length > 0) {
var i = 0;
while (i<p_node.children.length && l_element==null) {
l_element = vd_search( p_node.children[i], p_searchIn, p_class, p_parentName);
i++;
return l_element;
} // -- eof vd_search() -- //
// Gibt an, ob Debug ein- (true) oder ausgeschaltet (false) ist.
// Return
// true - debug ist eingeschaltet
// false - debug ist ausgeschaltet
function vd_debug()
return g_DEBUG;
-->
</script>
Maybe you have to modify the "vd_getBody" function. I'm searching the table cell with having the class "t10data". When you use another theme, there's maybe another class used.
Second is, that you set an static id for your report region. I prefer this structure:
R<app-id><page-id><seq> (Raaaaappppsss) e.g. R094260001010.
First example is to turn off the onMouse-Effect. Maybe on the first or last column definition you put this code in the "HTML-Expression" area:
<script>ex_conditional_tr('R094260001010', #ROWNUM#);</script>#ID#This will call the example function ex_conditional_tr with the parameter
a) the region id
b) the rownum (as oracle always starts with 1 this is the first data row [rownum=0 is the table header row])
Second example is the conditional formatting of a table cell. Put this in the HML-Expression area:
<script>ex_conditional_td('R094260001010', #ROWNUM#, #COLNUM#-1);</script>#ENAME#This will call the example function ex_conditional_tr with the parameter
a) the region id
b) the rownum
c) the cellnum (here we have to subtract 1 to get the "real" cell index)
The "ex_conditional" functions are just a representation of how to get the row or cell node.
Hope this help a bit.
TomI would use a CASE statement in the select....
each CASE would be an img src tag for a different button if the button is an image.
does that make sense? I can include an example if you would like... -
I want to update iCloud account with new apple id but don't know password for old apple id. Plus can no longer receive email at old apple id. How can I delete the current iCloud account on my iPhone if the previously stated conditions exist?
If the old ID is yours, and if it is an earlier version of your current ID, go to https://appleid.apple.com, click Manage my Apple ID and sign in with your current iCloud ID. Click edit next to the primary email account, change it back to your old email address and save the change. Then edit the name of the account to change it back to your old email address. You can now use your current password to turn off Find My iDevice, even though it prompts you for the password for your old account ID. Then save any photo stream photos that you wish to keep to your camera roll. When finished go to Settings>iCloud, tap Delete Account and choose Delete from My iDevice when prompted (your iCloud data will still be in iCloud). Next, go back to https://appleid.apple.com and change your primary email address and iCloud ID name back to the way it was. Now you can go to Settings>iCloud and sign in with your current iCloud ID and password.
-
How to build dynamic query strings in the query using DB adapter 'Pure SQL'
Dear Forum,
I am building an application which will access DB to fetch some result set. The query involves retrieving data from multiple tables(nearly 10 tables). So I have created a DB adapter using 'execute pure sql' option. With this query works fine, but my inputs parameters will vary. So I need to make my query dynamic to append the query strings at runtime depending on the inputs.
For example I have 3 input variables - input1,input2 and input3 (in my request xsd) which are used in the pure sql query. Now if I get a 4th input parameter input4 in the request, I need to append this to query string as 'AND input4=[some value]' at runtime. Otherwise my query should have only 3 parameters. Please suggest how this can be achieved.
Regards,
Satya.This is a strange requirement, depending on the columns you have and what are optional in them, one way is to have separate operations and each opeartion will have different inputs and for each operation , a different DB Adapter is called. But this way, it results in more number of operations for the service as well as more number of references in the composite. Even if you pass the column inputs to the SQL procedure, it will result in a large number of if-else cases..
Thanks,
N -
Hi All,
Here is my scenario:
I wnat to take teh dat from the database tables and generate teh reports in BAM. Al;ready I have SQL queries to generate the report. I want to pool the db tables for every 2 mins and generate the report .
My question is :
Is there is any way to trigge teh pure SQL in DB adapter for every certain intervat of time? Please help me on this. also suggest me best approach..
Thanks
VenkatHi Venkat
1. Hope you are familiar with BAM Reports architecture and how it works. Its pretty straight forward.
2. First you create a DataSource to any external Database giving the db host, port, sid, username/password. This database contains like Tables, Views, etc etc.
3. You create a DataObject that References any component of this database like Table, View etc. So you have a SQL that joins multiple tables and fetches data. Simply Create a View for that SQL Query on database side like database View. Then create a BAM Data Object for that View. It shows all Columns from that View. Simply Rename them if you want or just leave as it is. Just run the View and it shows all the data records. Remember this is dynamic. There is no need to refresh or trigger. Say if the table had a new row, the View will just show that new row.
4. Now create a Report (Web or excel format) for the above Data Object. Report by default will show all the column from Data Object. Pick the columns you want to add to that Report.
Run the Report. Data in Report is 100% Dynamic. If backend tables had new rows or deleted rows, just run the Report and you will see the results.
Thanks
Ravi Jegga -
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 -
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 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. -
In which table does Pricing Condition exist?
Please inform where the field Pricing condition exists in which table and what is the field's technical name?
Hi,
i do not remember exactly...but it starts with KO...
please go to SE11 in the TABLES give KO* and press F4 u will get a list a tables which r starting with that name u can find in that list
Regards,
Satya -
How to create conditional update trigger in sql server
How to create conditional update trigger in sql server
You cant create a conditional update trigger. Once you create an update trigger it will get called for every update action. However you could write logic inside it to make it do your activity based on your condition using IF condition statement
Say for example if you've table with 6 columns and you want some logic to be implemented on update trigger only if col3 and col5 are participating in update operation you can write trigger like this
CREATE TRIGGER Trg_TableName_Upd
ON TableName
FOR UPDATE
AS
BEGIN
IF UPDATE(Col3) OR UPDATE (Col5)
BEGIN
....your actual logic here
END
END
UPDATE() function will check if column was involved in update operation and returns a boolean result
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
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
Maybe you are looking for
-
Applescript - how do I use the result of a library return value
Hello. Been using applescript for about a week. Very new. I'm using the following script below using an external libarary to query mysql database on external server. works. gives results. How do I save them to do something with the. when I run
-
Mac OS 10.4 Mail takes longer to receive than on Outlook Express 5
I receive email via Outlook Express 5.0.6 within an hour (but hate to use it). It can take Mac OS 10.4.8 Mail up to 24 hrs longer. Mail Preferences are set to: Check for new mail:" Every 30 min." Under Accounts>Advanced: "Enable This Account" and "In
-
Apple wired keyboard. Number pad not working with Windows Office 07 via bo
I have a 27' Quad core i7 with windows 7 loaded via bootcamp. i have Office 2007 loaded in the Windows partition. My problem is that the number pad on my wired apple keyboard does not work in excel or word. The number at the top of the keyboard work
-
Jdeveloper 10.1.3 with BPEL designer
I downloaded Jdeveloper 10.1.3. But this version of Jdev doesn't include BPEL designer. I wonder how I can I make BPEL designer included in Jdeveloper 10.1.3. Thanks,
-
Using iPhoto Book Themes in Aperture
I would like to use the iPhoto book themes in Aperture. Anyway of importing them. Thanks, Paul. iMac Intel Core Duo 20", 2 GB RAM Mac OS X (10.4.6) Nikon Coolscan V ED, Nikon D200, Iomega MiniMax