XML Query Help row with no data
declare @address table
AddressID int,
AddressType varchar(12),
Address1 varchar(20),
Address2 varchar(20),
City varchar(25),
AgentID int
insert into @address
select 1, 'Home', 'abc', 'xyz road', 'RJ', 1 union all
select 2, 'Office', 'temp', 'ppp road', 'RJ', 1 union all
select 3, 'Home', 'xxx', 'aaa road', 'NY', 2 union all
select 4, 'Office', 'ccc', 'oli Com', 'CL', 2 union all
select 5, 'Temp', 'eee', 'olkiu road', 'CL', 2 union all
select 6, 'Home', 'ttt', 'loik road', 'NY', 3
SELECT a.* from @address a
where a.AddressID = 1
FOR XML path('Addresses')
SELECT a.* from @address a
where a.AddressID = 9
FOR XML path('Addresses')
Issue:
As you can see for second query where AddressID = 9 is not exists so xml is not generated but
my expected result is for second query is
<Addresses>
<AddressID />
<AddressType />
<Address1 />
<Address2 />
<City />
<AgentID />
</Addresses>
Thanks in advance for all your help.
First of all: Your expectation is wrong. Sorry to say that. But your SQL statement for A.AddressID = 9 does not return a row. So no row is converted. I hope you C it: void.
From the XML viewpoint:
<Addresses>
<AddressID />
<AddressType />
<Address1 />
<Address2 />
<City />
<AgentID />
</Addresses>
is equivalent to
<Addresses />
which is equivalent to
void
You C. Sorry got infeCted some how ;)
The only meaningful result in XML would be:
<Addresses ID="1">
<AddressType>Home</AddressType>
<Address1>abc</Address1>
<Address2>xyz road</Address2>
<City>RJ</City>
<AgentID>1</AgentID>
</Addresses>
<Addresses ID="9"/>
Cause now Addresses (Really? A plural form for a single entity?) transports the meaning, well there is no data (no row) for it. We tried to find it, but we failed. In opposite to
<Addresses>
<AddressID>9</AddressID>
<AddressType />
<Address1 />
<Address2 />
<City />
<AgentID />
</Addresses>
<Addresses ID="9">
<AddressType />
<Address1 />
<Address2 />
<City />
<AgentID />
</Addresses>
Which says: well, we have a row with the ID 9, but the rest of the columns is empty.
The problem is mere semantics. But it's an important difference.
Now for your problem: Why do you expect this? Where do can you work with such a kind of informationless result?
btw, as you're using already a table variable (+1), you should also use
table value constructors like
INSERT INTO @address
VALUES ( 1, 'Home', 'abc', 'xyz road', 'RJ', 1 ),
( 2, 'Office', 'temp', 'ppp road', 'RJ', 1 ),
( 3, 'Home', 'xxx', 'aaa road', 'NY', 2 ),
( 4, 'Office', 'ccc', 'oli Com', 'CL', 2 ),
( 5, 'Temp', 'eee', 'olkiu road', 'CL', 2 ),
( 6, 'Home', 'ttt', 'loik road', 'NY', 3 );
I would use a tally table, when you really need this:
DECLARE @address TABLE
AddressID INT ,
AddressType VARCHAR(12) ,
Address1 VARCHAR(20) ,
Address2 VARCHAR(20) ,
City VARCHAR(25) ,
AgentID INT
INSERT INTO @address
VALUES ( 1, 'Home', 'abc', 'xyz road', 'RJ', 1 ),
( 2, 'Office', 'temp', 'ppp road', 'RJ', 1 ),
( 3, 'Home', 'xxx', 'aaa road', 'NY', 2 ),
( 4, 'Office', 'ccc', 'oli Com', 'CL', 2 ),
( 5, 'Temp', 'eee', 'olkiu road', 'CL', 2 ),
( 6, 'Home', 'ttt', 'loik road', 'NY', 3 );
WITH n1
AS ( SELECT *
FROM ( VALUES ( 1), ( 1), ( 1), ( 1) ) Q ( n )
n2
AS ( SELECT a.n
FROM n1 a ,
n1 b ,
n1 c ,
n1 d
NumberTally
AS ( SELECT ROW_NUMBER() OVER ( ORDER BY n ) AS n
FROM n2
SELECT NT.n AS [@ID] ,
a.AddressType ,
a.Address1 ,
a.Address2 ,
a.City ,
a.AgentID
FROM NumberTally NT
LEFT JOIN @address a ON a.AddressID = NT.n
WHERE NT.n IN ( 1, 9 )
FOR XML PATH('Address');
or the void version:
DECLARE @address TABLE
AddressID INT ,
AddressType VARCHAR(12) ,
Address1 VARCHAR(20) ,
Address2 VARCHAR(20) ,
City VARCHAR(25) ,
AgentID INT
INSERT INTO @address
VALUES ( 1, 'Home', 'abc', 'xyz road', 'RJ', 1 ),
( 2, 'Office', 'temp', 'ppp road', 'RJ', 1 ),
( 3, 'Home', 'xxx', 'aaa road', 'NY', 2 ),
( 4, 'Office', 'ccc', 'oli Com', 'CL', 2 ),
( 5, 'Temp', 'eee', 'olkiu road', 'CL', 2 ),
( 6, 'Home', 'ttt', 'loik road', 'NY', 3 );
WITH n1
AS ( SELECT *
FROM ( VALUES ( 1), ( 1), ( 1), ( 1) ) Q ( n )
n2
AS ( SELECT a.n
FROM n1 a ,
n1 b ,
n1 c ,
n1 d
NumberTally
AS ( SELECT ROW_NUMBER() OVER ( ORDER BY n ) AS n
FROM n2
SELECT a.AddressID AS [@ID] ,
a.AddressType ,
a.Address1 ,
a.Address2 ,
a.City ,
a.AgentID
FROM NumberTally NT
LEFT JOIN @address a ON a.AddressID = NT.n
WHERE NT.n IN ( 1, 9 )
FOR XML PATH('Address');
Similar Messages
-
Query Not reflected with Updated Data
Dear Experts,
I am facing a Problem in query data updation. Data has been daily updating in infoprovider successfully ,But when user run query through Bex he is always shown old data. Then I go to RSRT and generate the query and data got updated.
Every Time for new data updation I need to Generate the query.
What could be reason for this. Is this related to cache data ?
Any Advise .
Thanks in Advance.Dear Michael,
This problem is coming only for one Multiprovider. Running this program would affect all other queries also . This will Delay the reporting.
Any other reason why query is reflected with old data Though infoprovide is loaded with new data. -
Help needed with binary data in xml (dtd,xml inside)
I am using the java xml sql utility. I am trying to load some info into a table.
my.dtd:
<!ELEMENT ROWSET (ROW*)>
<!ELEMENT ROW (ID,JPEGS?)>
<!ELEMENT ID (#PCDATA)>
<!ELEMENT DESCRIPTION EMPTY>
<!ATTLIST DESCRIPTION file ENTITY #REQUIRED>
<!NOTATION INFOFILE SYSTEM "Files with binary data inside">
<!ENTITY file1 SYSTEM "abc.jpg" NDATA INFOFILE>
xml file:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE ROWSET SYSTEM "MY.DTD">
<ROWSET>
<ROW>
<ID>1272</ID>
<DESCRIPTION file="file1"/>
</ROW>
</ROWSET>
I am using the insertXML method to do this. However, the only value that gets loaded is the ID. abc.jpg is in the same directory where I ran the java program.
Thanks in advance.Sorry! wrong dtd. It should read this instead:
my.dtd:
<!ELEMENT ROWSET (ROW*)>
<!ELEMENT ROW (ID,DESCRIPTION?)>
<!ELEMENT ID (#PCDATA)>
<!ELEMENT DESCRIPTION EMPTY>
<!ATTLIST DESCRIPTION file ENTITY #REQUIRED>
<!NOTATION INFOFILE SYSTEM "Files with binary data inside">
<!ENTITY file1 SYSTEM "abc.jpg" NDATA INFOFILE>
null -
Query help - problems with ROLLUP
I'm trying to make a query i can use for an alert, it generates sales for the past 7 days.
This query works fine:
SELECT
CASE WHEN GROUPING(T0.[CardCode]) = 0
THEN CAST (T0.[CardCode] AS CHAR(8))
ELSE 'ALL'
END AS Customer#,
SUM(T0.[Max1099]) AS "Total Sales",
SUM(T0.[GrosProfit]) AS "Gross Profit"
FROM OINV T0
WHERE T0.[DocDate] >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())-7,0) AND T0.[Max1099] > 0
GROUP BY T0.[CardCode] WITH ROLLUP
And it gives me this:
# Customer#* Total Sales* Gross Profit*
1 C2235 8,285.87 4,165.77
2 C2236 10,191.39 4,197.95
3 C2253 570.56 311.17
4 C3008 18,756.76 5,720.21
5 ALL 37,804.58 14,395.10
Which is great. Gives me a total at the end, and substitutes "ALL" for the customer number. Lovely.
Problem #1: I REALLY want it to give the Customer Name NEXT TO the Customer Number. But when I try to add it, i have to add it to the GROUP BY as well. Which changes the query to this:
SELECT
CASE WHEN GROUPING(T0.[CardCode]) = 0
THEN CAST (T0.[CardCode] AS CHAR(8))
ELSE 'ALL'
END AS Customer#,
CardName as "Cust Name",
SUM(T0.[Max1099]) AS "Total Sales",
SUM(T0.[GrosProfit]) AS "Gross Profit"
FROM OINV T0
WHERE T0.[DocDate] >= DATEADD(dd,DATEDIFF(dd,0,GETDATE())-7,0) AND T0.[Max1099] > 0
GROUP BY T0.[CardCode], T0.[CardName] WITH ROLLUP
And changes my output to THIS:
# Customer# Cust Name Total Sales Gross Profit
1 C2235 Acme Products 8,285.87 4,165.77
2 C2235 (blanks blanks) 8,285.87 4,165.77
3 C2236 Some Other Products 10,191.39 4,197.95
4 C2236 (blanks blanks blanks) 10,191.39 4,197.95
5 C2253 Third Customer Name 570.56 311.17
6 C2253 (blanks blanks blanks) 570.56 311.17
7 C3008 Fourth Customer Name 18,756.76 5,720.21
8 C3008 (blanks blanks blanks) 18,756.76 5,720.21
9 ALL 37,804.58 14,395.10
( I have replaced actual customer names, of course, and replaces actual blanks with the word 'blanks' so it would be more legible.)
I can't figure out a way to simply list the customer name next to the number. Instead , it gives me a summary for the CardCode and a summary for the CardName.
I've tried combining the two into one field, on the fly, but haven't been successful.
Problem #2 - extra credit!
If i really want this done right, i should also have a query that pulls the same data from ORIN (Credit Memos) and do a UNION ALL, but when i do this, is simply rejects me at the word "UNION"
any and all help appreciated, and to test this, you can just cut and past the query into SAP, it will run right there, no mods needed.
oops. I had to change the "Not Equal" symbol to just "greater than" for "Max1099" because it was just dropping the symbol...
Edited by: Dante Amodeo on Jan 18, 2012 6:30 PMTry:
SELECT CAST (T0.CardCode AS CHAR(8)) AS Customer#,
MAX(T0.CardName) 'Customer Name',
SUM(T0.Max1099) AS 'Total Sales',
SUM(T0.GrosProfit) AS 'Gross Profit'
FROM OINV T0
WHERE DATEDIFF(dd,T0.DocDate,GETDATE())<=7 AND T0.Max1099 > 0
GROUP BY T0.CardCode
UNION ALL
SELECT 'ALL','',SUM(T0.Max1099),
SUM(T0.GrosProfit)
FROM OINV T0
WHERE DATEDIFF(dd,T0.DocDate,GETDATE())<=7 AND T0.Max1099 > 0 -
Not Getting Rows With No Date Match
I have SQL 2012 and am trying to use a CTE to get patient meal calendar rows even if the row does not match a given date range. We use a Calendar table that has 1 row for each date in the year so I wanted it to drive the results so that when I ask for a
week date range I will get rows even if the patient does not have a meal or snack scheduled for that date. My CTE code is below and it gives me the correct data but only if the patient has a meal or snack scheduled for that date (this is like a weekly
meal menu). Any help is appreciated.
ALTER PROCEDURE [dbo].[kd_selMealPlannerMatrix]
@PatientID int,
@StartDate smalldatetime,
@EndDate smalldatetime = null
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
IF @EndDate IS NULL
BEGIN
SET @EndDate = DATEADD(day,6,@StartDate);
END
;WITH client_meals AS (
SELECT DATEPART(dw, dbo.tblMealCalendar.MealDate) AS PrintDate,
dbo.tlkpMealCodes.MealCode,
CASE WHEN dbo.tblMealCalendar.MealID <> 0 THEN dbo.tblActualMeals.MealName + N' - ' + CONVERT(nvarchar, dbo.tblActualMeals.MealNumber)
WHEN dbo.tblMealCalendar.SnackID <> 0 THEN dbo.tblActualSnacks.SnackName + N' - ' + CONVERT(nvarchar, dbo.tblActualSnacks.SnackNumber)
ELSE NULL
END AS PrintMeal,
dbo.tblMealCalendar.PatientID,
dbo.tblMealCalendar.MealDate,
dbo.tblMealCalendar.CalendarID,
dbo.tlkpMealCodes.MealCodeSort,
dbo.tblActualMeals.MealID,
dbo.tblActualSnacks.SnackID,
dbo.tblMealCalendar.MealCodeID
FROM dbo.tblMealCalendar LEFT OUTER JOIN
dbo.tblActualMeals ON dbo.tblMealCalendar.MealID = dbo.tblActualMeals.MealID LEFT OUTER JOIN
dbo.tblActualSnacks ON dbo.tblMealCalendar.SnackID = dbo.tblActualSnacks.SnackID LEFT OUTER JOIN
dbo.tlkpMealCodes ON dbo.tblMealCalendar.MealCodeID = dbo.tlkpMealCodes.MealCodeID
WHERE (dbo.tblActualSnacks.Verified IS NULL OR dbo.tblActualSnacks.Verified <> 0)
AND (dbo.tblActualMeals.Verified IS NULL OR dbo.tblActualMeals.Verified <> 0)
AND (dbo.tblMealCalendar.PatientID = @PatientID)
), dt_range AS (
SELECT dt, DW
FROM dbo.Calendar
WHERE dt BETWEEN @StartDate AND @EndDate
SELECT
MAX(M.MealDate) AS MealDate,
MAX(M.PrintDate) AS PrintDay,
MAX(D.DW) AS WkDay,
MAX(CASE WHEN MealCode = 'AM Meal' THEN PrintMeal
ELSE NULL
END) AS AMMeal,
MAX(CASE WHEN MealCode = 'AM Meal' THEN MealID
ELSE 0
END) AS AMMealID,
MAX(CASE WHEN MealCode = 'AM Snack' THEN PrintMeal
ELSE NULL
END) AS AMSnack,
MAX(CASE WHEN MealCode = 'AM Snack' THEN SnackID
ELSE 0
END) AS AMSnackID,
MAX(CASE WHEN MealCode = 'Mid-Day' THEN PrintMeal
ELSE NULL
END) AS MidDay,
MAX(CASE WHEN MealCode = 'Mid-Day' THEN MealID
ELSE 0
END) AS MidDayMealID,
MAX(CASE WHEN MealCode = 'PM Snack' THEN PrintMeal
ELSE NULL
END) AS PMSnack,
MAX(CASE WHEN MealCode = 'PM Snack' THEN SnackID
ELSE 0
END) AS PMSnackID,
MAX(CASE WHEN MealCode = 'PM Meal' THEN PrintMeal
ELSE NULL
END) AS PMMeal,
MAX(CASE WHEN MealCode = 'PM Meal' THEN MealID
ELSE 0
END) AS PMMealID,
MAX(CASE WHEN MealCode = 'Evening Snack' THEN PrintMeal
ELSE NULL
END) AS EveningSnack,
MAX(CASE WHEN MealCode = 'Evening Snack' THEN SnackID
ELSE 0
END) AS EveningSnackID,
MAX(CASE WHEN MealCode = '4th Meal' THEN PrintMeal
ELSE NULL
END) AS FourthMeal,
MAX(CASE WHEN MealCode = '4th Meal' THEN MealID
ELSE 0
END) AS FourthMealID
FROM dt_range AS D RIGHT OUTER JOIN
client_meals AS M ON D.dt = M.MealDate
GROUP BY D.dt
HAVING (D.dt BETWEEN @StartDate AND @EndDate)
ORDER BY D.dt;
ENDI tried to keep this as close to what we know as I could. Here's an example of making it work as you're asking:
DECLARE @tinyCalendar table (date date)
DECLARE @i INT = 0
WHILE @i < 10
BEGIN
INSERT INTO @tinyCalendar (date)
VALUES (DATEADD(DAY,-@i,GETDATE()))
SET @i = @i + 1
END
DECLARE @patients TABLE (id INT IDENTITY, name VARCHAR(20))
INSERT INTO @patients (name)
VALUES ('John'),('Paul'),('George'),('Ringo')
DECLARE @mealSelections TABLE (patientID INT, mealID INT, mealCode VARCHAR(8), DATE DATE)
INSERT INTO @mealSelections (patientID, mealID, mealCode, date)
VALUES
(1,1,'1st Meal','2014-08-12'),(1,2,'1st Meal','2014-08-13'),(1,3,'1st Meal','2014-08-14'),(1,4,'1st Meal','2014-08-15'),(2,1,'1st Meal','2014-08-12'),(2,2,'1st Meal','2014-08-13'),(2,3,'1st Meal','2014-08-14'),(2,4,'1st Meal','2014-08-15'),(3,1,'1st Meal','2014-08-12'),(3,2,'1st Meal','2014-08-13'),(3,3,'1st Meal','2014-08-14'),(3,4,'1st Meal','2014-08-15'),(4,1,'1st Meal','2014-08-12'),(4,2,'1st Meal','2014-08-13'),(4,3,'1st Meal','2014-08-14'),(4,4,'1st Meal','2014-08-15'),
(1,1,'1st Meal','2014-08-16'),(1,2,'1st Meal','2014-08-17'),(1,3,'1st Meal','2014-08-18'),(1,4,'1st Meal','2014-08-19'),(2,1,'1st Meal','2014-08-16'),(2,2,'1st Meal','2014-08-17'),(2,3,'1st Meal','2014-08-18'),(2,4,'1st Meal','2014-08-19'),(3,1,'1st Meal','2014-08-16'),(3,2,'1st Meal','2014-08-17'),(3,3,'1st Meal','2014-08-18'),(3,4,'1st Meal','2014-08-19'),(4,1,'1st Meal','2014-08-16'),(4,2,'1st Meal','2014-08-17'),(4,3,'1st Meal','2014-08-18'),(4,4,'1st Meal','2014-08-19'),
(1,1,'2nd Meal','2014-08-12'),(1,2,'2nd Meal','2014-08-13'),(1,3,'2nd Meal','2014-08-14'),(1,4,'2nd Meal','2014-08-15'),(2,1,'2nd Meal','2014-08-12'),(2,2,'2nd Meal','2014-08-13'),(2,3,'2nd Meal','2014-08-14'),(2,4,'2nd Meal','2014-08-15'),(3,1,'2nd Meal','2014-08-12'),(3,2,'2nd Meal','2014-08-13'),(3,3,'2nd Meal','2014-08-14'),(3,4,'2nd Meal','2014-08-15'),(4,1,'2nd Meal','2014-08-12'),(4,2,'2nd Meal','2014-08-13'),(4,3,'2nd Meal','2014-08-14'),(4,4,'2nd Meal','2014-08-15'),
(1,1,'2nd Meal','2014-08-16'),(1,2,'2nd Meal','2014-08-17'),(1,3,'2nd Meal','2014-08-18'),(1,4,'2nd Meal','2014-08-19'),(2,1,'2nd Meal','2014-08-16'),(2,2,'2nd Meal','2014-08-17'),(2,3,'2nd Meal','2014-08-18'),(2,4,'2nd Meal','2014-08-19'),(3,1,'2nd Meal','2014-08-16'),(3,2,'2nd Meal','2014-08-17'),(3,3,'2nd Meal','2014-08-18'),(3,4,'2nd Meal','2014-08-19'),(4,1,'2nd Meal','2014-08-16'),(4,2,'2nd Meal','2014-08-17'),(4,3,'2nd Meal','2014-08-18'),(4,4,'2nd Meal','2014-08-19'),
(1,1,'3rd Meal','2014-08-12'),(1,2,'3rd Meal','2014-08-13'),(1,3,'3rd Meal','2014-08-14'),(1,4,'3rd Meal','2014-08-15'),(2,1,'3rd Meal','2014-08-12'),(2,2,'3rd Meal','2014-08-13'),(2,3,'3rd Meal','2014-08-14'),(2,4,'3rd Meal','2014-08-15'),(3,1,'3rd Meal','2014-08-12'),(3,2,'3rd Meal','2014-08-13'),(3,3,'3rd Meal','2014-08-14'),(3,4,'3rd Meal','2014-08-15'),(4,1,'3rd Meal','2014-08-12'),(4,2,'3rd Meal','2014-08-13'),(4,3,'3rd Meal','2014-08-14'),(4,4,'3rd Meal','2014-08-15'),
(1,1,'3rd Meal','2014-08-16'),(1,2,'3rd Meal','2014-08-17'),(1,3,'3rd Meal','2014-08-18'),(1,4,'3rd Meal','2014-08-19'),(2,1,'3rd Meal','2014-08-16'),(2,2,'3rd Meal','2014-08-17'),(2,3,'3rd Meal','2014-08-18'),(2,4,'3rd Meal','2014-08-19'),(3,1,'3rd Meal','2014-08-16'),(3,2,'3rd Meal','2014-08-17'),(3,3,'3rd Meal','2014-08-18'),(3,4,'3rd Meal','2014-08-19'),(4,1,'3rd Meal','2014-08-16'),(4,2,'3rd Meal','2014-08-17'),(4,3,'3rd Meal','2014-08-18'),(4,4,'3rd Meal','2014-08-19'),
(1,1,'4th Meal','2014-08-12'),(1,2,'4th Meal','2014-08-13'),(1,3,'4th Meal','2014-08-14'),(1,4,'4th Meal','2014-08-15'),(2,1,'4th Meal','2014-08-12'),(2,2,'4th Meal','2014-08-13'),(2,3,'4th Meal','2014-08-14'),(2,4,'4th Meal','2014-08-15'),(3,1,'4th Meal','2014-08-12'),(3,2,'4th Meal','2014-08-13'),(3,3,'4th Meal','2014-08-14'),(3,4,'4th Meal','2014-08-15'),(4,1,'4th Meal','2014-08-12'),(4,2,'4th Meal','2014-08-13'),(4,3,'4th Meal','2014-08-14'),(4,4,'4th Meal','2014-08-15'),
(1,1,'4th Meal','2014-08-16'),(1,2,'4th Meal','2014-08-17'),(1,3,'4th Meal','2014-08-18'),(1,4,'4th Meal','2014-08-19'),(2,1,'4th Meal','2014-08-16'),(2,2,'4th Meal','2014-08-17'),(2,3,'4th Meal','2014-08-18'),(2,4,'4th Meal','2014-08-19'),(3,1,'4th Meal','2014-08-16'),(3,2,'4th Meal','2014-08-17'),(3,3,'4th Meal','2014-08-18'),(3,4,'4th Meal','2014-08-19'),(4,1,'4th Meal','2014-08-16'),(4,2,'4th Meal','2014-08-17'),(4,3,'4th Meal','2014-08-18'),(4,4,'4th Meal','2014-08-19')
SELECT p.id, p.name, c.date,
Max(CASE WHEN mealCode = '1st Meal' THEN mealID END) AS FirstMeal,
Max(CASE WHEN mealCode = '2nd Meal' THEN mealID END) AS SecondMeal,
Max(CASE WHEN mealCode = '3rd Meal' THEN mealID END) AS ThirdMeal,
Max(CASE WHEN mealCode = '4th Meal' THEN mealID END) AS FourthMeal
FROM @patients p
INNER JOIN @tinyCalendar c
ON p.id = p.id
LEFT OUTER JOIN @mealSelections m
ON p.id = m.patientID
AND m.date = c.date
GROUP BY p.id, p.name, c.date
ORDER BY c.date -
Hi,
Need help in writing a query.
SQL> SELECT xmlelement("P",xmlforest(P.process_id AS Ppid),
2 xmlagg(xmlelement("PI",XMLFOREST( PI.question_id AS PIqid,
3 PI.process_id AS PIpid,
4 PI.innertext AS PItext),
5 xmlagg(Xmlelement("PO",xmlforest( PO.option_id AS POoid,
6 PO.question_id AS POqid,
7 PO.process_id AS popid
8 ))
9 ORDER BY PO.option_id))
10 ORDER BY PI.question_id ) )
11 FROM liveProcess_ec P
12 INNER JOIN vw_liveProcessItem_Sim_v6 PI
13 ON P.process_id = PI.process_id
14 LEFT OUTER JOIN vw_liveProcessOption_Sim_v6 PO
15 ON PI.question_id = PO.question_id
16 AND PI.process_id = PO.process_id
17 WHERE p.process_id =450
18 GROUP BY p.process_id,PI.question_id,PI.process_id,PI.innertext
19 ORDER BY p.process_id;
SELECT xmlelement("P",xmlforest(P.process_id AS Ppid),
ERROR at line 1:
ORA-00937: not a single-group group functionThanks in advanceHi,
Here below are the create table scripts along with sample data and expected output.
CREATE TABLE VW_LIVEPROCESSOPTION_SIM_v6
( "OPTION_ID" NUMBER,
"QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"OPT_INNERTEXT" VARCHAR2(200 CHAR),
"OPT_LINKFROM" VARCHAR2(20 CHAR),
"OPT_LINKTO" VARCHAR2(20 CHAR),
"LIBQUESTION_IDFK" NUMBER,
"LIBOPTION_IDFK" NUMBER
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,2,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,3,450,'Yes',null,'5',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,5,450,'Yes',null,'6',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,6,450,'Yes',null,'7',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,8,450,'Block All',null,'9',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,9,450,'Yes',null,'10',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,11,450,'Yes',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,12,450,'Yes',null,'13',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (1,14,450,'Yes',null,'16',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,2,450,'No',null,'3',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,3,450,'No',null,'4',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,5,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,6,450,'No',null,'8',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,8,450,'Standard',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,9,450,'No',null,'11',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,11,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,12,450,'No',null,'14',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (2,14,450,'No',null,'15',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (3,8,450,'Disabled',null,'12',null,null);
Insert into VW_LIVEPROCESSOPTION_SIM_v6(OPTION_ID,QUESTION_ID,PROCESS_ID,OPT_INNERTEXT,OPT_LINKFROM,OPT_LINKTO,LIBQUESTION_IDFK,LIBOPTION_IDFK) values (4,8,450,'User Defined',null,'12',null,null);
REATE TABLE "VW_LIVEPROCESSITEM_SIM_v6"
( "QUESTION_ID" NUMBER(10,0),
"PROCESS_ID" NUMBER(10,0),
"INNERTEXT" VARCHAR2(200 CHAR),
"ITEMTYPE" VARCHAR2(50 CHAR),
"LINKFROM" VARCHAR2(500 CHAR),
"LINKTO" VARCHAR2(500 CHAR),
"ASSOCIATED" VARCHAR2(200 CHAR),
"CONTENT_ID" NUMBER,
"EXITPOINT1_ID" NUMBER(10,0),
"EXITPOINT2_ID" NUMBER(10,0),
"EXITPOINT3_ID" NUMBER(10,0),
"RESOLVEIDENTIFIER" VARCHAR2(40 CHAR),
"LIBQUESTION_IDFK" NUMBER(10,0),
"FOLLOWONCALL" NUMBER(1,0),
"USERINPUT" VARCHAR2(200 CHAR),
"ISLOCKED" NUMBER(1,0),
"PREVIOUSANSWER" NUMBER(1,0),
"VISIBLETOAGENT" NUMBER(1,0),
"RETRYATTEMPT" NUMBER(10,0),
"TAGS" VARCHAR2(50 BYTE)
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (1,450,'CBB1015 - Router Firewall Settinngs Process','Title',null,'2',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (2,450,'Is the customers PC Firewall turned off?','Question','1','2.2,2.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (3,450,'Advise the customer to turn off the PC Firewall in order to continue. Has this been done?','Question','2.2','3.2,3.1',null,278,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (4,450,'Advise the customer the PC Firewall must be switched off before this process????','ExitPoint','3.2',null,null,null,14,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (5,450,'Is the customer able to access the internet now?','Question','3.1,2.1','5.2,5.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (6,450,'Is the customer having a problem with a specific website?','Question','5.1','6.2,6.1',null,null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (7,450,'1536: CBB1008 - Browser Setup and Daignostics','SubProcess','6.1',null,'1536-1-0',null,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (8,450,'What is the security level on the CPE Management page?','Question','6.2,5.2','8.4,8.3,8.2,8.1',null,279,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (9,450,'Change the security level to Standard. Does this resolve the customers issue?','Question','8.1','9.2,9.1',null,280,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (10,450,'Issue Resolved','ExitPoint','9.1',null,null,null,1,6,122,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (11,450,'Change the security level to Disabled. Is the customer able to browse the internet?','Question','9.2,8.2','11.2,11.1',null,281,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (12,450,'Change the security level to Standard. Is the customer able to browse the internet now?','Question','11.1,8.3,8.4','12.2,12.1',null,283,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (13,450,'Issue Resolved','ExitPoint','12.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (14,450,'Ask the customer to perform a master reset. Does this resolve their issue?','Question','12.2,11.2','14.2,14.1',null,282,null,null,null,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (15,450,'Faulty CPE','ExitPoint','14.2',null,null,null,1,6,124,null,null,null,null,null,null,null,null,null);
Insert into VW_LIVEPROCESSITEM_SIM_v6 (QUESTION_ID,PROCESS_ID,INNERTEXT,ITEMTYPE,LINKFROM,LINKTO,ASSOCIATED,CONTENT_ID,EXITPOINT1_ID,EXITPOINT2_ID,EXITPOINT3_ID,RESOLVEIDENTIFIER,LIBQUESTION_IDFK,FOLLOWONCALL,USERINPUT,ISLOCKED,PREVIOUSANSWER,VISIBLETOAGENT,RETRYATTEMPT,TAGS) values (16,450,'Issue Resolved','ExitPoint','14.1',null,null,null,1,6,123,null,null,null,null,null,null,null,null,null);
CREATE TABLE "LIVEPROCESS_EC_V"
( "PROCESS_ID" NUMBER(10,0),
"USER_ID" NUMBER(10,0),
"CREATED" TIMESTAMP (6)
Insert into LIVEPROCESS_EC (PROCESS_ID,USER_ID,CREATED) values (450,7460,to_timestamp('21-APR-08 09.34.41.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'));Expected Output
<P>
<Ppid>450</Ppid>
<Pn>CBB1015 - Router Firewall Settinngs Process</Pn>
<Pg>9</Pg>
<Pl>0</Pl>
<Pb>5</Pb>
<qcount>100</qcount>
<ocount>200</ocount>
<PI>
<PIqid>1</PIqid>
<PIpid>450</PIpid>
<PIpx>366</PIpx>
<PIpy>-516</PIpy>
<PItext>CBB1015 - Router Firewall Settinngs Process</PItext>
<PItype>Title</PItype>
<PIto>2</PIto>
<PO />
</PI>
<PI>
<PIqid>2</PIqid>
<PIpid>450</PIpid>
<PIpx>366</PIpx>
<PIpy>-437</PIpy>
<PItext>Is the customers PC Firewall turned off?</PItext>
<PItype>Question</PItype>
<PIfrom>1</PIfrom>
<PIto>2.2,2.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>2</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>3</POto>
</PO>
</PI>
<PI>
<PIqid>3</PIqid>
<PIpid>450</PIpid>
<PIpx>468</PIpx>
<PIpy>-344</PIpy>
<PItext>Advise the customer to turn off the PC Firewall in order to continue. Has this been done?</PItext>
<PItype>Question</PItype>
<PIfrom>2.2</PIfrom>
<PIto>3.2,3.1</PIto>
<PIc>278</PIc>
<PO>
<POoid>1</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>5</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>3</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>4</POto>
</PO>
</PI>
<PI>
<PIqid>4</PIqid>
<PIpid>450</PIpid>
<PIpx>571</PIpx>
<PIpy>-250</PIpy>
<PItext>Advise the customer the PC Firewall must be switched off before this process????</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>3.2</PIfrom>
<PIe1>14</PIe1>
<PO />
</PI>
<PI>
<PIqid>5</PIqid>
<PIpid>450</PIpid>
<PIpx>374</PIpx>
<PIpy>-240</PIpy>
<PItext>Is the customer able to access the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>3.1,2.1</PIfrom>
<PIto>5.2,5.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>6</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>5</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>6</PIqid>
<PIpid>450</PIpid>
<PIpx>322</PIpx>
<PIpy>-141</PIpy>
<PItext>Is the customer having a problem with a specific website?</PItext>
<PItype>Question</PItype>
<PIfrom>5.1</PIfrom>
<PIto>6.2,6.1</PIto>
<PO>
<POoid>1</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>7</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>6</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>8</POto>
</PO>
</PI>
<PI>
<PIqid>7</PIqid>
<PIpid>450</PIpid>
<PIpx>128</PIpx>
<PIpy>-36</PIpy>
<PItext>1536: CBB1008 - Browser Setup and Daignostics</PItext>
<PItype>SubProcess</PItype>
<PIfrom>6.1</PIfrom>
<PIas>1536-1-0</PIas>
<PO />
</PI>
<PI>
<PIqid>8</PIqid>
<PIpid>450</PIpid>
<PIpx>461</PIpx>
<PIpy>-43</PIpy>
<PItext>What is the security level on the CPE Management page?</PItext>
<PItype>Question</PItype>
<PIfrom>6.2,5.2</PIfrom>
<PIto>8.4,8.3,8.2,8.1</PIto>
<PIc>279</PIc>
<PO>
<POoid>1</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>-112</POpx>
<POpy>89</POpy>
<POtext>Block All</POtext>
<POto>9</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>Standard</POtext>
<POto>11</POto>
</PO>
<PO>
<POoid>3</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>83</POpx>
<POpy>116</POpy>
<POtext>Disabled</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>4</POoid>
<POqid>8</POqid>
<popid>450</popid>
<POpx>-14</POpx>
<POpy>94</POpy>
<POtext>User Defined</POtext>
<POto>12</POto>
</PO>
</PI>
<PI>
<PIqid>9</PIqid>
<PIpid>450</PIpid>
<PIpx>237</PIpx>
<PIpy>76</PIpy>
<PItext>Change the security level to Standard. Does this resolve the customers issue?</PItext>
<PItype>Question</PItype>
<PIfrom>8.1</PIfrom>
<PIto>9.2,9.1</PIto>
<PIc>280</PIc>
<PO>
<POoid>1</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>10</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>9</POqid>
<popid>450</popid>
<POpx>69</POpx>
<POpy>73</POpy>
<POtext>No</POtext>
<POto>11</POto>
</PO>
</PI>
<PI>
<PIqid>10</PIqid>
<PIpid>450</PIpid>
<PIpx>158</PIpx>
<PIpy>185</PIpy>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>9.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>122</PIe3>
<PO />
</PI>
<PI>
<PIqid>11</PIqid>
<PIpid>450</PIpid>
<PIpx>821</PIpx>
<PIpy>144</PIpy>
<PItext>Change the security level to Disabled. Is the customer able to browse the internet?</PItext>
<PItype>Question</PItype>
<PIfrom>9.2,8.2</PIfrom>
<PIto>11.2,11.1</PIto>
<PIc>281</PIc>
<PO>
<POoid>1</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>12</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>11</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>12</PIqid>
<PIpid>450</PIpid>
<PIpx>474</PIpx>
<PIpy>186</PIpy>
<PItext>Change the security level to Standard. Is the customer able to browse the internet now?</PItext>
<PItype>Question</PItype>
<PIfrom>11.1,8.3,8.4</PIfrom>
<PIto>12.2,12.1</PIto>
<PIc>283</PIc>
<PO>
<POoid>1</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>13</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>12</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>14</POto>
</PO>
</PI>
<PI>
<PIqid>13</PIqid>
<PIpid>450</PIpid>
<PIpx>322</PIpx>
<PIpy>278</PIpy>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>12.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
<PI>
<PIqid>14</PIqid>
<PIpid>450</PIpid>
<PIpx>645</PIpx>
<PIpy>327</PIpy>
<PItext>Ask the customer to perform a master reset. Does this resolve their issue?</PItext>
<PItype>Question</PItype>
<PIfrom>12.2,11.2</PIfrom>
<PIto>14.2,14.1</PIto>
<PIc>282</PIc>
<PO>
<POoid>1</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POpx>-50</POpx>
<POpy>70</POpy>
<POtext>Yes</POtext>
<POto>16</POto>
</PO>
<PO>
<POoid>2</POoid>
<POqid>14</POqid>
<popid>450</popid>
<POpx>50</POpx>
<POpy>70</POpy>
<POtext>No</POtext>
<POto>15</POto>
</PO>
</PI>
<PI>
<PIqid>15</PIqid>
<PIpid>450</PIpid>
<PIpx>768</PIpx>
<PIpy>435</PIpy>
<PItext>Faulty CPE</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.2</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>124</PIe3>
<PO />
</PI>
<PI>
<PIqid>16</PIqid>
<PIpid>450</PIpid>
<PIpx>479</PIpx>
<PIpy>420</PIpy>
<PItext>Issue Resolved</PItext>
<PItype>ExitPoint</PItype>
<PIfrom>14.1</PIfrom>
<PIe1>1</PIe1>
<PIe2>6</PIe2>
<PIe3>123</PIe3>
<PO />
</PI>
</P>Thanks in advance. -
Hi guys,
Quick question which I would appreciate some help with. I am currently querying a table with multiple rows but I only want it to return 1 row (the one which was created most recently) ie. the one with the max date_Created field.
I was thinking I could do this:
Select *
from table
where date_created = max(date_created)
but you will probably know I cant do this. I know I can partition etc but since I am calling this as a cursor from oracle forms I cant use partition, can anyone help me out please?
Thanks.Hi,
Here's one way:
WITH got_r_num AS
SELECT t.*
, ROW_NUMBER () OVER (ORDER BY date_created DESC)
AS r_num
FROM table_x t
SELECT * -- or list all columns except r_num
FROM got_r_num
WHERE r_num = 1
786733 wrote:Hi guys,
Quick question which I would appreciate some help with. I am currently querying a table with multiple rows but I only want it to return 1 row (the one which was created most recently) ie. the one with the max date_Created field.
I was thinking I could do this:
Select *
from table
where date_created = max(date_created)
but you will probably know I cant do this. You can do something pretty close:
SELECT *
FROM table_x
WHERE date_created = (
SELECT MAX (date_created)
FROM table_x
;However, if there is a tie (that is, 2 or more rows that have exactly the same date_created, and none later), then this will return all of them, and you said you only want 1 row.
I know I can partition etc but since I am calling this as a cursor from oracle forms I cant use partition, can anyone help me out please?Sorry, I don;t undersand what you're saying about partitions.
If there's something that you can do in, say, SQL*Plus, but not in Forms, then hre's probably a way to "hide" it (in a view, perhaps) so that the part Forms can't hande isn't being done in Forms. -
Transpose row with multiple data into 3 columns / Excel Macros
Hi everyone, can you please help me with my manual intervention of transposing column data to row format?
Sample
Dates
01/01/2014
01/02/2014
01/03/2014
01/04/2014
01/05/2014
01/06/2014
01/07/2014
01/08/2014
01/09/2014
01/10/2014
01/11/2014
Name1
Value 1
Value 2
Value 3
Value 4
Value 5
Value 6
Value 7
Value 8
Value 9
Value 10
Value 11
Name2
Item1
Item2
Item3
Item4
Item6
Item7
Item8
Item9
Item10
Name3
Code1
Code2
Code4
Code5
Code6
Code7
Code8
Code9
Code10
Code11
Expected output
NAME
Date
DATA
Name1
01/01/2014
Value 1
Name1
01/02/2014
Value 2
Name1
01/03/2014
Value 3
Name1
01/04/2014
Value 4
Name1
01/05/2014
Value 5
Name1
01/06/2014
Value 6
Name1
01/07/2014
Value 7
Name1
01/08/2014
Value 8
Name1
01/09/2014
Value 9
Name1
01/10/2014
Value 10
Name1
01/11/2014
Value 11
Name2
01/01/2014
Item1
Name2
01/02/2014
Item2
Name2
01/03/2014
Item3
Name2
01/04/2014
Item4
Name2
01/05/2014
Item5
Name2
01/06/2014
Item6
Name2
01/07/2014
Item7
Name2
01/08/2014
Item8
Name2
01/10/2014
Item9
Name2
01/11/2014
Item10
Name2
01/12/2014
Item11
Name3
01/01/2014
Code1
Name3
01/02/2014
Code2
Name3
01/03/2014
Code3
Name3
01/04/2014
Code4
Name3
01/05/2014
Code5
Name3
01/06/2014
Code6
Name3
01/07/2014
Code7
Name3
01/08/2014
Code8
Name3
01/09/2014
Code9
Name3
01/10/2014
Code10
Name3
01/11/2014
Code11See my reply in
http://www.eileenslounge.com/viewtopic.php?f=27&t=17245
Regards, Hans Vogelaar (http://www.eileenslounge.com) -
Update row with more data - JTable with Abstracttablemodel
Hello!
I got some problems with my program, im using jtable with abstracttablemodel.
First I include content into the jtable by pressing ”New Content”, then it will pop up a dialog which I fill with information as you can see in the picture.
http://img42.imageshack.us/img42/6969/jtable.jpg
But when its done, I want to borrow it and update that row with more information as you can see if its loaned, if it is their shall be a checkbox, name and phone there. I don’t really know how to do this. Suppose I should do a similar metodh as when I’m adding and removing content. The question is how do I do that? I’ve been looking at some tips and hints on google. It seems to me that should use “fireTableRowsUpdated” but not really sure if its right and how to. When I’m borrowing the specific row I guess I need to check which row is clicked before borrowing and then fill in the information and update the table.The borrow button will also pop up a dialog with 3 fields to fill. Here is the code I wrote for adding and removing. I’ve tried with the update but its not right which I’m going to use when borrowing objects from the database. Please help!
Code from the abstracttablemodel
private ArrayList<Objects> obj = new ArrayList<Objects>();
public void add(Objects o) {
obj.add(o);
fireTableRowsInserted(obj.size()-1, obj.size()-1);
public void remove(int o) {
int index = obj.indexOf(o);
obj.remove(o);
fireTableRowsDeleted(index, index);
public void update (Objects o){
// Not sure how to do here
//int index = obj.indexOf(o);
//fireTableRowsUpdated(index,index);
}Code for the button in the main program.
if (arg.getSource() == borrow) {
// How should I do here? I need to implement the BorrowDialog, check if a row is pressed then update? How do I do that?
BorrowDialog newLoan = new BorrowDialog(frame);
if(table.getSelectedRow() == -1)
JOptionPane.showMessageDialog(frame,"Select the row before loan");
else
dir.update(newLoan.getLoan());
table.repaint();
}Code for BorrowDialog
public class BorrowDialog extends JDialog implements ActionListener {
//implements JTextFields, Buttons,Labels and Panels.
public BorrowDialog(JFrame parent) {
//Setting buttons to panels and such
public Objects getLoan(){
return loan;
public void setLoan()
// Not sure if this is right, as I leave some fields empty, will it be empty when its updating aswell?
// I tried with add data then it just will be a new row, when I will update a specific row
loan = new Objects("", "" , "" , "" , "" ,"", loanField.getText(),nameField.getText(), phoneField.getText());
public void actionPerformed(ActionEvent arg) {
if (arg.getActionCommand().equals("Save")) {
System.out.println("save");
setLoan();
dispose();
}All help is appreciated!
Edited by: iTech34 on Feb 22, 2010 3:27 AM
Edited by: iTech34 on Feb 22, 2010 3:31 AM
Edited by: iTech34 on Feb 22, 2010 3:58 AMLook up for the rest of the code!
I explained everything on the first post, so please read there so you know the problem I got.
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class Database implements ActionListener {
private final int WIDTH = 800;
private final int HEIGHT = 800;
private JTable table = new JTable();
private JFrame frame = new JFrame("Database");
private JButton addContent = new JButton("New content");
private JButton borrow = new JButton("Borrow");
private JButton returnObject = new JButton("Return");
private JButton remove = new JButton("Remove");
private JButton save = new JButton("Save");
private JButton load = new JButton("Load");
private JButton exit = new JButton("Exit");
private Directory dir = new Directory();
private JPanel buttonPanel = new JPanel();
private JPanel mainPanel = new JPanel();
public Database() {
// BUTTONS
buttonPanel.add(addContent);
buttonPanel.add(remove);
buttonPanel.add(borrow);
buttonPanel.add(returnObject);
buttonPanel.add(save);
buttonPanel.add(load);
buttonPanel.add(exit);
// ACTION LISTENERS
addContent.addActionListener(this);
remove.addActionListener(this);
borrow.addActionListener(this);
returnObject.addActionListener(this);
save.addActionListener(this);
load.addActionListener(this);
exit.addActionListener(this);
// JTABLE
table = new JTable(dir);
table.setAutoCreateRowSorter(true);
table.setRowHeight(25);
JScrollPane JScroll = new JScrollPane(table);
// PANELS
mainPanel.setLayout(new BorderLayout());
mainPanel.add("North", buttonPanel);
mainPanel.add("Center", JScroll);
// FRAME
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
frame.getContentPane().add(mainPanel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
public void actionPerformed(ActionEvent arg) {
if (arg.getSource() == addContent) {
Dialog newDialog = new Dialog(frame);
dir.add(newDialog.getItem());
if (arg.getSource() == remove) {
if (table.getSelectedRow() == -1)
JOptionPane.showMessageDialog(frame,"Select the row before remove");
else
dir.remove(table.getSelectedRow());
if (arg.getSource() == borrow) {
// Not sure how to do here! I need to check which row I've clicked and take that row into BorrowDialog as argument i suppose.. please explain
BorrowDialog newLoan = new BorrowDialog(frame);
if(table.getSelectedRow() == -1)
JOptionPane.showMessageDialog(frame,"Select the row before loan");
else
dir.update(newLoan.getLoan());
table.repaint();
if (arg.getSource() == returnObject) {
if (arg.getSource() == save) {
dir.writeFile();
if (arg.getSource() == load) {
Objects[] tempObject = dir.readFile("info.txt");
for (int i = 0; tempObject[i] != null; i++)
dir.add(tempObject);
if (arg.getSource() == exit){
frame.dispose();
public static void main(String[] argv) {
new Database();
}import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class BorrowDialog extends JDialog implements ActionListener {
private final int WIDTH = 300;
private final int HEIGHT = 400;
private JButton exitDialog = new JButton("Exit");
private JButton saveDialog = new JButton("Save");
private JTextField loanField = new JTextField();
private JTextField nameField = new JTextField();
private JTextField phoneField = new JTextField();
private JLabel loanLabel = new JLabel("Loan");
private JLabel nameLabel = new JLabel("Name");
private JLabel phoneLabel = new JLabel("Phone");
private JPanel eastPanel = new JPanel();
private JPanel southPanel = new JPanel();
private JPanel westPanel = new JPanel();
private GridLayout layout = new GridLayout(3, 1);
private Objects loan;
public BorrowDialog(JFrame parent) {
super(parent, "Borrow", true);
southPanel.add(saveDialog);
southPanel.add(exitDialog);
westPanel.add(loanLabel);
eastPanel.add(loanField);
westPanel.add(nameLabel);
eastPanel.add(nameField);
westPanel.add(phoneLabel);
eastPanel.add(phoneField);
westPanel.setLayout(layout);
eastPanel.setLayout(layout);
add("West", westPanel);
add("Center", eastPanel);
add("South", southPanel);
saveDialog.addActionListener(this);
exitDialog.addActionListener(this);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
setResizable(false);
setSize(WIDTH, HEIGHT);
getContentPane();
setVisible(true);
public Objects getLoan(){
return loan;
public void setLoan()
// Can I really do like this? Will the the specific row I've chosen be overwriten entirly with blank elements in the six columns as I left empty(see below, when I send the arguments into the constructor)?
loan = new Objects("", "" , "" , "" , "" ,"", loanField.getText(),nameField.getText(), phoneField.getText());
public void actionPerformed(ActionEvent arg) {
if (arg.getActionCommand().equals("Save")) {
System.out.println("save");
setLoan();
dispose();
if (arg.getSource() == exitDialog) {
dispose();
Edited by: iTech34 on Feb 22, 2010 11:19 AM
Edited by: iTech34 on Feb 22, 2010 11:20 AM -
Help needed with passing data between classes, graph building application?
Good afternoon please could you help me with a problem with my application, my head is starting to hurt?
I have run into some difficulties when trying to build an application that generates a linegraph?
Firstly i have a gui that the client will enter the data into a text area call jta; this data is tokenised and placed into a format the application can use, and past to a seperate class that draws the graph?
I think the problem lies with the way i am trying to put the data into co-ordinate form (x,y) as no line is being generated.
The following code is from the GUI:
+public void actionPerformed(ActionEvent e) {+
+// Takes data and provides program with CoOrdinates+
int[][]data = createData();
+// Set the data data to graph for display+
grph.showGrph(data);
+// Show the frame+
grphFrame.setVisible(true);
+}+
+/** set the data given to the application */+
+private int[][] createData() {+
+ //return data;+
+ String rawData = jta.getText();+
+ StringTokenizer tokens = new StringTokenizer(rawData);+
+ List list = new LinkedList();+
+ while (tokens.hasMoreElements()){+
+ String number = "";+
+ String token = tokens.nextToken();+
+ for (int i=0; i<token.length(); i++){+
+ if (Character.isDigit(token.charAt(i))){+
+ number += token.substring(i, i+1);+
+ }+
+ } +
+ }+
+ int [][]data = new int[list.size()/2][2];+
+ int index = -2;+
+ for (int i=0; i<data.length;i++){+
+ index += 2;+
+ data[0] = Integer.parseInt(+
+ (list.get(index).toString()));+
+ data[i][1] = Integer.parseInt(+
+ (list.get(index +1).toString()));+
+ }+
+ return data;+
The follwing is the coding for drawing the graph?
+public void showGrph(int[][] data) {+
this.data = data;
repaint();
+} +
+/** Paint the graph */+
+protected void paintComponent(Graphics g) {+
+//if (data == null)+
+ //return; // No display if data is null+
super.paintComponent(g);
+// x is the start position for the first point+
int x = 30;
int y = 30;
for (int i = 0; i < data.length; i+) {+
+g.drawLine(data[i][0],data[i][1],data[i+1][0],data[i+1][1]);+
+}+
+}+Thanks for that tip!
package LineGraph;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.util.List;
public class GUI extends JFrame
implements ActionListener {
private JTextArea Filejta;
private JTextArea jta;
private JButton jbtShowGrph = new JButton("Show Chromatogram");
public JButton jbtExit = new JButton("Exit");
public JButton jbtGetFile = new JButton("Search File");
private Grph grph = new Grph();
private JFrame grphFrame = new JFrame(); // Create a new frame to hold the Graph panel
public GUI() {
JScrollPane pane = new JScrollPane(Filejta = new JTextArea("Default file location: - "));
pane.setPreferredSize(new Dimension(350, 20));
Filejta.setWrapStyleWord(true);
Filejta.setLineWrap(true);
// Store text area in a scroll pane
JScrollPane scrollPane = new JScrollPane(jta = new JTextArea("\n\n Type in file location and name and press 'Search File' button: - "
+ "\n\n\n Data contained in the file will be diplayed in this Scrollpane "));
scrollPane.setPreferredSize(new Dimension(425, 300));
jta.setWrapStyleWord(true);
jta.setLineWrap(true);
// Place scroll pane and button in the frame
JPanel jpButtons = new JPanel();
jpButtons.setLayout(new FlowLayout());
jpButtons.add(jbtShowGrph);
jpButtons.add(jbtExit);
JPanel searchFile = new JPanel();
searchFile.setLayout(new FlowLayout());
searchFile.add(pane);
searchFile.add(jbtGetFile);
add (searchFile, BorderLayout.NORTH);
add(scrollPane, BorderLayout.CENTER);
add(jpButtons, BorderLayout.SOUTH);
// Exit Program
jbtExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
System.exit(0);
// Read Files data contents
jbtGetFile.addActionListener(new ActionListener(){
public void actionPerformed( ActionEvent e) {
String FileLoc = Filejta.getText();
LocateFile clientsFile;
clientsFile = new LocateFile(FileLoc);
if (FileLoc != null){
String filePath = clientsFile.getFilePath();
String filename = clientsFile.getFilename();
String DocumentType = clientsFile.getDocumentType();
public String getFilecontents(){
String fileString = "\t\tThe file contains the following data:";
return fileString;
// Register listener // Create a new frame to hold the Graph panel
jbtShowGrph.addActionListener(this);
grphFrame.add(grph);
grphFrame.pack();
grphFrame.setTitle("Chromatogram showing data contained in file \\filename");
/** Handle the button action */
public void actionPerformed(ActionEvent e) {
// Takes data and provides program with CoOrdinates
int[][]data = createData();
// Set the data data to graph for display
grph.showGrph(data);
// Show the frame
grphFrame.setVisible(true);
/** set the data given to the application */
private int[][] createData() {
String rawData = jta.getText();
StringTokenizer tokens = new StringTokenizer(rawData);
List list = new LinkedList();
while (tokens.hasMoreElements()){
String number = "";
String token = tokens.nextToken();
for (int i=0; i<token.length(); i++){
if (Character.isDigit(token.charAt(i))){
number += token.substring(i, i+1);
int [][]data = new int[list.size()/2][2];
int index = -2;
for (int i=0; i<data.length;i++){
index += 2;
data[0] = Integer.parseInt(
(list.get(index).toString()));
data[i][1] = Integer.parseInt(
(list.get(index +1).toString()));
return data;
public static void main(String[] args) {
GUI frame = new GUI();
frame.setLocationRelativeTo(null); // Center the frame
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Clients Data Retrival GUI");
frame.pack();
frame.setVisible(true);
package LineGraph;
import javax.swing.*;
import java.awt.*;
public class Grph extends JPanel {
private int[][] data;
/** Set the data and display Graph */
public void showGrph(int[][] data) {
this.data = data;
repaint();
/** Paint the graph */
protected void paintComponent(Graphics g) {
//if (data == null)
//return; // No display if data is null
super.paintComponent(g);
//Find the panel size and bar width and interval dynamically
int width = getWidth();
int height = getHeight();
//int intervalw = (width - 40) / data.length;
//int intervalh = (height - 20) / data.length;
//int individualWidth = (int)(((width - 40) / 24) * 0.60);
////int individualHeight = (int)(((height - 40) / 24) * 0.60);
// Find the maximum data. The maximum data
//int maxdata = 0;
//for (int i = 0; i < data.length; i++) {
//if (maxdata < data[i][0])
//maxdata = data[i][1];
// x is the start position for the first point
int x = 30;
int y = 30;
//draw a vertical axis
g.drawLine(20, height - 45, 20, (height)* -1);
// Draw a horizontal base line4
g.drawLine(20, height - 45, width - 20, height - 45);
for (int i = 0; i < data.length; i++) {
//int Value = i;
// Display a line
//g.drawLine(x, height - 45 - Value, individualWidth, height - 45);
g.drawLine(data[i][0],data[i][1],data[i+1][0],data[i+1][1]);
// Display a number under the x axis
g.drawString((int)(0 + i) + "", (x), height - 30);
// Display a number beside the y axis
g.drawString((int)(0 + i) + "", width - 1277, (y) + 900);
// Move x for displaying the next character
//x += (intervalw);
//y -= (intervalh);
/** Override getPreferredSize */
public Dimension getPreferredSize() {
return new Dimension(1200, 900); -
Query on Materials with deletion date
Dear All,
We need a query (SQ01/SQ02) with following result:
- Material with deletion flag
- Date of the deletion (when deletion flag was set)
and the following selection:
- Period of deletion
- Plant
I know that I can find the material with MARA (and MARA - LVORM for deleted material). How can I find the date when a material was deleted?
Thank you in advance for your inputs.
Best regards,
ThomasHi,
DF for material can be set at different levels not only at client level - so, not only table MARA may contain information on deletion (e.g. you can set DF at warehouse, SLoc level, etc.).
Table CDHDR contains information on changes of material master.
Regards,
Csaba
Edited by: Csaba Szommer on Jan 20, 2009 8:36 AM -
Help needed with missing data problem in CRVS2010
We recently upgraded the reporting engine in our product to use Crystal Reports for Visual Studio 2010 (previously engine was CR9). Our quote report, which has numerous subreports and lots of conditional formatting, started losing data when a quote took more than a single page to be printed. We knew the SQL results included the data, but the report was not printing those lines at all or sometimes printing a partial line. In addition, the running total on the report would exclude the lines that were being missed on the next page. In one example submitted by a customer, 3 lines were skipped between pages.
I think I have identified two potential issues that document the possibility of data not being included in the report.
The first potential issue is an issue with the "suppress blank section" option being checked. This issue is supposedly fixed with ADAPT01483793, being released someday with service pack 2 for CRVS2010.
The second potential issue is using shared variables. This issue is supposedly fixed with ADAPT01484308, also targeted for SP2.
Our quote report does not explicitly use shared variables with any of the subreports, but it does have several subreports, each in its own section that has the "supress blank section" option checked. We have other reports that use this feature, as well, and they are not exhibiting the problem.
One different thing about the quote report is that it has a section with multiple suppression options selected. The section has a conditional suppression formula, which controls whether the section is included at all within the report. The section also has the suppress blank section option selected. There are multiple fields within the report that are each conditionally suppressed. In theory, the section's suppress formula could evaluate to true, yet all of the fields within the section are suppressed (due to null values), and then the "suppress blank section" option would kick in.
The missing data only seems to happen when the section is not being suppressed, and at least one of the fields is being included in the report. If I clear the "suppress blank section" check box, and change the section formula to also include the rules applied to the fields in the section, the missing data problem seems to be resolved.
Is this related to ADAPT01483793? Will it be fixed in service pack 2?
If more details are needed, I would be happy to provide a sample report with stored data.Hi Don,
Have a look at the Record Selection formula in CR Designer ( stand alone ) and when exported to RPT format opening that report in the Designer also.
There's been a few issues with => logic in the record selection formula. It could be you are running into this problem. Look for NOT inserted into your selection formula.
Oh and SP2 is coming out shortly so it may resolve the issue. But if you want you could purchase a support, or if you have a support contract then create a case in SMP and get a rep to work with you to debug the issue.
If you have not try the Trial Version of CR 2011, put it on a VM-ware image or Test PC so you don't corrupt anything for production and have a look at and test it in that designer also. If you purchase a case and it is a bug then you'll get a credit back for the case.
Don
Edited by: Don Williams on Oct 26, 2011 7:40 AM -
Please Help! with a data merge
Iam trying to do a data merge for my client in Indesign this is a new challenge to me and have gone through many a tutorial and uTube video but still cant get it to work properly.
Iam hoping that someone can give me some advise.
I have 11 different images (product Labels) that need personalisation with a data merge. I have attached the data merge file preview and the txt file (tab delimited text. txt)
As you can see the data merge text, seems to overflow into all the other boxes. (The blank boxes hold white text) and the images dont appear at all. Any suggestions would be really appreciated.
ThanksSo you did press the preview button...
First thing I see though, is the image tag is in a text frame, not an image frame, or at least that's the way it looks in the screen cap, but it does appear correct in the prvious version, so it might just be the way the frames are displayed.
But I suspect, too, that the file is now damaged. The preview button is buggy, and once you've pressed it and then done a merge the odds that the file will ever work correctly are small. Best thing is to rebuild the template in a new file and merge without pressing preview (just trust it will work). Copy/paste from the old file seems to be OK to do this. -
I have a problem, The scenario is that when I click any folder that si in my JTable's first row, the table is update by removing all the rows and showing only the contents of my selected folder. Right now it's not removing the rows and instead throwing exceptions. The code is attached. The methods to look are upDateTabel(...) and clearTableData(....), after clearing all my rows then I proceed on adding my data to the Jtable and inserting rows but it's not being done. May be I have a problem in my DefaultTableModel class. Please see the code below what I am doing wrong and how should I do it. Any help is appreciated.
Thanks
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class SimpleTable extends JPanel{
/** Formats the date */
protected SimpleDateFormat formatter;
/** variable to hold the date and time in a raw form for the directory*/
protected long dateDirectory;
/** holds the readable form converted date for the directories*/
protected String dirDate;
/** holds the readable form converted date for the files*/
protected String fileDate;
/** variable to hold the date and time in a raw form for the file*/
protected long dateFile;
/** holds the length of the file in bytes */
protected long totalLen;
/** convert the length to the wrapper class */
protected Long longe;
/** Vector to hold the sub directories */
protected Vector subDir;
/** holds the name of the selected directory */
protected String dirNameHold;
/** converting vector to an Array and store the values in this */
protected File directoryArray[];
/** hashtable to store the key-value pair */
protected static Hashtable hashTable = new Hashtable();
/** refer to the TableModel that is the default*/
protected MyTableModel tableModel;
/** stores the path of the selected file */
protected static String fullPath;
/** stores the currently selected file */
protected static File selectedFilename;
/** stores the extension of the selected file */
protected static String extension;
protected int COLUMN_COUNT = 4;
protected Vector data = new Vector( 0, 1 );
protected final JTable table;
/** holds the names of the columns */
protected final String columnNames[] = {"Name", "Size", "Type", "Modified"};
public SimpleTable(File directoryArray[])
this.setLayout(new BorderLayout());
this.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
(SimpleTable.hashTable).clear();
formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
for(int k = 0; k < directoryArray.length; k++)
if(directoryArray[k].isDirectory())
dateDirectory = directoryArray[k].lastModified();
dirDate = formatter.format(new java.util.Date(dateDirectory));
data.addElement( new MyObj( directoryArray[k].getName(), "", "File Folder", "" + dirDate ) );
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
else if(directoryArray[k].isFile())
dateDirectory = directoryArray[k].lastModified();
fileDate = formatter.format(new java.util.Date(dateDirectory));
totalLen = directoryArray[k].length();
longe = new Long(totalLen);
data.addElement( new MyObj( directoryArray[k].getName(), longe + " Bytes", "", "" + fileDate ) );
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
tableModel = new MyTableModel();
table = new JTable( tableModel );
table.getTableHeader().setReorderingAllowed(false);
table.setRowSelectionAllowed(false);
table.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
table.setShowHorizontalLines(false);
table.setShowVerticalLines(false);
table.addMouseListener(new MouseAdapter()
public void mouseReleased(MouseEvent e)
Object eventTarget = e.getSource();
if( eventTarget == table )
upDateTable(table);
table.tableChanged( new javax.swing.event.TableModelEvent(tableModel) ) ;
DefaultTableCellRenderer D_headerRenderer = (DefaultTableCellRenderer ) table.getTableHeader().getDefaultRenderer();
table.getColumnModel().getColumn(0).setHeaderRenderer(D_headerRenderer );
((DefaultTableCellRenderer)D_headerRenderer).setToolTipText("File and Folder in the Current Folder");
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this window.
this.add(scrollPane, BorderLayout.CENTER);
* Searches the Hashtable and returns the path of the folder or the value.
public File findPath(String value)
return (File)((SimpleTable.hashTable).get(value));
* This clears the previous data in the JTable
public void clearTableData(JTable table)
for(int row = 0; row < table.getRowCount() ; row++)
//for (int col = 0; col < table.getColumnCount() ; col++)
tableModel.deleteSelections( row );
tableModel.fireTableStructureChanged();
tableModel.fireTableRowsDeleted(0,table.getRowCount());
//table.getModel().fireTableChanged(new TableModelEvent(table.getModel()));
private void upDateTable(JTable table)
if((table.getSelectedColumn() == 0) && ((table.getColumnName(0)).equals(columnNames[0])))
dirNameHold =(String) table.getValueAt(table.getSelectedRow(),table.getSelectedColumn());
File argument = findPath(dirNameHold);
if(argument.isFile())
CMRDialog.fileNameTextField.setText(argument.getName());
try
fullPath = argument.getCanonicalPath();
selectedFilename = argument.getCanonicalFile();
CMRDialog.filtersComboBox.removeAllItems();
extension = fullPath.substring(fullPath.lastIndexOf('.'));
CMRDialog.filtersComboBox.addItem("( " + extension + " )" + " File");
catch(IOException e)
System.out.println("THE ERROR IS " + e);
return;
else if(argument.isDirectory())
String path = argument.getName();
//find the system dependent file separator
//String fileSeparator = System.getProperty("file.separator");
CMRDialog.driveComboBox.addItem(" " + path);
subDir = Search.subDirs(argument);
/**TBD:- needs a method to convert the vector to an array and return the array */
directoryArray = new File[subDir.size()];
int indexCount = 0;
/** TBD:- This is inefficient way of converting a vector to an array */
Iterator e = subDir.iterator();
while( e.hasNext() )
directoryArray[indexCount] = (File)e.next();
indexCount++;
/** now calls this method and clears the previous data */
clearTableData(table);
(SimpleTable.hashTable).clear();
//data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
for(int k = 0; k < directoryArray.length; k++)
if(directoryArray[k].isDirectory())
dateDirectory = directoryArray[k].lastModified();
dirDate = formatter.format(new java.util.Date(dateDirectory));
data.addElement( new MyObj( directoryArray[k].getName(), "", "File Folder", "" + dirDate ) );
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
else if(directoryArray[k].isFile())
dateDirectory = directoryArray[k].lastModified();
fileDate = formatter.format(new java.util.Date(dateDirectory));
totalLen = directoryArray[k].length();
longe = new Long(totalLen);
data.addElement( new MyObj( directoryArray[k].getName(), longe + " Bytes", "", "" + fileDate ) );
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
// tableModel.fireTableDataChanged();
// tableModel.fireTableRowsInserted(0,1);
table.revalidate();
table.validate();
class MyTableModel extends DefaultTableModel
int totalRows;
int totalCols;
public MyTableModel()
super();
setColumnIdentifiers (columnNames);
this.totalRows = data.size();
this.totalCols = columnNames.length;
// this will return the row count of your table
public int getRowCount()
return totalRows;
// this return the column count of your table
public int getColumnCount()
return totalCols;
// this return the data for each cell in your table
public Object getValueAt(int row, int col)
MyObj obj = (MyObj)data.elementAt( row );
if( obj != null )
if( col == 0 ) return( obj.first );
else if( col == 1 ) return( obj.last );
else if( col == 2 ) return( obj.third );
else if( col == 3 ) return( obj.fourth );
else return( "" );
return "";
// if you want your table to be editable then return true
public boolean isCellEditable(int row, int col)
return false;
// if your table is editable edit the data vector here and
// call table.tableChanged(...)
public void setValueAt(Object value, int row, int col)
protected void deleteSelections (int rows)
try
removeRow(rows);
catch(ArrayIndexOutOfBoundsException e)
System.out.println("The error in the row index " + rows);
fireTableDataChanged() ;
class MyObj
String first;
String last;
String third;
String fourth;
public MyObj( String f, String l, String t, String fo )
this.first = f;
this.last = l;
this.third = t;
this.fourth = fo;
#####################################The following code works fine but it doesn't show me the new updated date in my JTable. I tried to print the values that I am getting and it does give the values on the prompt but doesn't show me on the JTable only first two are shown and the rest of the table is filled with the same values. I don't know what's going on and am tired of this TableModel thing so pla. take a time to give me some suggestions. Thanks
import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.table.*;
import javax.swing.border.*;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class SimpleTable extends JPanel {
/** Formats the date */
protected SimpleDateFormat formatter;
/** two-dimensional array to hold the information for each column */
protected Object data[][];
/** variable to hold the date and time in a raw form for the directory*/
protected long dateDirectory;
/** holds the readable form converted date for the directories*/
protected String dirDate;
/** holds the readable form converted date for the files*/
protected String fileDate;
/** variable to hold the date and time in a raw form for the file*/
protected long dateFile;
/** holds the length of the file in bytes */
protected long totalLen;
/** convert the length to the wrapper class */
protected Long longe;
/** Vector to hold the sub directories */
protected Vector subDir;
/** holds the name of the selected directory */
protected String dirNameHold;
/** converting vector to an Array and store the values in this */
protected File directoryArray[];
/** hashtable to store the key-value pair */
protected static Hashtable hashTable = new Hashtable();
/** refer to the TableModel that is the default*/
protected DefaultTableModel model;
/** stores the path of the selected file */
protected static String fullPath;
/** stores the currently selected file */
protected static File selectedFilename;
/** stores the extension of the selected file */
protected static String extension;
protected Vector m = new Vector(0,1);
/** holds the names of the columns */
protected final String columnNames[] = {"Name", "Size", "Type", "Modified"};
public SimpleTable(File directoryArray[])
this.setLayout(new BorderLayout());
this.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
(SimpleTable.hashTable).clear();
data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
for(int k = 0; k < directoryArray.length; k++)
if(directoryArray[k].isDirectory())
data[k][0] = directoryArray[k].getName();
data[k][2] = "File Folder";
dateDirectory = directoryArray[k].lastModified();
dirDate = formatter.format(new java.util.Date(dateDirectory));
data[k][3] = dirDate;
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
else if(directoryArray[k].isFile())
data[k][0] = directoryArray[k].getName();
totalLen = directoryArray[k].length();
longe = new Long(totalLen);
data[k][1] = longe + " Bytes";
dateFile = directoryArray[k].lastModified();
fileDate = formatter.format(new java.util.Date(dateFile));
data[k][3] = fileDate;
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
model = new DefaultTableModel();
model.addTableModelListener( new TableModelListener(){
public void tableChanged( javax.swing.event.TableModelEvent e )
System.out.println("************ I am inside the table changed method ********" );
final JTable table = new JTable(model);
table.getTableHeader().setReorderingAllowed(false);
table.setRowSelectionAllowed(false);
table.setBorder( BorderFactory.createEmptyBorder( 0, 0, 0, 0 ) );
table.setShowHorizontalLines(false);
table.setShowVerticalLines(false);
table.addMouseListener(new MouseAdapter()
/* public void mousePressed(MouseEvent e)
//System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
/* if(e.getClickCount() >= 2 &&
(table.getSelectedColumn() == 0) &&
((table.getColumnName(0)).equals(columnNames[0])))
//System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
upDateTable(table);
public void mouseReleased(MouseEvent e)
//System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
/* if(e.getClickCount() >= 2 &&
(table.getSelectedColumn() == 0) &&
((table.getColumnName(0)).equals(columnNames[0]))) */
//System.out.println("The clicked component is " + table.rowAtPoint(e.getPoint()) + "AND the number of clicks is " + e.getClickCount());
upDateTable(table);
/** set the columns */
for(int c = 0; c < columnNames.length; c++)
model.addColumn(columnNames[c]);
/** set the rows */
for(int r = 0; r < data.length; r++)
model.addRow(data[r]);
DefaultTableCellRenderer D_headerRenderer = (DefaultTableCellRenderer ) table.getTableHeader().getDefaultRenderer();
table.getColumnModel().getColumn(0).setHeaderRenderer(D_headerRenderer );
((DefaultTableCellRenderer)D_headerRenderer).setToolTipText("File and Folder in the Current Folder");
//Create the scroll pane and add the table to it.
JScrollPane scrollPane = new JScrollPane(table);
//Add the scroll pane to this window.
this.add(scrollPane, BorderLayout.CENTER);
* Returns the number of columns
public int getColumnTotal()
return columnNames.length;
* Returns the number of rows
public int getRowTotal(Object directoryArray[])
return directoryArray.length;
private void upDateTable(JTable table)
if((table.getSelectedColumn() == 0) && ((table.getColumnName(0)).equals(columnNames[0])))
dirNameHold =(String) table.getValueAt(table.getSelectedRow(),table.getSelectedColumn());
File argument = findPath(dirNameHold);
if(argument.isFile())
CMRDialog.fileNameTextField.setText(argument.getName());
try
fullPath = argument.getCanonicalPath();
selectedFilename = argument.getCanonicalFile();
CMRDialog.filtersComboBox.removeAllItems();
extension = fullPath.substring(fullPath.lastIndexOf('.'));
CMRDialog.filtersComboBox.addItem("( " + extension + " )" + " File");
catch(IOException e)
System.out.println("THE ERROR IS " + e);
return;
else if(argument.isDirectory())
String path = argument.getName();
//find the system dependent file separator
//String fileSeparator = System.getProperty("file.separator");
CMRDialog.driveComboBox.addItem(" " + path);
subDir = Search.subDirs(argument);
/**TBD:- needs a method to convert the vector to an array and return the array */
directoryArray = new File[subDir.size()];
int indexCount = 0;
/** TBD:- This is inefficient way of converting a vector to an array */
Iterator e = subDir.iterator();
while( e.hasNext() )
directoryArray[indexCount] = (File)e.next();
indexCount++;
/** now calls this method and clears the previous data */
clearTableData(table);
(SimpleTable.hashTable).clear();
data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
formatter = new SimpleDateFormat("mm/dd/yyyy hh:mm aaa");
m.clear();
data = null;
data = new Object[this.getRowTotal(directoryArray)][this.getColumnTotal()];
for(int k = 0; k < directoryArray.length; k++)
if(directoryArray[k].isDirectory())
System.out.println("Inside the if part");
data[k][0] = directoryArray[k].getName();
table.setValueAt(directoryArray[k].getName(),k,0);
//model.fireTableCellUpdated(k,0);
data[k][2] = "File Folder";
table.setValueAt("File Folder",k,2);
//model.fireTableCellUpdated(k,2);
dateDirectory = directoryArray[k].lastModified();
dirDate = formatter.format(new java.util.Date(dateDirectory));
data[k][3] = dirDate;
table.setValueAt(dirDate,k,3);
//model.fireTableCellUpdated(k,3);
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]);
m.add(data);
model.addRow(m);
model.fireTableDataChanged();
else if(directoryArray[k].isFile())
System.out.println("******* Inside the else part *******");
data[k][0] = directoryArray[k].getName();
System.out.println("The Name is == " + data[k][0]);
table.setValueAt(directoryArray[k].getName(),k,0);
System.out.println("The table cell value of the name is == " + table.getValueAt(k,0));
//model.fireTableCellUpdated(k,0);
totalLen = directoryArray[k].length();
longe = new Long(totalLen);
data[k][1] = longe + " Bytes";
System.out.println("The length == " + data[k][1]);
table.setValueAt(longe + " Bytes",k,1);
System.out.println("The table cell value of the length is == " + table.getValueAt(k,1));
//model.fireTableCellUpdated(k,0);
dateFile = directoryArray[k].lastModified();
fileDate = formatter.format(new java.util.Date(dateFile));
data[k][3] = fileDate;
System.out.println("The modified date == " + data[k][3]);
table.setValueAt(fileDate,k,3);
System.out.println("The table cell value of the name is == " + table.getValueAt(k,3));
//model.fireTableCellUpdated(k,0);
(SimpleTable.hashTable).put(directoryArray[k].getName(), directoryArray[k]); }
m.add(data);
model.addRow(m);
model.fireTableDataChanged();
// model.fireTableDataChanged();
// model.fireTableRowsInserted(0,1);
table.revalidate();
table.validate();
else
* Searches the Hashtable and returns the path of the folder or the value.
public File findPath(String value)
return (File)((SimpleTable.hashTable).get(value));
* This clears the previous data in the JTable
public void clearTableData(JTable table)
for(int row = 0; row < table.getRowCount() ; row++)
for (int col = 0; col < table.getColumnCount() ; col++)
table.setValueAt(null, row , col);
model.fireTableStructureChanged();
### -
I have the XML below stored in a table in an XML field. I wish to query this record for the <HISTORY_BLOCK> data and get on record for each <row>. ie. I want to do something like
Select
extractvalue(detail, '/S12/HISTORY_BLOCK/RESULT),
extractvalue(detail, '/S12/HISTORY_BLOCK/ACTION),
extractvalue(detail, '/S12/HISTORY_BLOCK/DEVICE_TYPE),
extractvalue(detail, '/S12/HISTORY_BLOCK/RECORD_NUMBER)
FROM
extract(table.field, '/S12/HISTORY_BLOCK)
which returns multiple records, one for each row. ie.
TIME OUT,DISABLE,TASL,1,TASL,015F,2
NOT SUCCESSFUL,DISABLE,TASL,1,TASL,015D,4
NOT SUCCESSFUL,DISABLE,TASL,1,TASL,015C,6
NOT SUCCESSFUL,DISABLE,ENDOFCAV,1,TASL,0157,8
NOT SUCCESSFUL,DISABLE,ENDOFCAV,1,TASL,0155,10
NOT SUCCESSFUL,DISABLE,ENDOFCAV,1,TASL,0154,12
NOT SUCCESSFUL,DISABLE,TASL,1,TASL,0153,14
NOT SUCCESSFUL,DISABLE,TASL,1,TASL,0152,16
TIME OUT,DISABLE,TASL,1,TASL,0151,18
NOT SUCCESSFUL,DISABLE,TASL,1,TASL,0150,20
Reading the "Oracle9i Application Developers Guide - Fundamentals" manual, Table Functions, you can use a PL-SQL Table Function to transform the data and return multiple records from a single record in. As my XML data structure is not set but has many formats, I will need many PL-SQL functions to get the data out.
Can you please check the Oracle resources to see whether there is a straight SQL answer to my requirements.
Example of a single record of XML stored in the detail field.
<S12>
<ID_>ssapp010101125903468218634000</ID_>
<oracle_tzr>EST</oracle_tzr>
<HEADER_DATE_TIME>2005-09-05 16:59:06</HEADER_DATE_TIME>
<NODE>EXEU</NODE>
<EXCHANGE_STATUS>L705AA_64*W</EXCHANGE_STATUS>
<RRN_NUMBER>00052</RRN_NUMBER>
<COMMAND_NAME/>
<MAIN_EXECUTION_RESULT>SYSTEM REPORT</MAIN_EXECUTION_RESULT>
<COMMAND_CODE>AUDIT DISABLE</COMMAND_CODE>
<REPORT_HEADER>REPORT ON DEPENDENT SBLS</REPORT_HEADER>
<NETWORK_ADDRESS>H'0150</NETWORK_ADDRESS>
<SECURITY_BLOCK_TYPE>ACSW</SECURITY_BLOCK_TYPE>
<SECURITY_BLOCK_NUMBER_RANGE>1</SECURITY_BLOCK_NUMBER_RANGE>
<WAIT_FOR_TRAFFIC_CLEAR>0</WAIT_FOR_TRAFFIC_CLEAR>
<GLOBAL_RESULT>ACTION FAILED</GLOBAL_RESULT>
<HISTORY_BLOCK>
<row>
<RESULT>TIME OUT</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>015F</NETWORK_ADDRESS>
<RECORD_NUMBER>2</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>015D</NETWORK_ADDRESS>
<RECORD_NUMBER>4</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>015C</NETWORK_ADDRESS>
<RECORD_NUMBER>6</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>ENDOFCAV</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0157</NETWORK_ADDRESS>
<RECORD_NUMBER>8</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>ENDOFCAV</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0155</NETWORK_ADDRESS>
<RECORD_NUMBER>10</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>ENDOFCAV</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0154</NETWORK_ADDRESS>
<RECORD_NUMBER>12</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0153</NETWORK_ADDRESS>
<RECORD_NUMBER>14</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0152</NETWORK_ADDRESS>
<RECORD_NUMBER>16</RECORD_NUMBER>
</row>
<row>
<RESULT>TIME OUT</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0151</NETWORK_ADDRESS>
<RECORD_NUMBER>18</RECORD_NUMBER>
</row>
<row>
<RESULT>NOT SUCCESSFUL</RESULT>
<ACTION>DISABLE</ACTION>
<DEVICE_TYPE>TASL</DEVICE_TYPE>
<NBR>1</NBR>
<SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
<NETWORK_ADDRESS>0150</NETWORK_ADDRESS>
<RECORD_NUMBER>20</RECORD_NUMBER>
</row>
</HISTORY_BLOCK>
<SECURITY_BLOCKS>Aussie_boy, there was a slight problem with the xml instance you posted, so i have taken the content only for the history blocks of your interest to make this sample.
you can do it very well what you want using a combination of TABLE,XMLSEQUENCE and EXTRACT functions.
SQL> create table xml_table(id number, xml_data xmltype)
2 /
Table created.
SQL> insert into xml_table values(1,
2 xmltype('<HISTORY_BLOCK>
3 <row>
4 <RESULT>TIME OUT</RESULT>
5 <ACTION>DISABLE</ACTION>
6 <DEVICE_TYPE>TASL</DEVICE_TYPE>
7 <NBR>1</NBR>
8 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
9 <NETWORK_ADDRESS>015F</NETWORK_ADDRESS>
10 <RECORD_NUMBER>2</RECORD_NUMBER>
11 </row>
12 <row>
13 <RESULT>NOT SUCCESSFUL</RESULT>
14 <ACTION>DISABLE</ACTION>
15 <DEVICE_TYPE>TASL</DEVICE_TYPE>
16 <NBR>1</NBR>
17 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
18 <NETWORK_ADDRESS>015D</NETWORK_ADDRESS>
19 <RECORD_NUMBER>4</RECORD_NUMBER>
20 </row>
21 <row>
22 <RESULT>NOT SUCCESSFUL</RESULT>
23 <ACTION>DISABLE</ACTION>
24 <DEVICE_TYPE>TASL</DEVICE_TYPE>
25 <NBR>1</NBR>
26 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
27 <NETWORK_ADDRESS>015C</NETWORK_ADDRESS>
28 <RECORD_NUMBER>6</RECORD_NUMBER>
29 </row>
30 <row>
31 <RESULT>NOT SUCCESSFUL</RESULT>
32 <ACTION>DISABLE</ACTION>
33 <DEVICE_TYPE>ENDOFCAV</DEVICE_TYPE>
34 <NBR>1</NBR>
35 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
36 <NETWORK_ADDRESS>0157</NETWORK_ADDRESS>
37 <RECORD_NUMBER>8</RECORD_NUMBER>
38 </row>
39 <row>
40 <RESULT>NOT SUCCESSFUL</RESULT>
41 <ACTION>DISABLE</ACTION>
42 <DEVICE_TYPE>ENDOFCAV</DEVICE_TYPE>
43 <NBR>1</NBR>
44 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
45 <NETWORK_ADDRESS>0155</NETWORK_ADDRESS>
46 <RECORD_NUMBER>10</RECORD_NUMBER>
47 </row>
48 <row>
49 <RESULT>NOT SUCCESSFUL</RESULT>
50 <ACTION>DISABLE</ACTION>
51 <DEVICE_TYPE>ENDOFCAV</DEVICE_TYPE>
52 <NBR>1</NBR>
53 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
54 <NETWORK_ADDRESS>0154</NETWORK_ADDRESS>
55 <RECORD_NUMBER>12</RECORD_NUMBER>
56 </row>
57 <row>
58 <RESULT>NOT SUCCESSFUL</RESULT>
59 <ACTION>DISABLE</ACTION>
60 <DEVICE_TYPE>TASL</DEVICE_TYPE>
61 <NBR>1</NBR>
62 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
63 <NETWORK_ADDRESS>0153</NETWORK_ADDRESS>
64 <RECORD_NUMBER>14</RECORD_NUMBER>
65 </row>
66 <row>
67 <RESULT>NOT SUCCESSFUL</RESULT>
68 <ACTION>DISABLE</ACTION>
69 <DEVICE_TYPE>TASL</DEVICE_TYPE>
70 <NBR>1</NBR>
71 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
72 <NETWORK_ADDRESS>0152</NETWORK_ADDRESS>
73 <RECORD_NUMBER>16</RECORD_NUMBER>
74 </row>
75 <row>
76 <RESULT>TIME OUT</RESULT>
77 <ACTION>DISABLE</ACTION>
78 <DEVICE_TYPE>TASL</DEVICE_TYPE>
79 <NBR>1</NBR>
80 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
81 <NETWORK_ADDRESS>0151</NETWORK_ADDRESS>
82 <RECORD_NUMBER>18</RECORD_NUMBER>
83 </row>
84 <row>
85 <RESULT>NOT SUCCESSFUL</RESULT>
86 <ACTION>DISABLE</ACTION>
87 <DEVICE_TYPE>TASL</DEVICE_TYPE>
88 <NBR>1</NBR>
89 <SECURITY_BLOCK_TYPE>TASL</SECURITY_BLOCK_TYPE>
90 <NETWORK_ADDRESS>0150</NETWORK_ADDRESS>
91 <RECORD_NUMBER>20</RECORD_NUMBER>
92 </row>
93 </HISTORY_BLOCK>'))
94 /
1 row created.
SQL>
SQL> set linesize 200
SQL> column result format a20
SQL> column action format a10
SQL> column device_type format a10
SQL> column nbr format a5
SQL> column security_block format a20
SQL> column network_address format a10
SQL> column record_number format a20
SQL>
SQL> select extractvalue(value(a), '/row/RESULT') result
2 , extractvalue(value(a), '/row/ACTION') action
3 , extractvalue(value(a), '/row/DEVICE_TYPE') device_type
4 , extractvalue(value(a), '/row/NBR') nbr
5 , extractvalue(value(a), '/row/SECURITY_BLOCK') security_block
6 , extractvalue(value(a), '/row/NETWORK_ADDRESS') network_address
7 , extractvalue(value(a), '/row/RECORD_NUMBER') record_number
8 from xml_table
9 , table(xmlsequence(extract(xml_Data, 'HISTORY_BLOCK/row'))) a
10 where id =1
11 /
RESULT ACTION DEVICE_TYP NBR SECURITY_BLOCK NETWORK_AD RECORD_NUMBER
TIME OUT DISABLE TASL 1 015F 2
NOT SUCCESSFUL DISABLE TASL 1 015D 4
NOT SUCCESSFUL DISABLE TASL 1 015C 6
NOT SUCCESSFUL DISABLE ENDOFCAV 1 0157 8
NOT SUCCESSFUL DISABLE ENDOFCAV 1 0155 10
NOT SUCCESSFUL DISABLE ENDOFCAV 1 0154 12
NOT SUCCESSFUL DISABLE TASL 1 0153 14
NOT SUCCESSFUL DISABLE TASL 1 0152 16
TIME OUT DISABLE TASL 1 0151 18
NOT SUCCESSFUL DISABLE TASL 1 0150 20
10 rows selected.
Maybe you are looking for
-
I need to delet all the songs off my Ipod 6th generation nano. I began a restore to factory settings but my ipod was unplugged. Now the songs are still ON the ipod and the ipod does not register with my computer. It is not available in the device lis
-
Remove garbage text from fields SQL server 2000
I have a SQL server db that just got hacked. I am using CFQUERYPARAM in all my queries, but somehow still got hacked. It corrupted data and I know I can do a restore, but I don't want to lost anything. How can I, for example, remove all garbage chara
-
We want a lumpsum amount for excise duty-how to onfigure?
Dear Friends Previously we were paying tax to the vendor as ED, Cess, and Ecess etc.But now vendor wants us to pay a lumpsum tax as excise duty as follows: Basic Price Rs 10
-
Lib Folder? Unix executable files
So suddenly a folder entitled "lib" appeared in my documents folder without me putting it there. Or shall I say without me intentionally putting there. But before I remove it I just wanted to make sure it is not a critical system component. Oh and th
-
Exporting to Quicktime loses transitions
Hello, I'm using keynote 4.0.2 and if I create a hyperlink presentation with multiple slides and have transitions between them (whether it's disolve or cube or curtains, etc.) it appears that several of the transitions get lost. The link works, it ju