Difference between dispose and setVisible(false)?
What is the difference between dispose() and setVisible(false)? The only difference I see is that setVisible(false) and bring a window back by using a true flag, while dispose() cannot. Other than that, they appear to do the same thing.
If I want to get rid of a window (with no intention of bring it back), which should I use?
Also, is there a memory advantage to using one or the other?
Thanks for any responses.
setVisible just makes it visible or not...the advantage would be that you would not have to constantly spend time creating a new object, downside is it sits in memory until you really need it again.
dispose will actually tell the gc it's ok to clean up the object...and you would have to make a new one each time you wanted to use it...advantage, frees up ram, disadvantage, takes time to create objects over and over.
Similar Messages
-
Dispose() and setVisible(false)
I'm developing a program containing a wizard and I think the memory is not correctly managed.
Here is an example of the implementation of two dialogs :
public class A extends JDialog {
private B nextDialog= null;
nextButton.addActionListener(new ActionListener() {
setVisible(false);
if (nextDialog== null) {
nextDialog= new B();
nextDialog.setVisible(true);
public class B extends JDialog {
private A previousDialog= null;
previousButton.addActionListener(new ActionListener() {
setVisible(false);
if (previousDialog== null) {
previousDialog= new A();
previousDialog.setVisible(true);
Whenever I click on the nextButton, a new instance of the nextDialog is created and the present dialog is hidden.
Similarly, whenever I click on the previousButton of the second Dialog, a new instance of the first Dialog is created and the present dialog is hidden.
Thus, if I click on the nextButton then previousButton, nextButton, previousButton, etc... a lot of instances will be created.
Should I use dispose() instead of setVisible(false) ?
In this case each instance will be destroyed, won't it ?
Should I use the singleton pattern ?
In this case, the setVisible() method would be preferred to the destroy method ?
Could you help me ?> int visIndex = getVisibleIndex(cont);
String name = cont.getComponent(visIndex).getName();
public static int getVisibleIndex(Container cont) {
if(cont != null && cont.getLayout() instanceof
CardLayout) {
Component[] comps = cont.getComponents();
for(int x = 0; x < comps.length; x++) {
if(comps[x].isVisible()) {
return x;
return -1;
Thanks for re-phrasing my point in a much more understandable way (it was late last night) -
Difference between getSession() and getSession(true)
I am new to servlets. I couldn't find any difference between request.getSession()
and request.getSession(true) methods. Could any one help me plese.
Thanks.I am new to servlets. I couldn't find any difference
between request.getSession()
and request.getSession(true) methods. Could
any one help me plese.
Thanks.getSession() is a convenience method shortcut for getSession(true). There is no difference. There is a difference between getSession() and getSession(false) though...
(ie, if getSession(false) will not make a new session if one does not already exist...) -
Differences between awt and swing
Ive written the following code, however Ive implemented the gui in awt rather then swing. Ive been told it hs too be in swing. What is the difference between swing and awt what will I need to change in my program so that its done using swing rather then the awt? Heres the code:
// pp.java
// Grant Brown
// 22/02/02
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
// =========================================================
// Class: pp
// This class drives the customer manager. It contains the
// main method which gets called as soon as this application
// begins to run.
// =========================================================
class pp extends Frame implements ActionListener
// Container of customer objects
private Vector customers = new Vector (100);
// List of names component. (Must specify java.awt in
// front of List to distinguish the List class in the
// java.awt package from the List class in the java.util
// package.)
private java.awt.List names = new java.awt.List ();
// Delete and update button components.
private Button delete;
private Button update;
// Default constructor.
public pp ()
// Assign "Paper Round Manager" to title bar of frame window.
super ("Paper Round Manager");
// Add a listener that responds to window closing
// events. When this event occurs (by clicking on the
// close box in the title bar), save customers and exit.
addWindowListener (new WindowAdapter ()
public void windowClosing
(WindowEvent e)
saveCustomers ();
System.exit (0);
// Place an empty label in the north part of the frame
// window. This is done to correct an AWT positioning
// problem.
Label l = new Label ();
add ("North", l);
// Place the names component in the center part of the
// frame window.
add ("Center", names);
// Create a panel object to hold four buttons.
Panel p = new Panel ();
Button b;
// Add an Insert button to the Panel object and register
// the current pp object as a listener for button events.
p.add (b = new Button ("Insert"));
b.addActionListener (this);
// Add a Delete button to the Panel object and register
// the current pp object as a listener for button events.
p.add (delete = new Button ("Delete"));
delete.addActionListener (this);
// The Delete button should be disabled until there is at
// least one customer to delete.
delete.setEnabled (false);
// Add an Update button to the Panel object and register
// the current pp object as a listener for button events.
p.add (update = new Button ("Update"));
update.addActionListener (this);
// The Update button should be disabled until there is at
// least one customer to update.
update.setEnabled (false);
// Add a Finish button to the Panel object and register
// the current customer object as a listener for button events.
p.add (b = new Button ("Finish"));
b.addActionListener (this);
// Add the panel object to the frame window container.
add ("South", p);
// Set the background of the frame window container to
// lightGray
setBackground (Color.lightGray);
// Set the size of the frame window container to 400
// pixels horizontally by 200 pixels vertically.
setSize (400, 200);
// Allow the user to resize the frame window.
setResizable (true);
// Load all contacts.
loadCustomers ();
// Make sure that the frame window is visible.
setVisible (true);
public void actionPerformed (ActionEvent e)
if (e.getActionCommand ().equals ("Delete"))
delete ();
else
if (e.getActionCommand ().equals ("Finish"))
saveCustomers ();
System.exit (0);
else
if (e.getActionCommand ().equals ("Insert"))
insert ();
else
update ();
public Insets getInsets ()
// Return an Insets object that describes the number of
// pixels to reserve as a border around the edges of the
// frame window.
return new Insets (10, 10, 10, 10);
public static void main (String [] args)
// Create a new pp object and let it do its thing.
new pp ();
private void delete ()
// Obtain index of selected contact item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a contact if no contact item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Remove the contact item from the names component.
names.remove (index);
// Remove the Customer object from the contacts Vector
// object.
customers.remove (index);
// If there are no more customers ...
if (customers.size () == 0)
delete.setEnabled (false);
update.setEnabled (false);
else
// Make sure that the first contact item in the names
// list is highlighted.
names.select (0);
private void insert ()
// Create an Insert data entry form to enter information
// for a new customer.
DataEntryForm def = new DataEntryForm (this, "Insert");
// If the bOk Boolean flag is set, this indicates the user
// exited the form by pressing the Ok button.
if (def.bOk)
// Create a Contact object and assign information from
// the form to its fields.
Customer temp = new Customer ();
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.round = new String (def.round.getText ());
temp.address = new String (def.address.getText ());
temp.phone = new String (def.phone.getText ());
// Add a new customer item to the names component.
names.add (temp.name + ", " + temp.publication);
// Add the Customer object to the contacts Vector
// object.
customers.add (temp);
// Make sure that the Delete and Update buttons are
// enabled.
delete.setEnabled (true);
update.setEnabled (true);
// Destroy the dialouge box.
def.dispose ();
// Make sure that the first customer item in the names list
// is highlighted.
names.select (0);
// ===========================================================
// Load all contacts from contacts.dat into the contacts
// Vector object. Also, make sure that the last name/first
// name from each contact is combined into a String object and
// inserted into the names component - as a contact item.
// ===========================================================
private void loadCustomers ()
FileInputStream fis = null;
try
fis = new FileInputStream ("Customers.dat");
DataInputStream dis = new DataInputStream (fis);
int nCustomers = dis.readInt ();
for (int i = 0; i < nCustomers; i++)
Customer temp = new Customer ();
temp.name = dis.readUTF ();
temp.publication = dis.readUTF ();
temp.round = dis.readUTF ();
temp.address = dis.readUTF ();
temp.phone = dis.readUTF ();
names.add (temp.name + ", " + temp.publication);
customers.add (temp);
if (nCustomers > 0)
delete.setEnabled (true);
update.setEnabled (true);
catch (IOException e)
finally
if (fis != null)
try
fis.close ();
catch (IOException e) {}
// Make sure that the first contact item in the names list
// is highlighted.
names.select (0);
// ========================================================
// Save all Customer objects from the customer Vector object
// to customer.dat. The number of customerss are saved as an
// int to make it easy for loadCustomers () to do its job.
// ========================================================
private void saveCustomers ()
FileOutputStream fos = null;
try
fos = new FileOutputStream ("customers.dat");
DataOutputStream dos = new DataOutputStream (fos);
dos.writeInt (customers.size ());
for (int i = 0; i < customers.size (); i++)
Customer temp = (Customer) customers.elementAt (i);
dos.writeUTF (temp.name);
dos.writeUTF (temp.publication);
dos.writeUTF (temp.round);
dos.writeUTF (temp.address);
dos.writeUTF (temp.phone);
catch (IOException e)
MsgBox mb = new MsgBox (this, "PP Error",
e.toString ());
mb.dispose ();
finally
if (fos != null)
try
fos.close ();
catch (IOException e) {}
private void update ()
// Obtain index of selected customer item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a customer if no customer item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Obtain a reference to the customer object (from the
// customers Vector object) that is associated with the
// index.
Customer temp = (Customer) customers.elementAt (index);
// Create and display an update entry form.
DataEntryForm def = new DataEntryForm (this, "Update",
temp.name,
temp.publication,
temp.round,
temp.address,
temp.phone);
// If the user pressed Ok...
if (def.bOk)
// Update the customer information in the customers
// Vector object.
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.round = new String (def.round.getText ());
temp.address = new String (def.address.getText ());
temp.phone = new String (def.phone.getText ());
// Make sure the screen reflects the update.
names.replaceItem (temp.name + ", " + temp.publication,
index);
// Destroy the dialouge box.
def.dispose ();
// Make sure that the first customer item in the names
// list is highlighted.
names.select (0);Ive doen pretty much what you said burt now my program isnt working at all. The window comes up but instead of doing something when you click the button it just throws shit loads of exceptions. Heres my abridged code
// pp.java
// Grant Brown
// 22/02/02
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import javax.swing.*;
// =========================================================
// Class:PP
// This class drives the Paper Round manager. It contains the
// main method which gets called as soon as this application
// begins to run.
// =========================================================
class pp extends JFrame implements ActionListener
// Container of customer objects (one object per customer)
private Vector customers = new Vector (100);
// List of names component. (Must specify java.awt in
// front of List to distinguish the List class in the
// java.awt package from the List class in the java.util
// package.)
private java.awt.List names = new java.awt.List ();
// Delete and update button components.
private JButton delete;
private JButton update;
// Default constructor.
public pp ()
// Assign Contact Manager to title bar of frame window.
super ("Paper Round Manager");
// Add a listener that responds to window closing
// events. When this event occurs (by clicking on the
// close box in the title bar), save contacts and exit.
addWindowListener (new WindowAdapter ()
public void windowClosing
(WindowEvent e)
saveCustomers ();
System.exit (0);
// Place an empty label in the north part of the frame
// window. This is done to correct an AWT positioning
// problem. (One thing that you'll come to realize as
// you work with the AWT is that there are lots of bugs.)
JLabel l = new JLabel ();
getContentPane().add ("North", l);
// Place the names component in the center part of the
// frame window.
getContentPane().add ("Center", names);
// Create a panel object to hold four buttons.
JPanel p = new JPanel ();
JButton b;
// Add an Insert button to the Panel object and register
// the current cm object as a listener for button events.
p.add (b = new JButton ("Insert"));
b.addActionListener (this);
// Add a Delete button to the Panel object and register
// the current cm object as a listener for button events.
p.add (delete = new JButton ("Delete"));
delete.addActionListener (this);
// The Delete button should be disabled until there is at
// least one contact to delete.
delete.setEnabled (false);
// Add an Update button to the Panel object and register
// the current cm object as a listener for button events.
p.add (update = new JButton ("Update"));
update.addActionListener (this);
// The Update button should be disabled until there is at
// least one contact to update.
update.setEnabled (false);
// Add a Finish button to the Panel object and register
// the current cm object as a listener for button events.
p.add (b = new JButton ("Finish"));
b.addActionListener (this);
// Add the panel object to the frame window container.
getContentPane().add ("South", p);
// Set the background of the frame window container to
// lightGray (to give a pleasing effect).
setBackground (Color.lightGray);
// Set the size of the frame window container to 400
// pixels horizontally by 200 pixels vertically.
setBounds (50, 100, 400, 200);
// Do not allow the user to resize the frame window.
loadCustomers ();
// Load all contacts.
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Make sure that the frame window is visible.
setVisible (true);
public void actionPerformed (ActionEvent e)
if (e.getActionCommand ().equals ("Delete"))
delete ();
else
if (e.getActionCommand ().equals ("Finish"))
saveCustomers ();
System.exit (0);
else
if (e.getActionCommand ().equals ("Insert"))
insert ();
else
update ();
public Insets getInsets ()
// Return an Insets object that describes the number of
// pixels to reserve as a border around the edges of the
// frame window.
return new Insets (10, 10, 10, 10);
public static void main (String [] args)
// Create a new cm object and let it do its thing.
new pp ();
private void delete ()
// Obtain index of selected customer item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a contact if no contact item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Remove the customer item from the names component.
names.remove (index);
// Remove the Customer object from the contacts Vector
// object.
customers.remove (index);
// If there are no more customers ...
if (customers.size () == 0)
delete.setEnabled (false);
update.setEnabled (false);
else
// Make sure that the first contact item in the names
// list is highlighted.
names.select (0);
private void insert ()
// Create an Insert data entry form to enter information
// for a new contact.
DataEntryForm def = new DataEntryForm (this, "Insert");
// If the bOk Boolean flag is set, this indicates the user
// exited the form by pressing the Ok button.
if (def.bOk)
// Create a Customer object and assign information from
// the form to its fields.
Customer temp = new Customer ();
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.address = new String (def.address.getText ());
temp.round = new String (def.round.getText ());
temp.phone = new String
(def.phone.getText ());
// Add a new customer item to the names component.
names.add (temp.publication + ", " + temp.address);
// Add the Customer object to the contacts Vector
// object.
customers.add (temp);
// Make sure that the Delete and Update buttons are
// enabled.
delete.setEnabled (true);
update.setEnabled (true);
// Destroy the dialog box.
def.dispose ();
// Make sure that the first customer item in the names list
// is highlighted.
names.select (0);
// ===========================================================
// Load all customers from customers.dat into the customers
// Vector object. Also, make sure that the last name/first
// name from each contact is combined into a String object and
// inserted into the names component - as a contact item.
// ===========================================================
private void loadCustomers ()
FileInputStream fis = null;
try
fis = new FileInputStream ("customers.dat");
DataInputStream dis = new DataInputStream (fis);
int nCustomers = dis.readInt ();
for (int i = 0; i < nCustomers; i++)
Customer temp = new Customer ();
temp.name = dis.readUTF ();
temp.publication = dis.readUTF ();
temp.address = dis.readUTF ();
temp.round = dis.readUTF ();
temp.phone = dis.readUTF ();
names.add (temp.publication + ", " + temp.address);
customers.add (temp);
if (nCustomers > 0)
delete.setEnabled (true);
update.setEnabled (true);
catch (IOException e)
finally
if (fis != null)
try
fis.close ();
catch (IOException e) {}
// Make sure that the first customer item in the names list
// is highlighted.
names.select (0);
// ========================================================
// Save all customer objects from the contacts Vector object
// to customers.dat. The number of contacts are saved as an
// int to make it easy for loadCustomers () to do its job.
// ========================================================
private void saveCustomers ()
FileOutputStream fos = null;
try
fos = new FileOutputStream ("customers.dat");
DataOutputStream dos = new DataOutputStream (fos);
dos.writeInt (customers.size ());
for (int i = 0; i < customers.size (); i++)
Customer temp = (Customer) customers.elementAt (i);
dos.writeUTF (temp.name);
dos.writeUTF (temp.publication);
dos.writeUTF (temp.address);
dos.writeUTF (temp.round);
dos.writeUTF (temp.phone);
catch (IOException e)
MsgBox mb = new MsgBox (this, "PP Error",
e.toString ());
mb.dispose ();
finally
if (fos != null)
try
fos.close ();
catch (IOException e) {}
private void update ()
// Obtain index of selected customer item from the names
// component.
int index = names.getSelectedIndex ();
// If no item was selected, index is -1. We cannot update
// a customer if no customer item in the names component was
// selected - because we would have nothing to work with.
if (index != -1)
// Obtain a reference to the Customer object (from the
// customer Vector object) that is associated with the
// index.
Customer temp = (Customer) customers.elementAt (index);
// Create and display an update entry form.
DataEntryForm def = new DataEntryForm (this, "Update",
temp.name,
temp.publication,
temp.address,
temp.round,
temp.phone);
// If the user pressed Ok...
if (def.bOk)
// Update the customer information in the customers
// Vector object.
temp.name = new String (def.name.getText ());
temp.publication = new String (def.publication.getText ());
temp.address = new String (def.address.getText ());
temp.round = new String (def.round.getText ());
temp.phone = new String (def.phone.getText ());
// Make sure the screen reflects the update.
names.replaceItem (temp.publication + ", " + temp.address,
index);
// Destroy the dialog box.
def.dispose ();
// Make sure that the first customer item in the names
// list is highlighted.
names.select (0);
// ========================================================
// Class: Customer
// This class describes the contents of a business customer.
// ========================================================
class Customer
public String name;
public String publication;
public String address;
public String round;
public String phone;
// ==========================================================
// Class: DataEntryForm
// This class provides a data entry form for entering customer
// information.
// ==========================================================
class DataEntryForm extends JDialog implements ActionListener
// bOk is a boolean flag. When true, it indicates that
// the Ok button was pressed to terminate the dialog box
// (as opposed to the Cancel button).
public boolean bOk;
// The following components hold the text that the user
// entered into the visible text fields.
public JTextField name;
public JTextField publication;
public JTextField address;
public JTextField round;
public JTextField phone;
public void actionPerformed (ActionEvent e)
// If the user pressed the Ok button, indicate this
// by assigning true to bOk.
if (e.getActionCommand ().equals ("Ok"))
bOk = true;
// Destroy the dialog box and return to the point
// just after the creation of the DataEntryForm object.
dispose ();
public DataEntryForm (JFrame parent, String title)
// Call the other constructor. The current constructor
// is used for insert operations. The other constructor
// is used for update operations.
this (parent, title, "", "", "", "", "");
public DataEntryForm (JFrame parent, String title,
String name, String publication,
String address, String round,
String phone)
// Initialize the superclass layer.
super (parent, title, true);
// Choose a grid bag layout so that components can be more
// accurately positioned. (It looks nicer.)
setLayout (new GridBagLayout ());
// Add appropriate first name, last name, phone, fax, and
// email components to the current DataEntryForm container.
// (Remember, DataEntryForm is a subclass of Dialog.
// Dialog is a container. Therefore, DataEntryForm
// inherits the ability to be a container.)
addComponent (this, new JLabel ("Name: "), 0, 0, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.name = new JTextField (15);
addComponent (this, this.name, 1, 0, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.name.setText (name);
addComponent (this, new JLabel ("Publications: "), 0, 1, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.publication = new JTextField (15);
addComponent (this, this.publication, 1, 1, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.publication.setText (publication);
addComponent (this, new JLabel ("Address "), 0, 2, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.address = new JTextField (15);
addComponent (this, this.address, 1, 2, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.address.setText (address);
addComponent (this, new JLabel ("Round No "), 0, 3, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.round = new JTextField (15);
addComponent (this, this.round, 1, 3, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.round.setText (round);
addComponent (this, new JLabel ("Phone Number "), 0, 4, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.WEST);
this.phone = new JTextField (15);
addComponent (this, this.phone, 1, 4, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
if (title.equals ("Update"))
this.phone.setText (phone);
addComponent (this, new JLabel (""), 0, 5, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
addComponent (this, new JLabel (""), 1, 5, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
JButton b;
// Add an Ok button to this container.
addComponent (this, b = new JButton ("Ok"), 0, 6, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
b.addActionListener (this);
// Add a Cancel button to this container.
addComponent (this, b = new JButton ("Cancel"), 1, 6, 1, 1,
GridBagConstraints.NONE,
GridBagConstraints.CENTER);
b.addActionListener (this);
// Set the size of the dialog window to 250 pixels
// horizontally by 200 pixels vertically.
setSize (250, 200);
// Do not allow users to resize the dialog window.
setResizable (false);
// Make sure that the dialog window is visible.
setVisible (true);
private void addComponent (Container con, Component com,
int gridx, int gridy,
int gridw, int gridh, int fill,
int anchor)
// Get the current layout manager. It is assumed to
// be a GridBagLayout object.
LayoutManager lm = con.getLayout ();
// Create a GridBagConstraints object to make it
// possible to customize component positioning.
GridBagConstraints gbc = new GridBagConstraints ();
// Assign the x and y grid positions.
gbc.gridx = gridx;
gbc.gridy = gridy;
// Assign the number of grid blocks horizontally and
// vertically that are occupied by the component.
gbc.gridwidth = gridw;
gbc.gridheight = gridh;
// Specify the component's resize policy (fill) and
// the direction in which the component is positioned
// when its size is smaller than available space (anchor).
gbc.fill = fill;
gbc.anchor = anchor;
// Set the new constraints that the grid bag layout
// manager will use.
((GridBagLayout) lm).setConstraints (com, gbc);
// Add the component to the container.
con.add (com);
// ===========================================================
// Class: MsgBox
// This class displays a message box to the user. The message
// is usually an error message. The user must press the Ok
// button to terminate the message box.
// ===========================================================
class MsgBox extends JDialog implements ActionListener
public void actionPerformed (ActionEvent e)
// Terminate the dialog box in response to the user
// pressing the Ok button.
dispose ();
public MsgBox (JFrame parent, String title, String msg)
// Initialize the superclass layer.
super (parent, title, true);
// Store the msg argument in a Label object and add
// this object to the center part of the dialog window.
JLabel l = new JLabel (msg);
add ("Center", l);
// Create a Button object and add it to the south part
// of the dialog window.
JButton b = new JButton ("Ok");
add ("South", b);
// Make the current object a listener to events that
// occur as a result of the user pressing the Ok
// button.
b.addActionListener (this);
// Make sure that the Ok button has the focus.
b.requestFocus ();
// Do not allow users to resize the dialog window.
setResizable (false);
// Allow the layout manager to choose an appropriate
// size for the dialog window.
pack ();
// Make sure that the dialog window is visible.
setVisible (true);
} -
What is the difference between exists and in
hi all
if i have these queries
1- select ename from emp where ename in ( select ename from emp where empno=10)
and
2- select ename from emp where exists ( select ename from emp where empno=10)
what is the difference between exists and in is that only when i use in i have to bring the field name or what.... i mean in a complex SQL queries is it will give the same answer
ThanksYou get two entirely different result sets that may be the same. Haah! What do I mean by that.
SQL> select table_name from user_tables;
TABLE_NAME
BAR
FOO
2 rows selected.
SQL> select table_name from user_tables where table_name in (select table_name from user_tables where table_name = 'FOO');
TABLE_NAME
FOO
1 row selected.
SQL> select table_name from user_tables where exists(select table_name from user_tables where table_name = 'FOO');
TABLE_NAME
BAR
FOO
2 rows selected.So, why is this? the WHERE EXISTS means 'if the next is true', much like where 1=1 being always true and 1=2 being always false. In this case, where exists could be TRUE or FALSE, depending on the subquery.
WHERE EXISTS can be useful for something like testing if we have data, without actually having to return columns.
So, if you want to see if an employee exists you might say
SELECT 1 FROM DUAL WHERE EXISTS( select * from emp where empid = 10);
If there is a row in emp for empid=10, then you get back 1 from dual;
This is what I call an 'optimistic' lookup because the WHERE EXISTS ends as soon as there is a hit. It does not care how many - only that at least one exists. It is optimistic because it will continue processing the table lookup until either it hits or reaches the end of the table - for a non-indexed query. -
Difference between validation and susbstittution with tcodes
hi all can any body tell me about difference between validation and susbstittution with tcodes
regars
sravyaHi,
Settting up the FI Validations
You can use additional validation to supplement the existing SAP logic to fit you into your businness needs.
For e.g. to allow postings from company code 0001 to business area AA only.
GGB0 - To maintain the validations
Validation - Enter a validation name e.g. VBUS
Applicaion Area - SAP module e.g. FI
Calling Point - Dependent upon the application area that is selected.
0001 - Document Header - validate enteries at document header, e.g BKPF table
0002 - Line Items - check line item entris within a document, e.g. BSEG table
0003 - Complete Document - check settings for the whole documents.
e.g. Validation step 001
Allowed company code '0001' to post to business area AA only. 'FI00' checks that line item is from FI.
If checks failed, the error message number 14 is displayed to stop the transaction.
Prerequisite
<BSEG> $BUKRS = '0001' AND
<BKPF> $GLVOR = 'FI00'
Check
<BSEG> $GSBER = 'AA'
Message
Type E No. 14 - Business Area not allowed for company 0001
Output fields 1 - BSEG - GSBER 2 - BSEG - BUKRS
3 - 4
OB28 - Define Validations for Posting
CC CallPnt Validation Description Activtn Level
0001 2 VBUS Business Area Validation 1
Activtn Level - 0 - Not Active 1 - Activated 2 - Activated for all except batch input
GGB4 - Manage the activation of all validations in the SAP system.
Validations, Substitutions, and Rules
Purpose
With the validations and substitutions software, you can validate and/or substitute data at the time of entry in the FI-SL System and other SAP Systems.
Implementation Considerations
You do not need to change the standard system to customize your validations and substitutions. For each installation, you can define exactly which validations and substitutions are necessary to ensure the integrity of your data.
Features
Validation
In the SAP System, almost all input values are validated by a program or against tables or master files. Since some types of validations cannot be standardized, you can use FI-SL's validations program to create validations for your system.
With validations, you can check values and combinations of values as they are being entered in the SAP environment. Validation rules are stored in the Rule Manager; as data is entered, the Integration Manager validates the data against the validation rules stored in the Rule Manager. Because data is validated before it is posted, only valid information enters the FI-SL System.
You define validation rules using Boolean logic. When you define a validation rule, the system checks the validation rule to ensure that it is syntactically correct.
You can also define the result of breaking the validation rule. For instance, you can specify that a message is issued but the user can continue processing. You can also force the user to correct the error before processing can continue.
For more information, see Validation or What Are Validations?. For more information on using validations, see Creating a Validation. For more information on Boolean Logic, see Introduction to Boolean Logic.
Substitution
Substitution rules are stored in the Rule Manager. When data is entered in the system, it is substituted by the Integration Manager. The Integration Manager calls the Rule Manager. Substitution occurs before the data is posted to the FI-SL databases.
You define substitution rules using Boolean logic. When you define a substitution rule, the system checks the substitution rule to ensure that it is syntactically correct.
For more information, see Substitution or What Are Substitutions?. For more information on using substitutions, see Creating a Substitution. For more information on Boolean Logic, see Introduction to Boolean Logic.
Rules
A rule is a Boolean expression that you can use as a condition, as a check, or in another rule. Rules enable you to refer to frequently used Boolean statements simply by specifying the rule name.
The FI-SL Integration Manager uses Boolean logic. When you use Boolean logic and syntax, you can:
Validate data
Substitute data
Select ledgers for posting
Transfer substitution data to a rollup ledger
Select report data
The Rule Manager stores the Boolean rules used to analyze data. The Integration Manager calls the Rule Manager and determines whether entered data should be used. If a Boolean statement is true, an action is taken; if a statement is false, no action is taken.
Boolean logic is used in the following FI-SL modules:
Validation
Substitution
Ledger selection
Report Writer
Rollups
To use Boolean Logic in one of the functions listed, you create statements that are used as formulas in the FI-SL System. For more information on using Boolean Logic, see Introduction to Boolean Logic or Boolean Logic Statements and Rules. -
Difference between -TlsDomain and -DomainSecureEnabled Parameters for Sendconnectors
Hi Exchange-Community,
I just came across with the different possibilties for securing mail flow between Partner companies.
I'm a little confused by the difference between -TlsDomain and -DomainSecureEnabled. All Whitepapers and tutorials for secured Partner communication refer only to the -DomainSecureEnabled Parameter. (With conjunction of Set-transportConfig -tlssenddomainsecurelist
etc. of course)
Can anybody enlight me when I have to use the -TlsDomain Parameter, and what it finally does?
Thanks for any response
ChrisHi Chris,
The DomainSecureEnabled parameter is part of the process to enable mutual Transport Layer Security (TLS) authentication for the domains serviced by this Send connector. Mutual TLS authentication functions correctly only when the following conditions
are met:
The value of the DomainSecureEnabled parameter must be $true.
The value of the DNSRoutingEnabled parameter must be $true.
The value of the IgnoreStartTLS parameter must be $false.
The TlsDomain parameter specifies the domain name that the Send connector uses to verify the FQDN of the target certificate when establishing a TLS secured connection.
This parameter is used only if the TlsAuthLevel parameter is set to DomainValidation.
A value for this parameter is required if:
The TLSAuthLevel parameter is set to DomainValidation.
The DNSRoutingEnabled parameter is set to $false (smart host Send connector).
For more information about them, please refer to Parameters in Set-SendConnector:
http://technet.microsoft.com/en-us/library/aa998294(v=exchg.150).aspx
Thanks,
Winnie Liang
TechNet Community Support -
What is the difference between OEE and OSE
What is the difference b/w
Oracle8i Enterprise Edition and Oracle8i Standard Edition?
Which version I choose to install the Oracle Server?The real difference between one and the another one are the options installed in the database. I have a document where you can see in detail what options have one and what options have the another one.
Which version I choose to install the Oracle Server?
r.- That is quite related to what options you need for your applications. Options like : partitioning, etc.
With this view you can see what options are available in your database.
SQL> select * from v$option;
PARAMETER VALUE
Partitioning TRUE
Objects TRUE
Real Application Clusters FALSE
Advanced replication TRUE
Bit-mapped indexes TRUE
Connection multiplexing TRUE
Connection pooling TRUE
Database queuing TRUE
Incremental backup and recover TRUE
y
PARAMETER VALUE
Instead-of triggers TRUE
Parallel backup and recovery TRUE
Parallel execution TRUE
Parallel load TRUE
Point-in-time tablespace recov TRUE
ery
Fine-grained access control TRUE
Proxy authentication/authoriza TRUE
tion
PARAMETER VALUE
Change Data Capture TRUE
Plan Stability TRUE
Online Index Build TRUE
Coalesce Index TRUE
Managed Standby TRUE
Materialized view rewrite TRUE
Materialized view warehouse re TRUE
fresh
Database resource manager TRUE
Spatial TRUE
PARAMETER VALUE
Visual Information Retrieval TRUE
Export transportable tablespac TRUE
es
Transparent Application Failov TRUE
er
Fast-Start Fault Recovery TRUE
Sample Scan TRUE
Duplexed backups TRUE
Java TRUE
PARAMETER VALUE
OLAP Window Functions TRUE
Block Media Recovery TRUE
Fine-grained Auditing TRUE
Application Role TRUE
Enterprise User Security TRUE
Oracle Data Guard TRUE
Oracle Label Security FALSE
OLAP TRUE
Heap segment compression TRUE
Join index TRUE
Trial Recovery TRUE
PARAMETER VALUE
Oracle Data Mining TRUE
Online Redefinition TRUE
Streams TRUE
Very Large Memory TRUE
File Mapping TRUE
48 rows selected.
SQL>
Joel P�rez -
Whats the difference between GSM and CDMA?
Sorry if this has been answered before but what is the difference between these two model types? In terms of world wide usage?
Thanks.A Google search is your friend with a wealth of info at your disposal with just a quick search entry and mouse click away.
http://www.wisegeek.com/what-is-the-difference-between-gsm-and-cdma.htm
http://gizmodo.com/#!5637136/giz-explains-gsm-vs-cdma
These two links were in the top 5 hits with a search for "GSM and CDMA". -
Mapping: Difference between createIf and ifWithoutElse
Suppose i have some condition based on which i am creating a node. Is there any difference between createIf and ifWithoutElse for creating the node (with or without context change)?
Hi Mala,
1. IfWithoutElse is usually used to set the filters in mapping. When If condition is satisfied the value of then is returned in output.
Else value is depends upon the mapping, i.e. where u want this value ( target or in function)
2. Createif is used to insert any structuring element in the target structure if it is not present in source.
To create a condition based node you have to go to CreateIf function as ifWithoutElse is boolean function deals with the true n false status of values and not with node creation.
Regards,
Shri
Reward points if u understood the concept. -
Difference between defun and Rule
Hi all,
Does anyone know the difference between <defun> and <Rule>? Can <defun> be used to generate a library of methods.. the only thing I think is you have to include the form with all these defun's to call any of those functions.
Would be nice if <defun> uses the same methodology as most programming languages... local variables are stored on stack, have higher precedence than global variables, their value is lost once the function returns, etc.... This is not the case in <Rule> where it can access the variables in the workflow which calls the rules! + localScope=false is the default value, etc.
Any other differences? (also validate if the differences I mentioned are correct).
Thanks,
Adi.Jayant,
The Implementation Rule is we write required SQL codes and Business rule is more Description about what is the Implementation rule is about. Lets say for an Example CASE WHEN COLUMN='ID' THEN 1 ELSE NULL END so the Business rule can write some thing like this - To check for column value if value is ID then populate as 1 else populate Null.
Hope this answers your question. If in case you worrying about or thinking should i need to write in Business rule i would say dont worry about it.
Let me know if you are looking for more information. -
Difference between Null and null?
What is the difference between null and NULL?
When is each used?
Thanks,veryConfused wrote:
There is a null in java, but no NULL. null means no value. However, when assigning value, the following is different:Although the empty String has no special role. Null means, the referential type is not assigned (doesn't refer) to a specific object. The empty String is just another object though, so seeing it or pointing it out as something special when it actually isn't at all (no more special than new Integer(0) or new Object[0]) just adds to the confusion. -
Difference between GUI_UPLOAD and WS_UPLOAD
Hi,
Please make me clear about the difference between GUI_UPLOAD and WS_UPLOAD. In which cases we need to use these modules...??
Thanks,
SatishI would suggest to always use the GUI_UPLOAD. I say this because this is the function module which is used in the GUI_UPLOAD method of the class CL_GUI_FRONTEND_SERVICES. Really, you should probably use the class/method instead of the function module.
data: filename type string.
filename = p_file.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = filename
filetype = 'ASC'
changing
data_tab = iflatf
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
no_authority = 6
unknown_error = 7
bad_data_format = 8
unknown_dp_error = 12
access_denied = 13
others = 17.
Regards,
Rich Heilman -
Difference between char and varchar, also the difference between varchar2
Hi,
Can anyone explain me the difference between char and varchar, and also the difference between varchar and varchar2...Varchar2 is variable width character data type, so if you define column with width 20 and insert only one character to tis column only, one character will be stored in database. Char is not variable width so when you define column with width 20 and insert one character to this column it will be right padded with 19 spaces to desired length, so you will store 20 characters in the dattabase (follow the example 1). Varchar data type from Oracle 9i is automaticlly promoted to varchar2 (follow example 2)
Example 1:
SQL> create table tchar(text1 char(10), text2 varchar2(10))
2 /
Table created.
SQL> insert into tchar values('krystian','krystian')
2 /
1 row created.
SQL> select text1, length(text1), text2, length(text2)
2 from tchar
3 /
TEXT1 LENGTH(TEXT1) TEXT2 LENGTH(TEXT2)
krystian 10 krystian 8
Example 2:
create table tvarchar(text varchar(10))
SQL> select table_name,column_name,data_type
2 from user_tab_columns
3 where table_name = 'TVARCHAR'
4 /
TABLE_NAME COLUMN_NAME DATA_TYPE
TVARCHAR TEXT VARCHAR2
Best Regards
Krystian Zieja / mob -
The difference between Lion and Mountain Lion
Can some one explain to me the difference between Lion and Mtn Lion? I'm currently 10.6.8 Is it beneficiall for me to upgrade?
Mountain Lion is an enhanced version of previous OS X and so that is Mavericks.
About upgrading it all depends on what your needs are and if your hardware supports it.
System requirements for OS X Lion
System requirements for OS X Mountain Lion
OS X Mavericks: System Requirements
Please check also applications compatibility. From Lion onward, you cannot run PPC application.
Maybe you are looking for
-
Why do I not have 'Save as' and 'Versions' in Mountain Lion 10.8.2
I know these features were brought back in Mountain Lion but I don't seem to have it. I think I didn't have it when I was running 10.8.1 as well. Most of my iWork software does a strange thing by saving the file with a '~' at the end of the name, whe
-
Hi, Where is the Supplier blocking code maintained in Customization? Thanks, Chintan.
-
how can i sequence my photos imported from Aperture on an iweb page? they are importing chaotically.
-
Simple Membership Provider Migration Error
I am trying to publish my website using Windows Azure. I have migrations enabled and I am also using Simple Membership Provider. When I publish the website the Simple Membership tables are created in my database but none of my other tables are create
-
HT5312 how to reset Apple ID security questions ?
how to reset Apple ID security questions ?