Need to find rows with overlapping dates
I have a table that has FirstName, LastName, EnrollmentFrom and EnrollmentTo
I need to find all names where they have overlapping dates. For example this is invalid:
Name EnrollmentFrom EnrollmentTo
John Doe 1/1/2014 1/1/2015
John Doe 2/5/2014 2/5/2014
This would be valid:
John Doe 1/1/2014 1/1/2015
John Doe 1/2/2015 1/1/2016
This is just an example as the dates could be anything in one of the other enrollments.
Any help is greatly appreciated.
Here is what I have based on the last post but it also returns ones that are valid:
SELECT ffev.PatientLastName, ffev.PatientFirstName, ffev.EnrollmentFrom, ffev.EnrollmentTo
FROM PAPPortal..FeedFileEnrollmentValues ffev
OUTER APPLY (select top 1 b.* from PAPPortal..FeedFileEnrollmentValues b where ffev.PatientID = b.PatientID and b.EnrollmentFrom < ffev.EnrollmentTo and b.EnrollmentTo > ffev.EnrollmentFrom and ffev.PatientID <> b.PatientID) overlap
WHERE ffev.EnrollmentTo IS NOT NULL
GROUP BY ffev.PatientLastName, ffev.PatientFirstName, ffev.EnrollmentFrom, ffev.EnrollmentTo
ORDER BY ffev.PatientLastName, ffev.PatientFirstName, ffev.EnrollmentFrom, ffev.EnrollmentTo
Name EnrollmentFrom EnrollmentTo
John Doe 2013-02-08 2014-02-07
John Doe 2014-08-15 2015-08-15
hi
it seems you have given (= and <>) which is always return false(no records)
where ffev.PatientID = b.PatientID and b.EnrollmentFrom < ffev.EnrollmentTo and b.EnrollmentTo > ffev.EnrollmentFrom and
ffev.PatientID <> b.PatientID
Note : i have given
where a.ID=b.ID and b.DateFrom<a.DateTo and b.DateTo>a.DateFrom and
a.rno<>b.rno
If you don't have any unique column to differentiate you can create rno with CTE and use like below
DECLARE @Data AS TABLE
-- rno int identity(1,1),
ID int,
DateFrom datetime,
DateTo datetime
INSERT INTO @Data VALUES (1, '1/1/2014', '1/1/2015')
INSERT INTO @Data VALUES (1, '2/5/2014', '2/5/2014')
INSERT INTO @Data VALUES (2, '1/1/2014', '12/31/2014')
INSERT INTO @Data VALUES (2, '1/2/2015', '12/31/2016')
;WITH CTE1 as
SELECT ROW_NUMBER() over(PARTITION by ID order by DateFrom,DateTo ) rno,* FROM @Data
SELECT a.*, overlap.rno,overlap.DateFrom,overlap.DateTo
FROM CTE1 a
OUTER APPLY (select top 1 b.* from CTE1 b where a.ID=b.ID
and b.DateFrom<a.DateTo
and b.DateTo>a.DateFrom and a.rno<>b.rno) overlapwhere overlap.ID is not null
Thanks
Saravana Kumar C
Similar Messages
-
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'); -
Finder - Images With Orientation Data
Hi,
I'd like to discuss the way Finder handles images/photos with Orientation data embedded in them. I have a portrait photo here. When I open it with Preview it appears the correct way up, with its longest dimension running vertically. The same is true for Cover Flow and Quick Look. All of these methods show the photo the correct way up. However, when I view the file in Icon View or in List View in the Finder, the photo appears on its side, with its longest dimension running horizontally.
My question is, why is this happening? If Preview, Cover Flow, Quick Look and even Safari understand Orientation data, why doesn't the Icon and List View modes of the Finder? Is this intentional or something that Apple forgot to implement?You need to have an application like EXIF Viewer for Mac OS X to check the files once you've exported them with the various checkboxes checked:
Happy Holidays -
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 -
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 -
Sample code snippet needed to provision appinstance with child data in R2
Gurus,
I have developed some code to provision an application instance to a user using API but it is not working.
Can you please provide me some sample code to provision with child data this using API.
Here are the errors.
oracle.iam.provisioning.exception.GenericProvisioningException: An error occurred in oracle.iam.provisioning.spi.DOBProvisioningMechanism/provision while provisioning application instance with key 16907 to user with name TESETUSER the cause of error is oracle.iam.provisioning.exception.GenericProvisioningConfigException: Entitlement attribute not marked as key in reconciliation field mapping for UD_ADUSRC.
at weblogic.rjvm.ResponseImpl.unmarshalReturn(ResponseImpl.java:237)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:348)
at weblogic.rmi.cluster.ClusterableRemoteRef.invoke(ClusterableRemoteRef.java:259)
at oracle.iam.provisioning.api.ProvisioningService_p7m7x_ProvisioningServiceRemoteImpl_1036_WLStub.provisionx(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at weblogic.ejb.container.internal.RemoteBusinessIntfProxy.invoke(RemoteBusinessIntfProxy.java:85)
at $Proxy2.provisionx(Unknown Source)
at oracle.iam.provisioning.api.ProvisioningServiceDelegate.provision(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at Thor.API.Base.SecurityInvocationHandler$1.run(SecurityInvocationHandler.java:68)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.security.Security.runAs(Security.java:41)
at Thor.API.Security.LoginHandler.weblogicLoginSession.runAs(weblogicLoginSession.java:52)
at Thor.API.Base.SecurityInvocationHandler.invoke(SecurityInvocationHandler.java:79)
at $Proxy3.provision(Unknown Source)
at OIM.provisioning.DirectProvisionApplicationInstance.provisionResource(DirectProvisionApplicationInstance.java:118)
at OIM.provisioning.DirectProvisionApplicationInstance.main(DirectProvisionApplicationInstance.java:179)
Caused by: oracle.iam.provisioning.exception.GenericProvisioningException: An error occurred in oracle.iam.provisioning.spi.DOBProvisioningMechanism/provision while provisioning application instance with key 16907 to user with name TESETUSER the cause of error is oracle.iam.provisioning.exception.GenericProvisioningConfigException: Entitlement attribute not marked as key in reconciliation field mapping for UD_ADUSRC.
at oracle.iam.provisioning.util.ProvisioningUtil.throwGenericProvisioningException(ProvisioningUtil.java:216)
at oracle.iam.provisioning.spi.DOBProvisioningMechanism.provision(DOBProvisioningMechanism.java:401)
at oracle.iam.provisioning.impl.ProvisioningServiceImpl$4.process(ProvisioningServiceImpl.java:488)I am new to the Windows programming environment (I'm running Windows 7).
I am looking for sample code that will do the following:
1.
12.
If you expect a useful answer here, you'll have to narrow your thread(s) to one specific
issue. Posting a (virtually) complete application specification is far too broad and
comprehensive for any one thread in these forums.
Pick *one* aspect of this project and describe what problems you're having writing the code.
Post a new thread for each specific problem.
As posted, you appear to be hoping to find code already completely written for this project.
Most sample code illustrates *one* task, not a dozen. If you aren't able or willing to do
the lion's share of the coding yourself, you may have to consider contracting a developer.
- Wayne -
Delete Rows with specified data
hello
maybe you know what script/formula i can use to do the following:
i need to remove rows what include in any cell some specified word.
words for lookup should be specified in another cells.
this require new script? or somebody know how to do this?First, you cannot "delete" a row using a formula. You can make it so a row can be hidden. You can highlight a row (i.e., such as by putting the word "DELETE" in a cell in a particular column) so you can locate and delete the row manually. You could probably write a script to do these deletions for you but I'm not sure it is worth the time unless you need to do an awful lot of them or need to do it often.
The problem statement is still not completely clear. Will you be searching for the entire phrase "T-Technologies :: CODE3290"? Is that the entirety of what is in a cell or is that only part of the text in the cell? Or will you be searching for a piece of that phrase, such as "Technologies" or "Tech" or "code" or "3290"?
You can highlight any cell containing a particular word or phrase or group of letter/numbers by using conditional formatting. Use the test "text contains..." and type in the word you are looking for. Set the fill to red so you can see it. Use Copy Style then Paste Style to the rest of the table. Then manually delete any row that has a red cell.
Message was edited by: Badunit -
Hi All
I have the following records:
--Drop Table
drop table agreement;
drop table GRP_INFO;
--Create table
create table agreement
Agreement_Id Number(5),
Coverage_Effective_Date Date,
COVERAGE_termination_date date
Create Table GRP_INFO
Agreement_Id Number(5),
Grp_Id Number(5),
Effective_Date Date,
TERMINATION_DATE Date
--Insertion
Insert Into Agreement
Select 100,'01JAN-2013','31-DEC-2013'
From Dual;
Insert Into Agreement
Select 200,'01JAN-2013','31-DEC-2013'
From Dual;
Insert Into Agreement
Select 300,'01JAN-2013','31-DEC-2013'
From Dual;
Insert Into Agreement
Select 400,'01JAN-2013','31-DEC-2013'
From Dual;
Insert Into Grp_Info
Select 100,1,'01-JAN-2013','31-MAR-2013'
From Dual
UNION ALL
Select 100,2,'01-APR-2013','02-APR-2013'
From Dual
UNION ALL
Select 100,3,'03-APR-2013','15-APR-2013'
From Dual
UNION ALL
Select 100,4,'03-APR-2013','15-APR-2013'
From Dual
UNION ALL
Select 100,5,'01-JUN-2013','31-DEC-2013'
From Dual
Union All
Select 200,6,'01-JAN-2013','02-APR-2013'
From Dual
Union All
Select 200,7,'03-APR-2013','15-APR-2013'
From Dual
Union All
Select 200,8,'03-APR-2013','15-APR-2013'
From Dual
Union All
Select 200,9,'01-JUN-2013','30-NOV-2013'
From Dual
Union All
Select 300,10,'01-JAN-2013','15-APR-2013'
From Dual
Union All
Select 300,11,'16-APR-2013','31-DEC-2013'
From Dual
Union All
Select 400,12,'02-JAN-2013','31-DEC-2013'
From Dual;
COMMIT;
--Query on agreement table
Select * from Agreement;
--Query Result
agreement_id coverage_effective_date coverage_termination_date
100 01-JAN-13 31-DEC-13
200 01-JAN-13 31-DEC-13
300 01-JAN-13 31-DEC-13
400 01-JAN-13 31-DEC-13
--Query on grp_info table
agreement_id grp_id effective_date termination_date
100 1 01-JAN-13 31-MAR-13
100 2 01-APR-13 02-APR-13
100 3 03-APR-13 15-APR-13
100 4 03-APR-13 15-APR-13
100 5 01-JUN-13 31-DEC-13
200 6 01-JAN-13 02-APR-13
200 7 03-APR-13 15-APR-13
200 8 03-APR-13 15-APR-13
200 9 01-JUN-13 30-NOV-13
300 10 01-JAN-13 15-APR-13
300 11 16-APR-13 31-DEC-13
400 12 02-JAN-13 31-DEC-13
--Result
agreement_id
100
200
400
--Logic for the above result
Each agreement_id have multiple grp_id and all grp_id or atleast one should cover all period agreement_id for example:
- Agreement_id 100 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 100 then you can find that the period from 16-Apr-2013 till 31-May-2013 are missing so I need this agreement_id.
- Agreement_id 200 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 200 then you can find that the period from 01-DEC-2013 till 31-DEC-2013 are missing so I need this agreement_id.
- Agreement_id 300 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 300 then you can find that no period is missing so I don't need this agreement_id.
- Agreement_id 400 has coverage effective date is 01-Jan-2013 and coverage_termination_date is 31-Dec-2013 and if you look into all record against agreement_id 300 then you can find that the period from 01-JAN-2013 till 01-JAN-2013 is missing so I need this agreement_id.
Please let me know if you have any questions related to my scenario and I really appreciate if someone provide me solution for this issue.
Regards
ShumailHi,
Here's one way:
WITH got_gap AS
SELECT agreement_id, effective_date, termination_date
, CASE
WHEN effective_date >
1 + MAX (termination_date) OVER ( PARTITION BY agreement_id
ORDER BY effective_date
ROWS BETWEEN UNBOUNDED PRECEDING
AND 1 PRECEDING
THEN 1
END AS gap
FROM grp_info
SELECT g.agreement_id
FROM got_gap g
JOIN agreement a ON a.agreement_id = g.agreement_id
GROUP BY g.agreement_id
HAVING COUNT (g.gap) > 0
OR MIN (g.effective_date) > MIN (a.coverage_effective_date)
OR MAX (g.termination_date) < MAX (a.coverage_termination_date)
ORDER BY g.agreement_id
Output:
AGREEMENT_ID
100
200
400
This makes no assumptions about effective_date and termination_date, except that effective_date <= termination_date on each row. It's okay if different rows for the same agreement_id overlap, or if one encompasses another.
Don't try to insert VARCHAR2 values (such as '01-JAN-2013') into DATE columns. Use TO_DATE, or DATE literals. -
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();
### -
SSRS Matrix Issue. Expression calculating in row with no data.
I have a matrix with multiple column groups for different sales channels. With in each group there are several columns and some with expressions for calculations. The rows are based on sales reps. Now not every sales rep sells in every channel, so there
are some columns in which a rep will have no data. I want them be blank or show a 0. I can do both of those. The issue I am having is in the expressions for reps that have no data, it is still showing a calculation. It seems to populate that cell with whatever
the first result of an actual calculation is. See below. For rep D and E they have no calls or sales in this particular sales channel; however, the closing ratio is showing 30.23% (which is the closing ratio for rep A). I need this to be blank or 0 or N/A,
anything other that a wrong %. I have tried numerous iif and isnothing statements, e.g. =iif(Fields!count_of_customers.Value = 0,0,Fields!count_of_customers.Value/iif(Fields!Calls.Value = 0,1,Fields!Calls.Value)) plus other i have found on the internet
but none of them work. Can someone please help? Sorry it is not a picture of the report. They need to confirm my account before I can attach pictures. But this is the set up of the report.
Figure A
Phone Field
Rep Calls
Sales Closing Ratio
Premium Rep
Calls Sales
A 1000
323 32.3%
$100,250 A
50 5
B 200
10 5% $50,000
B 0
0
C 300
15 5% $25,000
C 25
5
D 0
0 32.3%
$0 D
300 50
E 0
0 32.3%
$0 E
100 15
F 500
100 20%
$300,000 F
0 0Hi RobTencents,
After testing the issue in my environment, I can reproduce it. To fix this issue, please try to use the expression below to instead the original one:
=iif(sum(Fields!count_of_customers.Value) = 0,0,sum(Fields!count_of_customers.Value)/iif(sum(Fields!Calls.Value) = 0,1,sum(Fields!Calls.Value)))
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Cross Tab keeps suppressing rows with no data
I have a Crystal Report that is using a Cross Tab. I have 2 rows in the cross tab the first row is the Month name and the second row is the Day Number of the month, and the report will print the Month Name on the left followed by all the Calendar Day Numbers in the month.
The problem is that when there is no data for a Day Number row the entire row is not shown. So you might have day number 1, 2, 3 and then jumps to maybe 6. I found that the ones the cross tab was not showing did not contain any data. I just need the calendar day number to at least print so the days read sequentially instead of jumping to 6 or another number.
Is there any way to show the rows even if they don't contain any data?
I have right clicked and gone into the Cross Tab expert and there isn't anything checked to suppress rows. I don't understand why its still suppressing rows!
Is there a global report option that I missed that says "suppress rows when there are no records"?
Thank you all in advance,
I am using Crystal Reports XIR2 with Service Pack 4I am still not getting all rows to show up on the report. The rows that are not showing up contain no data in the cross tab but the row still needs to show.
The only reason I got it to work before was because I selected all values for the columns parameter so it brought back everything in the database that was why it was able to show all values.
I have two tables one is a date database and contains all the dates till 2012. The other is the product data which contains the product code and qty that the cross tab summarizes.
I have done a left outer join from the product data to the date database, and I am still not able to get all the dates to list for the selected time range.
I was able to get the dates to show up when I right clicked the link and modified the link properties. I chose Left Outer Join and then under Link Type I selected ">" in the database expert dialog. This brought back all the dates but the data in the report was all the same. Probably just the first record repeated all down the page.
Any ideas how to fix this problem? -
Fetch the row with latest data,when multiple rows exist for same user
Hi ,
Thanks for reading the post.I have table with the follwoing data.
user requestdate createdate
jake 02/21/2006 15:33:41 02/25/2006 15:33:41
jake 04/20/2006 15:33:41 04/21/2006 15:33:41
jake 04/23/2006 15:33:41 04/24/2006 15:33:41
jill 02/21/2006 15:33:41 02/25/2006 15:33:41
jill 04/20/2006 15:33:41 04/21/2006 15:33:41
The data type of user,reqdate,createdate is varchar2.I want to write a query that
gives me all the users and his latest information.After running the query I am expecting the result
user requestdate createdate
jake 04/23/2006 15:33:41 04/24/2006 15:33:41
jill 04/20/2006 15:33:41 04/21/2006 15:33:41
I am not able to write the correct query.Need help , Thanks
PanduI am sorry Again,Here are the actual tables and the data in them.
SQL> desc test;
Name Null? Type
ID NOT NULL VARCHAR2(22)
OBJECTNAME VARCHAR2(30)
SQL> select id,objectname from test order by objectname;
ID OBJECTNAME
49 Nani
43 Nani
46 jack
41 jack
45 jack
47 jill
42 jill
7 rows selected.
SQL> desc testattr;
Name Null? Type
ID NOT NULL VARCHAR2(22)
ATTRNAME VARCHAR2(22)
ATTRVALUE VARCHAR2(22)
SQL> select * from testattr;
ID ATTRNAME ATTRVALUE
41 rdate 02/21/2006 15:33:41
41 cdate 02/25/2006 15:33:41
45 rdate 04/20/2006 15:33:41
45 cdate 04/21/2006 15:33:41
46 rdate 04/23/2006 15:33:41
46 cdate 04/24/2006 15:33:41
42 rdate 02/21/2006 15:33:41
42 cate 02/25/2006 15:33:41
47 rdate 04/20/2006 15:33:41
47 cdate 04/21/2006 15:33:41
43 rdate 04/04/2006 14:33:41
43 cdate 04/05/2006 16:33:41
49 rdate 05/03/2006 09:32:55
49 cdate 05/05/2006 07:12:55
14 rows selected.All the attributes have data type varchar2.I want to write a query that gives the following result.
objectname (attrvalue)requestdate (attrval)createdate
jack 04/23/2006 15:33:41 04/24/2006 15:33:41
jill 04/20/2006 15:33:41 04/21/2006 15:33:41
Nani 05/03/2006 09:32:55 05/05/2006 07:12:55.Thanks,Need help.
Pandu -
Bug: when fetching arrays of rows with null data values
Using Oracle ODBC Driver 8.01.73.00 or 8.01.74.00 (called
8.1.7.3.0 and 8.1.7.4.0 on the Oracle downloads page).
When fetching multiple rows, and where some of the data is null,
the the indicator variable quite often (but not always) has
incorrect values.
Is this a known bug? This seems like something that lots of
people would encounter so I find it hard to understand why it
hasn't already been fixed.
Also, how do I report this as a bug to Oracle? I couldn't find
the place on the site to do this.
To reproduce:
Create the following data in Oracle
create table null_test
item_id number (10, 0) not null,
data1 number (10, 0) null,
constraint null_test_pk1 primary key (item_id)
insert into null_test (item_id) values (1);
insert into null_test (item_id) values (2);
commit;
When you run the code to print out indicators and values, you
get this output
4: 1 -1:
4: 2 0:-858993460
The code to do this is as follows (put in your own values for
the #defines at the top)
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <stdio.h>
#define DB_NAME ""
#define USER_NAME ""
#define PASSWORD ""
#define TEST_RETVAL(R) if (R != SQL_SUCCESS && R !=
SQL_SUCCESS_WITH_INFO) return 1;
int main()
SQLRETURN retval;
SQLHENV henv;
retval = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE,
&henv);
TEST_RETVAL(retval);
retval = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(void*)SQL_OV_ODBC3, 0);
TEST_RETVAL(retval);
SQLHDBC hdbc;
retval = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc);
TEST_RETVAL(retval);
retval = SQLConnect(hdbc, (unsigned char*)DB_NAME,
SQL_NTS, (unsigned char*)USER_NAME, SQL_NTS, (unsigned char*)
PASSWORD, SQL_NTS);
TEST_RETVAL(retval);
SQLHSTMT hstmt;
retval = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &hstmt);
TEST_RETVAL(retval);
const char* Query = "select item_id, data1 from
null_test order by item_id";
const int NumRows = 13;
int NumRowsFetched;
retval = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_BIND_TYPE,
SQL_BIND_BY_COLUMN, 0);
TEST_RETVAL(retval);
retval = SQLSetStmtAttr(hstmt, SQL_ATTR_ROW_ARRAY_SIZE,
(void*)NumRows, 0);
TEST_RETVAL(retval);
retval = SQLSetStmtAttr(hstmt,
SQL_ATTR_ROWS_FETCHED_PTR, &NumRowsFetched, 0);
TEST_RETVAL(retval);
SQLINTEGER rgnItemId[NumRows], rgnData1[NumRows],
rgnData2[NumRows];
SQLINTEGER rgnItemIdInd[NumRows], rgnData1Ind[NumRows],
rgnData2Ind[NumRows];
retval = SQLBindCol(hstmt, 1, SQL_C_LONG, rgnItemId, 0,
rgnItemIdInd);
TEST_RETVAL(retval);
retval = SQLBindCol(hstmt, 2, SQL_C_LONG, rgnData1, 0,
rgnData1Ind);
TEST_RETVAL(retval);
retval = SQLExecDirect(hstmt, (unsigned char*)Query,
SQL_NTS);
TEST_RETVAL(retval);
for (int i = 0; i < NumRows; i++)
rgnData1Ind[i] = rgnItemIdInd[i] = rgnData2Ind
= 0;
while ((retval = SQLFetchScroll(hstmt, SQL_FETCH_NEXT,
0)) != SQL_NO_DATA)
TEST_RETVAL(retval);
for (int i = 0; i < NumRowsFetched; i++)
if (rgnData1Ind[i] == SQL_NULL_DATA)
printf("%2d:%5d %2d:%6s\n",
rgnItemIdInd[i], rgnItemId[i], rgnData1Ind[i], "", rgnData2Ind
[i], rgnData2[i]);
else
printf("%2d:%5d %2d:%6d\n",
rgnItemIdInd[i], rgnItemId[i], rgnData1Ind[i], rgnData1[i],
rgnData2Ind[i], rgnData2[i]);
for (i = 0; i < NumRows; i++)
rgnData1Ind[i] = rgnItemIdInd[i] =
rgnData2Ind[i] = 0;
retval = SQLCloseCursor(hstmt);
TEST_RETVAL(retval);
retval = SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
TEST_RETVAL(retval);
retval = SQLDisconnect(hdbc);
TEST_RETVAL(retval);
retval = SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
TEST_RETVAL(retval);
retval = SQLFreeHandle(SQL_HANDLE_ENV, henv);
TEST_RETVAL(retval);
return 0;We get this problem too. We do a large fetch (200K rows)and find
that not only do the null indicators report incorrectly, but the
data for the nullable column is corrupt as well. -
Using alternate rows with Spry Data Set
Can anyone provide more information on how to implement alternate row colors with a Spry Data Set? What I have done is:
Create spry data set using HTML page as the data set
The html page that displays the data set is: <div spry:region="equipment">
In the default.css page that is linked, I added the info in note #1 below
When the page displays, no colors appear. Tried changing the colors and still no luck. Is there another step to do?
Note #1:
within the default.css, the following are declared:
#equipment odd {
background-color: #CCC;
#equipment even {
background-color: “#F2F2F2;
Note #2:
Here is a link to see the actual pages referenced above.
Any ideas? Getting frustrated!! Thanks in advance for any advice.You are going to kick yourself, but, you haven't assigned any page element the ID #equipment. The region is called that but the table or the DIV does not have an idea and your selector matches nothing...
-
Help needed to find the schema/application data size
Hi,
Would i request you to help me to measure schema size/(APEX)application data size.
I've 3 applications running on same schema and now i want to move one application to new server, new schema,
Now i need to know how much space is required for this application to host on the new server, so i should find the application size and application data size in the current server, your hep is appreciated. thanks in advance.
RegardsHi,
Would i request you to help me to measure schema size/(APEX)application data size.
I've 3 applications running on same schema and now i want to move one application to new server, new schema,
Now i need to know how much space is required for this application to host on the new server, so i should find the application size and application data size in the current server, your hep is appreciated. thanks in advance.
Regards
Maybe you are looking for
-
Error while running ldap40.jar file
Hi, I have cloned an oracle 8i database(which is on windows 2000 sp4 server) to a new server(same configuration i.e windows 2000) to make the new server as a production database. I was not aware that the db server will connect to an LDAP server, so i
-
Invoices report that displays also the VAT number
Hi I am looking for invoices report that displays also the customer/vendor name and its VAT registration number. The customer invoices are SD invoices (can be displayed using the FI) and the supplier invoices are MM or FI invoices. It is relevant for
-
Can only get sound at certain angles.
I don't understand why my ipod only puts through audible sound when I tilt it at a certain angle. Examples: If I hold it upside down, I can get normal sound, but If I tilt it, it looses words, so I get half of the music with out lyrics, or it sounds
-
Hi i have got a problem i'm writting a program that reads in a image, get the image pixels, alter the pixels and then write the image back out again. the problem is that when i write it back out the image goes from colour to gray scale and also when
-
Making changes in cs4 then to encore cs4
hi i thought when i make a change in my project in cs4 such as a small edit it would also go to the encore cs4 proj i created am i right or wrong ?