Xpath syntax for "a number"
In regex, it's [0-9]+ or \d+. I'm trying to use xpath to match a number that's any value of 18 digits long. What's the syntax?
DuckDuckGo: http://www.regular-expressions.info/xpath.html
Similar Messages
-
Simple question. Can someone please provide the proper syntax for placing an Input Variable into the query-database XPATH statement? I cannot even get this statement to compile (or any variants of it):
orcl:query-database('select ename from emp where empno = bpws:getVariableData('inputVariable','payload')',false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')
Here is the detailed error:
Error(30): [Error ORABPEL-10039]: invalid xpath expression [Description]: in line 30 of "C:\OraBPELPM_1\integration\jdev\jdev\mywork\BPELws\JDBC\JDBC.bpel", xpath expression "orcl:query-database('select ename from emp where empno = bpws:getVariableData('inputVariable')',false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" specified in <from> is not valid, because XPath query syntax error. Syntax error while parsing xpath expression "orcl:query-database('select ename from emp where empno = bpws:getVariableData('inputVariable')',false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')", at position "79" the exception is Expected: ). Please verify the xpath query "orcl:query-database('select ename from emp where empno = bpws:getVariableData('inputVariable')',false(),false(),'jdbc:oracle:thin:scott/tiger@localhost:1521:ORCL')" which is defined in BPEL process. . [Potential fix]: Please make sure the expression is valid.
I have been trying to XSQL to work and it suffers from XPATH issues at runtime.
Clemens, any suggestions here? I was thinking perhaps of using ora:parseEscapedXML to forceably create the proper expression after concatenating the orcl:query-database together with the EMPNO after it is assigned to a holding String variable. Not sure it would work though. It does not look like you can perform 2 successive COPY TO / FROM in one set of tags.
Thanks!Does anybody have any suggestions for this issue? Has anyone gotten this aspect of XPATH to work correctly? HELP!
-
Syntax for creating foreign key across users in a database
There are two user present A,B.They are granted all privileges.Now in USER A, there is a table PARENT whose primary key is PARENT_NO.In USER B I have created a table CHILD whose primary key is CHILD_NO.
In the CHILD table of USER B, I want to create a foreign key relation to the PARENT table of USER A.For this I have created a column CHILD_PARENT_NO in the CHILD table.If anybody knows the syntax please post the syntax for creating the required foreign key relationship?Please post your code. Cut'n'paste from SQL*Plus like this...
SQL> conn a/a
Connected.
SQL> desc t1
Name Null? Type
COL1 NUMBER
COL2 VARCHAR2(10)
SQL> grant references on t1 to b;
Grant succeeded.
SQL> conn b/b
SQL> create synonym a_t for a.t1;
Synonym created.
SQL> alter table test add constraint fk foreign key (n) references a_t(col1);
Table altered.
SQL> Note that Oracle will translate the synonym anyway...
SQL> select constraint_name, r_owner, r_constraint_name
2 from user_constraints
3 where table_name = 'TEST'
4 /
CONSTRAINT_NAME R_OWNER R_CONSTRAINT_NAME
FK A T1_PK
SQL> By the way, this ...
GRANT ALL PRIVILEGES TO B;... is a mindbendingly unsafe way of proceeding. In real life you would have given user B the power to utterly destroy your database. It's always easier to start with good habits than to break bad ones so please get used to granting only the minimum set of privileges necessary.
Cheers, APC -
Code to write syntax for JOB submit ( Please answer ASAP)
Hi,
I need sytax to submit a job
Right now I am using this code to send 4 parameters.
I need to send these 4 in a structure.
submit Ztestjob USER sy-uname
via job p_jobnm
number p_jobcount
with afko-rsnum eq afko-rsnum
with aufnr_d eq aufnr_d
with sernr_d eq sernr_d
with p_lmnga eq p_lmnga
AND RETURN.
So I have to pass a structure of values into the BGprogram through a submit and do a couple of loops in the BGPROGRAM.
I need the syntax for submit .
I also need to know how to catch the structure with values in the BGPROGRAM.
Anyone please answer ASAP
Message was edited by:
ramana peddu
Message was edited by:
ramana pedduHi,
<u>SUBMIT</u>
Calls an executable program of type 1.
Syntax
SUBMIT <rep> [AND RETURN] [VIA SELECTION-SCREEN]
[USING SELECTION-SET <var>]
[WITH <sel> <criterion>]
[WITH FREE SELECTIONS <freesel>]
[WITH SELECTION-TABLE <rspar>]
[LINE-SIZE <width>]
[LINE-COUNT <length>].
Calls the program <rep>. If you omit the AND RETURN addition, the current program is terminated. Otherwise, the data from the current program is retained, and processing returns to the calling program when <rep> has finished running. The other additions control the selection screen and set attributes of the default list in the called program.
Regards,
Bhaskar -
Round up syntax for Formatted Search
Hi all,
I need help on writing the formatted search syntax for below scenario.
Discount % = 2 decimal place only
Unit Price = 99,376.00
Discount = 30.97%
Price After Discount = 68,599.25
I want the Price After Discount to be rounded up to 68,600. Any idea how to achieve this? Will do this round up in another UDF so that my layout will show the rounded up price to customer.
Even if the Price after discount is 600.02, i wanted the result to be always rounded up to nearest $1 as long as the original price has some amount at the decimal. For this case, should round up to 601.00.
Anyone can help? Thanks in advance.Hi Too Mui Hwee
Will the UDF be varchar or numeric? Do you want the udf to show the currency as well?
I have done both for you. The problem with SQL 2008 & 2012 is that they don't have a roundup function. This is however in version 2014 which is not yet supported by SAP Business One.
Without currency:
SELECT CASE WHEN ROUND($[$38.17.NUMBER],0) < $[$38.17.NUMBER] THEN ROUND($[$38.17.NUMBER],0) + 1 ELSE ROUND($[$38.17.NUMBER],0) END
With currency:
SELECT CASE WHEN ROUND($[$38.17.NUMBER],0) < $[$38.17.NUMBER] THEN $[$38.17.CURRENCY] + ' ' + CAST(ROUND($[$38.17.NUMBER],0) + 1 AS VARCHAR(20)) ELSE $[$38.17.CURRENCY] + ' ' + CAST(ROUND($[$38.17.NUMBER],0) AS VARCHAR(20)) END
Kind regards
Peter Juby -
SQL Syntax for Access database
This pertains to LV only due to the fact that LV requires a slightly different syntax for SQL statements for use with Access than what you will see in the Access Queries SQL view. For instance, I discovered that if you use a ? for a character placeholder (can be any single character) in Access, you need to use an _ (underscore) for this feature. I also discoverd that you use a % sign instead of an * (asterisk) for any number of characters.
The lat thing I am having trouble with is specifying a range of characters that could be in a certain position in the text field. For instance, if the first character can be only an alpha between A and Z, and the next two characters can be numbers anywhere from 1 to 12, I would use LIKE "[A-Z][1-12]*" In LV, the double quotes are are replaced with single quotes but I cannot figure out what to replace the brackets with.
The brackets do not return a syntax error but also do not return any results that should fit the pattern.
I have tried parenthesis, double quotes, using a TO in place of the dash, etc.
Any input on this is very much appreciated.
Doug
I guess sometimes writing the problem out helps one deduce the answer by taking a closer look at what has been tried and what has not.
So LIKE "[A-Z][1-12]*" in Access will be LIKE ('[A-Z][01-12]%') in LV. I hadn't tried the pecent sign in place of the asterisk using the brackets. Too bad this stuff isn't spelled out in detail somewhere.
Doug
"My only wish is that I am capable of learning each and every day until my last breath."Thanks Danubio for the links. The one for the SQL utility may be helpful as I go forward.
Mike, yes I am using the connectivity toolkit. It's what I cut my teeth on and up to this point, has not caused me any issues. I rarely make changes after implementation but if I do, the use of typedef's keeps it pretty painless. A brief read on the doc included in your referenced zip file confirms there are alternate methods to talks to the database tables (I am not a one table programmer). When time permits, I will do some trials and if warranted, will try some of your techniques at some point. Simply not enough time currently.
As I posted intially, I actually solved my problem before there were any replies and included my solution in the first post. Why there is a syntax difference going from LV to an mdb is an unknown to me but it exists nonetheless.
Thanks for the input on this
Doug
"My only wish is that I am capable of learning each and every day until my last breath." -
Flex 3: syntax for populating ArrayCollection by loop
Hi, I'm a newb. I can't find an example of how to do this. Any examples would be greatl appreciated.
I want to chart some engineering data by populating my chart's dataprovider with an array collection (so far no problem). I want to poulate the array collection by looping through a math expression and I can't figure out the syntax for that. For example...
[Bindable]
private var myChartData:ArrayCollection = new ArrayCollection([
{vertNum:100, horizNum:100}
I want to loop through and add more points programmatically so if I loop 5 times I end up with...
[Bindable]
private var myChartData:ArrayCollection = new ArrayCollection([
{vertNum:100, horizNum:100},
{vertNum:110, horizNum:110},
{vertNum:43, horizNum:120},
{vertNum:88, horizNum:130},
{vertNum:140, horizNum:140},
// etc...
The number of horizontal variables to plot ould be in the hundreds, so I don't want to set up a huge static array collection with expressions in each location. I'd prefer to solve the expression as a loop iterates and populate the array collection as it goes. But I haven't got a clue how to 'word' that.
thanks!Here is an example of adding data points from a simple formula using a random number generator and scaling the randomness up. The process is just to create a new Object for each iteration of the loop and add the object to your ArrayCollection. You can assign as many properties to the object as you need, which can be helpful for using one ArrayCollection that is displayed in multiple charts.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="build_model()">
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
private function build_model():void {
var obj:Object;
var chartAC:ArrayCollection = new ArrayCollection();
for (var i:uint = 0; i < 100; i++) {
obj = new Object();
obj.horizNum = 100 + 10 * i;
obj.vertNum = i * Math.random();
chartAC.addItem(obj);
linechart1.dataProvider = chartAC;
]]>
</mx:Script>
<mx:LineChart left="10" right="10" top="54" bottom="10" id="linechart1">
<mx:series>
<mx:LineSeries displayName="Series 1" yField="vertNum" xField="horizNum"/>
</mx:series>
</mx:LineChart>
<mx:Button x="10" y="10" label="Build Model" click="build_model()"/>
</mx:Application>
Chris -
Hello,
I am trying to write an XPath syntax query to retrieve some specific child nodes in a loop (in PLSQL) from the following document excerpt..
<?xml version="1.0" encoding="utf-8" ?>
<Request RequestNumber="">
<TargetServers>
<TargetServer>
<HARDWARE>
<HOSTNAME>HNSS1</HOSTNAME>
</HARDWARE>
<PRODUCTS>
<PRODUCT PRD_ID="123" QUANTITY="10">
<PERIOD></PERIOD>
<PROD_ATTRIBUTES>
<SUPP>ven1</SUPP>
<EDITION>ENTERPRISE</EDITION>
<VERSION>1.0</VERSION>
</PROD_ATTRIBUTES>
</PRODUCT>
<PRODUCT PRD_ID="234" QUANTITY="3">
<PERIOD></PERIOD>
<EXEMPTIONS>
<EXEMPTION_CODE>xxx1</EXEMPTION_CODE>
</EXEMPTIONS>
<EXCEPTIONS />
<PROD_ATTRIBUTES />
</PRODUCT>
<PRODUCT PRD_ID="345" QUANTITY="5">
<PERIOD></PERIOD>
<EXCEPTIONS />
<PROD_ATTRIBUTES />
</PRODUCT>
</PRODUCTS>
</TargetServer>
<TargetServer>
<HARDWARE>
<HOSTNAME>HNSS2</HOSTNAME>
</HARDWARE>
<PRODUCTS>
<PRODUCT PRD_ID="123" QUANTITY="10">
<PERIOD></PERIOD>
<PROD_ATTRIBUTES>
<SUPP>ven1</SUPP>
<EDITION>ENTERPRISE</EDITION>
<VERSION>1.0</VERSION>
</PROD_ATTRIBUTES>
</PRODUCT>
</PRODUCTS>
</TargetServer>
</TargetServers>
</Request>
What I am trying to do is retrieve only those products associated with a given hostname but the xpath query I have come up with returns ALL the products for the entire document.
I am using the following code
xpath.selectnodes(doc,'/Request/TargetServers/TargetServer/PRODUCTS/PRODUCT');
Which I think is correctly returning (in the example above) all three product nodes.
My question is how do I make the xpath query ONLY select the nodes for a given specific hostname ?
I tried adding an HN attribute to the TARGETSERVER node and then using the following syntax
xpath.selectnodes(doc,'/Request/TargetServers/TargetServer[@HN="HN1"]/PRODUCTS/PRODUCT');
but that didn't work..
Any other suggestions gratefully received.
ThanksHi,
Based on the sample document you provided, this should work :
/Request/TargetServers/TargetServer[HARDWARE/HOSTNAME="HNSS1"]/PRODUCTS/PRODUCT
I am using the following code
xpath.selectnodes(doc,'/Request/TargetServers/TargetServer/PRODUCTS/PRODUCT');You said you're using PL/SQL, but isn't that a Java method? -
Syntax for Page 1/3, 2/3 etc. in Report
Hi,
I have a report, in which Page number is coming like this:--
Page 1
But i want it like this:--
Page 1/3 , Page 2/3 & Page 3/3.
In my report, syntax is written SY-PAGNO for Page 1. Then what will be the syntax for Page 1/3 etc.
ThanksI cann't paste the whole code here becuase it have more than 40000 characters.
Hint : - It is the copy of Standard program RQPDRK00.
I paste some code here.....(before START-OF-SELECTION.)....Here are the changed in this code---
REPORT ZKC_RQPDRK00 NO STANDARD PAGE HEADING LINE-SIZE 147 line-count
56(10).
Kopie aus RCPDRK00, Ohne Materialkomponenten, ergänzt um Typ Q
und Kreuz bei Merkmalen und Merkmalswerte. Wird aufgerufen von
RQPDRK02.
Tranparente DB-Tabellen
TABLES: MAPL, "Material-Alt. Zuordnung
PLKOD, "Plankopf
PLFLD, "Planfolge
PLPOD, "Vorgang
RCR01, "Arbeitsplatz Vorgang
PLPODS, "Untervorgang
RCR01S, "Arbeitsplatz Untervorgang
PLMZD, "Materialkomponentenzuor
PLMK, "QM-Merkmale
PLMKB, "QM-Merkmale: Belegstruktur
PLMW, "QM-Merkmalswerte
PLFHD, "Fertigungshilsmittelzuordnung
RQPAS, "Steuertabelle QM
QPMK , "Stammprüfmerkmale
QPMT , "Stammprüfmerkmale: Texte
QPMZ , "Zuordnungstabelle Stammdaten QM
MARA ,
CDPOS,
CDHDR,
TWEWT,
QMTT.
ATAB-Tabellen
TABLES:
TCA01, "Plantyp
TCA02, "Text zum Plantyp
TCA08, "Folgenartenbeschreibung
TCA09. "Plananwendung
Strukturtabellen (Reine Workareas)
TABLES: RC27M, "Struktur für Materialstammview
QMKST. "Steuerkennzeichen Planmerkmal
DATA: TAB_MAPL LIKE MAPL OCCURS 10 ,
L_MAPL_WA LIKE MAPL ,
L_PLNNR LIKE MAPL-PLNNR ,
L_MATNR LIKE MAPL-MATNR .
DATA : BEGIN OF I_CDPOS OCCURS 0.
INCLUDE STRUCTURE CDPOS.
DATA : UDATE LIKE CDHDR-UDATE.
DATA END OF I_CDPOS.
DATA WS_LINES LIKE SY-LINNO.
DATA FIRST_PAGE_FLAG VALUE 'Y'.
DATA BAL_LINE TYPE I.
data grp like PLKOD-PLNNR.
DATA : PAGECOUNT(5) TYPE c.
Select-Options
Auswahlmenü Anforderungsbild
SELECTION-SCREEN SKIP.
SELECTION-SCREEN BEGIN OF BLOCK AUSWAHL WITH FRAME TITLE TEXT-X22.
SELECT-OPTIONS:VAGRP FOR PLKOD-VAGRP, "Planergruppe
STATU FOR PLKOD-STATU, "Status
WERKS FOR PLKOD-WERKS, "Werk
VERWE FOR PLKOD-VERWE. "Planverwendung
SELECTION-SCREEN END OF BLOCK AUSWAHL.
Include QM Routinen zum Drucken der Merkmale
INCLUDE ZKC_IQPDRK00.
*INCLUDE IQPDRK00.
*-- Ergänzung QM: Plantyp Q wird als Default gesetzt
INITIALIZATION.
PN_PLNTY = 'Q' .
top-of-page.
ULINE.
PRINT-CONTROL FUNCTION: 'SABLD' LINE 2.
'SAOFF' LINE 2,
'SAULN' LINE 3.
write : SY-VLINE,
30 'BCH ELECTRIC LIMITED',
77 SY-VLINE,
95 'QUALITY ASSURANCE',
125 SY-VLINE,
130 'Page ',SY-PAGNO, '/ ', '-----',
147 SY-VLINE.
ULINE.
end-of-page.
skip 2.
ULINE.
WRITE : SY-VLINE,
50 SY-VLINE,
100 SY-VLINE,
147 SY-VLINE.
120 SY-VLINE,
82 'Confidential',
95 SY-VLINE,
122 'Restricted',
147 SY-VLINE.
WRITE : SY-VLINE,
50 SY-VLINE,
100 SY-VLINE,
147 SY-VLINE.
98 TEXT-K10,
106 grp,
92 'Confidentiality',
120 SY-VLINE,
123 'Confidentiality',
147 SY-VLINE.
ULINE AT 81(67).
WRITE : SY-VLINE,
50 SY-VLINE,
100 SY-VLINE,
147 SY-VLINE.
120 SY-VLINE,
84 'Internal',
95 SY-VLINE,
117 'Public',
147 SY-VLINE.
uline.
WRITE : SY-VLINE,
15 'Prepared by',
50 SY-VLINE,
70'Reviewed by',
100 SY-VLINE,
120 'Approved by',
147 SY-VLINE.
98 'Confidentiality',
120 sy-vline,
123 'Restricted',
122 'Page ',
147 SY-VLINE.
uline.
set margin 15 2.
START-OF-SELECTION.
END-OF-SELECTION.
WRITE SY-PAGNO TO PAGECOUNT LEFT-JUSTIFIED.
DO SY-PAGNO TIMES.
READ LINE 1 OF PAGE SY-INDEX.
REPLACE '-----' WITH PAGECOUNT INTO SY-LISEL.
MODIFY CURRENT LINE.
ENDDO.
This is changed code....
Please check... -
Syntax for DAQmxRepea​tTask
I want to build a limited oscilloscope for PCI-4474 with four analog inputs and analog-level trigger on one of those four analog inputs. With CVI example "Acq-IntClk-AnlgStart" I have most of the code.
Next with a start- and stop-button, I want that it repeats acquisition of 1000 samples at the analog-trigger, plots the four curves, and goes for the next trigger. The option (that I found in this forum) for DAQmxSetTrigAttribute retriggerable is (according CVI debug information) not supported for this board.
Next (probably not unique) ideais to split the example in a few functions with the use of DAQmxRegisterDoneEvent:
// create task with a.o.
DAQmxErrChk (DAQmxCreateTask("",&gTaskHandle));
DAQmxErrChk (DAQmxCreateAIVoltageChan(gTaskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(gTaskHandle,"",rate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,gSampsPerChan));
DAQmxErrChk (DAQmxCfgAnlgEdgeStartTrig(gTaskHandle,triggerSource,triggerSlope,triggerLevel));
DAQmxErrChk (DAQmxSetTrigAttribute (gTaskHandle,DAQmx_AnlgEdge_StartTrig_Hyst,triggerHysteresis));
DAQmxErrChk (DAQmxGetTaskAttribute(gTaskHandle,DAQmx_Task_NumChans,&gNumChannels));
// start-button with a.o.
DAQmxErrChk (DAQmxRegisterDoneEvent(gTaskHandle,0,DoneCallback,NULL));
DAQmxErrChk (DAQmxStartTask(gTaskHandle));
// DoneCallback which is called when task has finished the acquisition of its finite number of samples
DAQmxErrChk (DAQmxReadAnalogF64(gTaskHandle, ... ...
DeleteGraphPlot (panelHandle, PANEL_GRAPH, -1, VAL_DELAYED_DRAW);
if( numRead>0 )
for(i=0;i<gNumChannels;i++)
PlotY(panelHandle,PANEL_GRAPH,&(gData ... ...
RefreshGraph(panelHandle,PANEL_GRAPH);
DAQmxErrChk (DAQmxStartTask(gTaskHandle));
This does NOT work unless I insert in this DoneCallback DAQmxStopTask before start the task. This is not what I has expected because the callback function is called because the task has finished. And this is not what I prefer, because the CVI manual reports that stopping and starting a task will reduce the performance. Therefore I have two questions:
Q: can somebody explain (or refer to a text) what the difference is between task-done and task-stopped in combination with task-start?
Q: what is the best syntax for (not yet found) DAQmxRepeatTask when re-trigger is required for synchonisation and when this special attribute is not supperted for PCI-4474?
Regards, Jos
Solved!
Go to Solution.Hi Jos,
Here's what the NI-DAQmx Help says about task done:
When Is A Task Done?
If the measurement or generation is finite, the task is done when you acquire or generate the final sample or when you call the Stop Task function/VI. If the measurement or generation is continuous (including on-demand timing), the task is not done until you call the Stop Task function/VI. In addition, the task is done if a fatal error is generated while performing the measurement or generation, or you abort the measurement or generation. Check for errors and warnings to verify the task completed successfully.
> This does NOT work unless I insert in this DoneCallback DAQmxStopTask before start the task. This is not what I has expected because the callback function is called because the task has finished.
The callback function is called because the task is finite and the final sample has been acquired. Acquiring the final sample doesn't automatically transition the task from the "running" state to the "committed" state, so you still have to stop the task before you can start it again. See the section of the NI-DAQmx Help entitled "Task State Model" for an explanation of the different states.
> And this is not what I prefer, because the CVI manual reports that stopping and starting a task will reduce the performance.
Yes, but in this case I think stopping is necessary. In other cases, it's not necessary. For example, you wouldn't want to stop and start the task between every sample.
There is a way to reduce the overhead of stopping and starting the task: commit the task by calling DAQmxTaskControl(..., DAQmx_Val_Task_Commit) up front. This way, you don't waste time uncommitting, unreserving, re-reserving, and re-committing the task every time.
Anyway, does the performance meet your requirements? If not, what are your performance requirements?
Brad
Brad Keryan
NI R&D -
Required syntax for calling a subscreen.
hi,
Can any one tell me the syntax for calling a subscreen.
my task is to display both bar chart and pie chart adjacently in a single screen.
Thanks.
samyu.First you define a Subscreen area in the layout of the Screen where you want to call the Subscreen.
For example the main Screen is ' 0100'.
The Subscreen Area is ' SSA1' and the Subscreen is ' 0200'.
Then in the Flow logic of screen ' 0100' write the following code.
PROCESS BEFORE OUTPUT.
MODULE STATUS_0100.
CALL SUBSCREEN SSA1 INCLUDING SY_REPID '0200'.
PROCESS AFTER INPUT.
MODULE USER_COMMAND_0100.
CALL SUBSCREEN SSA1.
===========================================
The Syntax is :
CALL SUBSCREEN Subscreen Area INCLUDING Program name 'Subscreen Number'..
Plz reward if it helps.. -
Syntax for commiet for sales order creation from VB
syntax for commit for sales order creation from VB.
i have created sales order from vb using "sap bapi control" object, i am getting message too that sales order created of this number
BUT it will not reflect in particular table or tcode?
what should i do to commiet that sales order creation from vb while using sap bapi control.
i have tried sap function call too,
now how to commiet or is there any other way?
regards,
dushyant.Hi,
Check this link, explains step by step.
http://abaplovers.blogspot.com/2008/02/bap-sales-order-create.html
Thanks,
Krishna -
Can't figure out the correct syntax for this select statement
Hello,
The following statement works great and gives the desired results:
prompt
prompt Using WITH t
prompt
with t as
select a.proj_id,
a.proj_start,
a.proj_end,
case when (
select min(a.proj_start)
from v b
where (a.proj_start = b.proj_end)
and (a.proj_id != b.proj_id)
is not null then 0 else 1
end as flag
from v a
order by a.proj_start
select proj_id,
proj_start,
proj_end,
flag,
-- the following select statement is what I am having a hard time
-- "duplicating" without using the WITH clause
select sum(t2.flag)
from t t2
where t2.proj_end <= t.proj_end
) s
from t;As an academic exercise I wanted to rewrite the above statement without using the WITH clause, I tried this (among dozens of other tries - I've hit a mental block and can't figure it out):
prompt
prompt without with
prompt
select c.proj_id,
c.proj_start,
c.proj_end,
c.flag,
-- This is what I've tried as the equivalent statement but, it is
-- syntactically incorrect. What's the correct syntax for what this
-- statement is intended ?
select sum(t2.flag)
from c t2
where t2.proj_end <= c.proj_end
) as proj_grp
from (
select a.proj_id,
a.proj_start,
a.proj_end,
case when (
select min(a.proj_start)
from v b
where (a.proj_start = b.proj_end)
and (a.proj_id != b.proj_id)
is not null then 0 else 1
end as flag
from v a
order by a.proj_start
) c;Thank you for helping, much appreciated.
John.
PS: The DDL for the table v used by the above statements is:
drop table v;
create table v (
proj_id number,
proj_start date,
proj_end date
insert into v values
( 1, to_date('01-JAN-2005', 'dd-mon-yyyy'),
to_date('02-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 2, to_date('02-JAN-2005', 'dd-mon-yyyy'),
to_date('03-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 3, to_date('03-JAN-2005', 'dd-mon-yyyy'),
to_date('04-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 4, to_date('04-JAN-2005', 'dd-mon-yyyy'),
to_date('05-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 5, to_date('06-JAN-2005', 'dd-mon-yyyy'),
to_date('07-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 6, to_date('16-JAN-2005', 'dd-mon-yyyy'),
to_date('17-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 7, to_date('17-JAN-2005', 'dd-mon-yyyy'),
to_date('18-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 8, to_date('18-JAN-2005', 'dd-mon-yyyy'),
to_date('19-JAN-2005', 'dd-mon-yyyy'));
insert into v values
( 9, to_date('19-JAN-2005', 'dd-mon-yyyy'),
to_date('20-JAN-2005', 'dd-mon-yyyy'));
insert into v values
(10, to_date('21-JAN-2005', 'dd-mon-yyyy'),
to_date('22-JAN-2005', 'dd-mon-yyyy'));
insert into v values
(11, to_date('26-JAN-2005', 'dd-mon-yyyy'),
to_date('27-JAN-2005', 'dd-mon-yyyy'));
insert into v values
(12, to_date('27-JAN-2005', 'dd-mon-yyyy'),
to_date('28-JAN-2005', 'dd-mon-yyyy'));
insert into v values
(13, to_date('28-JAN-2005', 'dd-mon-yyyy'),
to_date('29-JAN-2005', 'dd-mon-yyyy'));
insert into v values
(14, to_date('29-JAN-2005', 'dd-mon-yyyy'),
to_date('30-JAN-2005', 'dd-mon-yyyy'));Hi, John,
Not that you asked, but as you proabably know, analytic functions are much better at doing this kind of thing.
You may be amazed (as I continually am) by how simple and efficient these queries can be.
For example:
WITH got_grp AS
SELECT proj_id, proj_start, proj_end
, proj_end - SUM (proj_end - proj_start) OVER (ORDER BY proj_start) AS grp
FROM v
SELECT ROW_NUMBER () OVER (ORDER BY grp) AS proj_grp
, MIN (proj_start) AS proj_start
, MAX (proj_end) AS proj_end
FROM got_grp
GROUP BY grp
ORDER BY proj_start
;Produces the results you want:
PROJ_GRP PROJ_START PROJ_END
1 01-Jan-2005 05-Jan-2005
2 06-Jan-2005 07-Jan-2005
3 16-Jan-2005 20-Jan-2005
4 21-Jan-2005 22-Jan-2005
5 26-Jan-2005 30-Jan-2005This is problem is an example of Neighbor-Defined Groups . You want to GROUP BY something that has 5 distinct values, to get the 5 rows above, but there's nothing in the table itself that tells you to which group each row belongs. The groups are not defined by any column in hte table, but by relationships between rows. In this case, a row is in the same group as its neighbor (the row immediatly before or after it when sorted by proj_start or proj_end) if proj_end of the earlier row is the same as proj_start of the later row. That is, there is nothing about 03-Jan-2005 that says the row with proj_id=2 is in the first group, or even that it is in the same group with its neighbor, the row with proj_id=3. Only the relation between those rows, the fact that the earlier row has end_date=03-Jan-2005 and the later row has start_date=03-Jan-2003, that says these neighbors belong to the same group.
You're figuring out when a new group starts, and then counting how many groups have already started to see to which group each row belongs. That's a prefectly natural procedural way of approaching the problem. But SQL is not a procedural language, and sometimes another approach is much more efficient. In this case, as in many others, a Constant Difference defines the groups. The difference between proj_end (or proj_start, it doesn't matter in this case) and the total duratiojn of the rows up to that date determines a group. The actual value of that difference means nothing to you or anybody else, so I used ROW_NUMBER in the query above to map those distinct values into consecutive integers 1, 2, 3, ... which are a much simpler way to identify the groups.
Note that the query above only requires one pass through the table, and only requires one sub-query. It does not need a WITH clause; you could easily make got_grp an in-line view.
If you used analytic functions (LEAD or LAG) to compute flag, and then to compute proj_grp (COUNT or SUM), you would need two sub-queries, one for each analytic function, but you would still only need one pass through the table. Also, those sub-queries could be in-line views; yiou would not need to use a WITH clause. -
I'm getting:
WARNING: com.sun.javafx.css.parser.CSSParser linearGradient Using deprecated syntax for linear gradient at <filename & line #>. Refer to the CSS Reference Guide.
But I'm copying the syntax from the only reference guide I can find (no reference is included in the JDK)
http://download.oracle.com/javafx/2.0/api/javafx/scene/doc-files/cssref.htmlThe docs in the SDK have the correct reference. You can find the ref by following the link from the class doc for Node. Here is the relevant section.
Linear Gradients <linear-gradient>
linear-gradient( [ [from <point> to <point>] | [ to <side-or-corner>], ]? [ [ repeat | reflect ], ]? <color-stop>[, <color-stop>]+)
where <side-or-corner> = [left | right] || [top | bottom]
Linear gradient creates a gradient going though all the stop colors along the line between the "from" <point> and the "to" <point>. If the points are percentages, then they are relative to the size of the area being filled. Percentage and length sizes can not be mixed in a single gradient function.
If neither repeat nor reflect are given, then the CycleMethod defaults "NO_CYCLE".
If neither [from <point> to <point>] nor [ to <side-or-corner> ] are given, then the gradient direction defaults to 'to bottom'.
Stops are per W3C color-stop syntax and are normalized accordingly.
This example will create a gradient from top left to bottom right of the filled area with red at the top left corner and black at the bottom right.
linear-gradient(to bottom right, red, black)
This is equivalent to:
linear-gradient(from 0% 0% to 100% 100%, red 0%, black 100%)
This more complex example will create a 50px high bar at the top with a 3 color gradient with white underneath for the rest of the filled area.
linear-gradient(from 0px 0px to 0px 50px, gray, darkgray 50%, dimgray 99%, white)
The following syntax for linear gradient does not conform to the CSS grammar and is deprecated in JavaFX 2.0. The JavaFX 2.0 CSS parser supports the syntax but this support may be removed in later releases.
linear (<size>, <size>) to (<size>, <size>) stops [ (<number>,<color>) ]+ [ repeat | reflect ]?
Radial Gradients <radial-gradient>
radial-gradient([ focus-angle <angle>, ]? [ focus-distance <percentage>, ]? [ center <point>, ]? radius [ <length> | <percentage> ] [ [ repeat | reflect ], ]? <color-stop>[, <color-stop>]+)
If neither repeat nor reflect are given, then the CycleMethod defaults "NO_CYCLE".
Stops are per W3C color-stop syntax and are normalized accordingly.
Following are examples of the use of radial-gradient:
radial-gradient(radius 100%, red, darkgray, black)
radial-gradient(focus-angle 45deg, focus-distance 20%, center 25% 25%, radius 50%, reflect, gray, darkgray 75%, dimgray)
The following syntax for radial gradient does not conform to the CSS grammar and is deprecated in JavaFX 2.0. The JavaFX 2.0 CSS parser supports the syntax but this support may be removed in later releases.
radial [focus-angle <number> | <number> ] ]? [ focus-distance <size> ]? [ center <size,size> ]? <size> stops [ ( <number>, <color> ) ]+ [ repeat | reflect ]? -
What is the setVariable syntax for AS3
Hi,
I am having issues with setting a variable in AS3 SWF playing inside a Dir12
spriteObjRef.setVariable(variableName, newValue)
In the context of ActionScript 3, this method is only supported on a Flash object, not on a
spriteObjectRef.
What would the Flash Object syntax be??
Thanks,
JimJusclark-Oracle wrote:
What is the correct syntax for referencing a page item (P23_ID, for example) in a PL/SQL page process, after submit?
See "About Referencing Session State" in the documentation.
Within an anonymous block in an APEX page process, use the standard bind variable syntax:
:P23_ID
In general, use bind variable syntax when referencing session state values in SQL or DML:
select
ename
into
:p23_name
from
emp
where
empno = to_number(:p23_id);
and obviously when assigning values to the item:
:P23_ID := foo.nextval;
PL/SQL function references v('p23_id') and nv('p23_id') [for number values] must be used to access values in stored program units called from APEX, although it's usually better to pass the values as parameters: foo(:p23_id).
Maybe you are looking for
-
Create purchase order from purchse requisition number
Hi guru's, I have a requirement that when ever i m creating the sales order through va01 and when i will click on save button it has to create an automatic PO from the PR number which will be there in the order. Functional consultant saying that he c
-
Installing Leopard with a blank disk?
I have an iMac G5 with a formatted HDD. I was just wondering if anyone knows how I can install leopard - I tried installing by holding down option but nothing happens. I've also tried booting while holding down the letter c but nothing happens. The C
-
Windows 8 does not go to sleep - how to identify the device/app preventing sleep
Hello, I have a quite new Windows 8 Pro installation upgraded from Windows 7, but as a clean install. It is running on a Asus K53E laptop bought almost a year ago but I ran into a problem with going to standby mode. The laptop successfully dims the d
-
Is there a way to have iPhoto automatically put date of import in the info block?
-
White line appears on macbook pro retina
When i minimized windows the white thin line appears on the screen. The line disappear right away. This is a big concern for me because my macbook pro retina 13' is still pretty new. How can i solve this problem ? I got my macbook late Sept 2013.