WPF How can I implement the INotifyPropertyChanged in a Three-tier architecture?

I am a student and I am confused on using the INotifyPropertyChanged in a three-tier style of coding. Can you guys help me a bit with these?
I have a solution named MetroAppProject. It is composed of four projects (I omitted the using clauses and references, just imagine they are there and are working fine):
1. MetroApp.BluePrints - a class library composed of the classes in my sql db
An example of my class
namespace MetroApp.BluePrints
    public partial class Patient
        public long Id { get; set; }
        public string PatientNumber { get; set; }
        public string LastName { get; set; }
        public string FirstName { get; set; }
        public string MiddleName { get; set; }        
        public string AddressLine1 { get; set; }
        public Nullable<short> CityId { get; set; }
public string CityName { get; set; }
        public Nullable<short> ProvinceId { get; set; }
public string ProvinceName { get; set; }        
Then the second project:
2. MetroApp.DataAccess = a class library composed of methods that calls my sql procedures. I used the SqlHelper class which contains the connection strings and other stuffs.
example class
namespace MetroApp.DataAccess
    public class PatientDb
public Patient Retrieve(PatientParams parameters)
            SqlCommand command = new SqlCommand();
            Patient singItem = new Patient();
            command.CommandText = "RetrievePatients";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@Id", parameters.Id).Direction = ParameterDirection.Input;
            DataTable dt = SqlHelper.GetData(command);
            if (dt.Rows.Count > 0)
                DataRow row = dt.Rows[0];
                singItem.Id = TDefaultValue.GetInt(row["Id"].ToString());
                singItem.PatientNumber = TDefaultValue.GetString(row["PatientNumber"].ToString());
                singItem.LastName = TDefaultValue.GetString(row["LastName"].ToString());
                singItem.FirstName = TDefaultValue.GetString(row["FirstName"].ToString());
                singItem.MiddleName = TDefaultValue.GetString(row["MiddleName"].ToString());
                singItem.AddressLine1 = TDefaultValue.GetString(row["AddressLine1"].ToString());
                singItem.CityId = TDefaultValue.GetShort(row["CityId"].ToString());
                singItem.CityName = TDefaultValue.GetString(row["CityName"].ToString());
                singItem.ProvinceId = TDefaultValue.GetShort(row["ProvinceId"].ToString());
                singItem.ProvinceName = TDefaultValue.GetString(row["ProvinceName"].ToString());
            return singItem;
        public List<Patient> RetrieveMany(PatientParams parameters)
            var items = new List<Patient>();
            var command = new SqlCommand();
            command.CommandText = "RetrievePatients";
            command.CommandType = CommandType.StoredProcedure;
            command.Parameters.AddWithValue("@Id", parameters.Id).Direction = ParameterDirection.Input;
            command.Parameters.AddWithValue("@PatientNumber", parameters.PatientNumber).Direction = ParameterDirection.Input;
            command.Parameters.AddWithValue("@LastName", parameters.LastName).Direction = ParameterDirection.Input;
            command.Parameters.AddWithValue("@FirstName", parameters.FirstName).Direction = ParameterDirection.Input;
            command.Parameters.AddWithValue("@MiddleName", parameters.MiddleName).Direction = ParameterDirection.Input;            
            command.Parameters.AddWithValue("@CityId", parameters.CityId).Direction = ParameterDirection.Input;
            command.Parameters.AddWithValue("@ProvinceId", parameters.ProvinceId).Direction = ParameterDirection.Input;
            DataTable dt = SqlHelper.GetData(command);
            foreach (DataRow row in dt.Rows)
                var item = new Patient();
                item.Id = TDefaultValue.GetLong(row["Id"].ToString());
                item.PatientNumber = (row["PatientNumber"].ToString());
                item.LastName = (row["LastName"].ToString());
                item.FirstName = (row["FirstName"].ToString());
                item.MiddleName = (row["MiddleName"].ToString());                
                item.AddressLine1 = (row["AddressLine1"].ToString());
                item.CityId = (short)row["CityId"].ToString();
                item.CityName = (row["CityName"].ToString());
                item.ProvinceId = (short)row["ProvinceId"].ToString();
                item.ProvinceName = (row["ProvinceName"].ToString());
                items.Add(item);
            return items;
        public bool Insert(Patient entity, int userId, ref bool doesExist)
            var command = new SqlCommand();
            try
                command.CommandText = "AddPatient";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@PatientNumber", entity.PatientNumber).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@LastName", entity.LastName).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@FirstName", entity.FirstName).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@MiddleName", entity.MiddleName).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@AddressLine1", entity.AddressLine1).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@CityId", entity.CityId).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@ProvinceId", entity.ProvinceId).Direction = ParameterDirection.Input;
command.Parameters.AddWithValue("@Id", entity.Id).Direction = ParameterDirection.Input;
                command.Parameters.Add("@DoesExist", SqlDbType.Bit).Direction = ParameterDirection.Output;
                int result = SqlHelper.ExecuteNonQuery(command);
                doesExist = (bool)(command.Parameters["@DoesExist"].Value);
                entity.Id = (int)(command.Parameters["@Id"].Value);
                if (result == 0 || doesExist)
                    return false;
                return true;
            catch (Exception)
                return false;
        public bool Update(Patient entity, int userId, ref bool doesExist)
            var command = new SqlCommand();
            try
                command.CommandText = "EditPatient";
                command.CommandType = CommandType.StoredProcedure;
                command.Parameters.AddWithValue("@PatientNumber", entity.PatientNumber).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@LastName", entity.LastName).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@FirstName", entity.FirstName).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@MiddleName", entity.MiddleName).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@AddressLine1", entity.AddressLine1).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@CityId", entity.CityId).Direction = ParameterDirection.Input;
                command.Parameters.AddWithValue("@ProvinceId", entity.ProvinceId).Direction = ParameterDirection.Input;
command.Parameters.AddWithValue("@Id", SqlDbType.Int).Direction = ParameterDirection.Output;
                command.Parameters.Add("@DoesExist", SqlDbType.Bit).Direction = ParameterDirection.Output;
doesExist = (bool)(command.Parameters["@DoesExist"].Value);
                int result = SqlHelper.ExecuteNonQuery(command);
                if (result == 0 || doesExist)
                    return false;
                return true;
            catch (Exception)
                return false;
Then a business logic
3. MetroApp.BusinessLogic = class libray for calling the methods from DataAccess
namespace MetroApp.BusinessLogic
    public class PatientMgr
        #region Fields
        private readonly PatientDb _db;
        #endregion
        #region Properties
        public Patient Entity { get; set; }
        public List<Patient> EntityList { get; set; }
        public PatientParams Parameters { get; set; }
        #endregion
        #region Constructors
        public PatientMgr()
            _db = new PatientDb();
            Entity = new Patient();
            EntityList = new List<Patient>();
            Parameters = new PatientParams();
        #endregion
        #region Methods
public Patient Retrieve(PatientParams parameters)
            return _db.Retrieve(parameters);
        public List<Patient> RetrieveMany(PatientParams parameters)
            return _db.RetrieveMany(parameters);
        public bool Insert(Patient entity, int userId, ref bool doesExist)
            return _db.Insert(entity, userId, ref doesExist);
        public bool Update(Patient entity, int userId, ref bool doesExist)
            return _db.Update(entity, userId, ref doesExist);
        #endregion
Then the last one, the WPF GUI
<UserControl x:Class="MetroDentProject.Pages.PatientDetailsPage"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:dims="clr-namespace:MetroAppProject.UserCons"
             mc:Ignorable="d" 
             d:DesignHeight="720" d:DesignWidth="1280">
    <Grid x:Name="MainGrid" >
        <Grid.RowDefinitions>
            <RowDefinition  Height="40"/>
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
            <RowDefinition  />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>
        <GroupBox Grid.Column="0" Grid.Row="1" Grid.RowSpan="7" x:Name="DetailsGroupBox" Header="Patient Details" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="Id: " Grid.Column="1" Grid.Row="0" Visibility="Collapsed"/>
                <TextBox x:Name="IdTextBox" Grid.Column="1" Grid.Row="1" Visibility="Collapsed"/>
                <TextBlock x:Name="PatientNumberTextBlock" Text="Patient Number: " Grid.Column="0" Grid.Row="0" />
                <TextBox x:Name="PatientNumberTextBox" Grid.Column="1" Grid.Row="0" IsReadOnly="True" IsReadOnlyCaretVisible="True"/>
                <TextBlock Text="Last Name: " Grid.Column="0" Grid.Row="1" />
                <TextBox x:Name="LastNameTextBox" Grid.Column="1" Grid.Row="1" />
                <TextBlock Text="First Name: " Grid.Column="0" Grid.Row="2" />
                <TextBox x:Name="FirstNameTextBox" Grid.Column="1" Grid.Row="2" />
                <TextBlock Text="Middle Name: " Grid.Column="0" Grid.Row="3" />
                <TextBox x:Name="MiddleNameTextBox" Grid.Column="1" Grid.Row="3" />
            </Grid>
        </GroupBox>
        <GroupBox x:Name="ContactDetailsGroupBox" Header="Contact Details" Grid.Column="1" Grid.Row="1" Grid.RowSpan="7">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <TextBlock Text="Address: " Grid.Column="0" Grid.Row="0" Grid.RowSpan="2" />
                <TextBlock Text="City: " Grid.Column="0" Grid.Row="2" />
                <TextBlock Text="Province: " Grid.Column="0" Grid.Row="3"/>
                <TextBox x:Name="AddressTextBox" Grid.Column="1" Grid.Row="0" Grid.RowSpan="2"
                         TextWrapping="Wrap"
                         AcceptsReturn="True"
                         VerticalScrollBarVisibility="Auto"
                         />
                <ComboBox x:Name="CitiesComboBox"  Grid.Column="1" Grid.Row="2"  />
                <ComboBox x:Name="ProvincesComboBox"  Grid.Column="1" Grid.Row="3" />
            </Grid>
        </GroupBox>
        <dims:FunctionButtonsControl x:Name="FunctionButtonsCon" Grid.Row="9" Grid.Column="0" Grid.ColumnSpan="2"
                                     ExecuteClick="FunctionButtonsCon_OnExecuteClick"
                                     UndoClick="FunctionButtonsCon_OnUndoClick"
                                     BackClick="FunctionButtonsCon_OnBackClick"
                                     DeleteClick="FunctionButtonsCon_OnDeleteClick"
                                     />
    </Grid>
</UserControl>
I apologize for the long post. As you can see, I don't use binding. Binding requires me to use INotifyPropertyChanged interface which I am not familiar. Can you at least make my project to implement the INotifypropertyChanged?
Here is my sample code for the WPF page:
public partial class PatientDetailsPage 
        readonly PatientMgr itemMgr = new PatientMgr();       
        public PatientParams CurrentPar = new PatientParams(); // for undoActionType _action = ActionType.Insert; // this is an enum from another project, ActionType.Insert, ActionType.Update
        public ActionType Action
            get { return _action; }
            set { _action = value; }
        public PatientDetailsPage()
            InitializeComponent();
            BindComboBoxes();
        #region Methods
        public void OnFragmentNavigation(FragmentNavigationEventArgs e)
        public void OnNavigatedFrom(NavigationEventArgs e)
        public void OnNavigatedTo(NavigationEventArgs e)
        {            Setup();
        public void OnNavigatingFrom(NavigatingCancelEventArgs e)
        public Patient GetPageEntity()
            Patient setEntity = new Patient();
            setEntity.Id = (long)IdTextBox.Text;
            setEntity.PatientNumber = PatientNumberTextBox.Text;
            setEntity.LastName = LastNameTextBox.Text;
            setEntity.FirstName = FirstNameTextBox.Text;
            setEntity.MiddleName = MiddleNameTextBox.Text;
            setEntity.AddressLine1 = AddressTextBox.Text;
            setEntity.CityId = (short)CitiesComboBox.SelectedValue);
            setEntity.ProvinceId = (short)ProvincesComboBox.SelectedValue;
            setEntity.StatusId = true;
            return setEntity;
        public void Setup()
            switch (Action)
                case ActionType.Insert:
                    Clearer(); //clears all textboxes and set all comboboxes to default
                    this.PatientNumberTextBlock.Visibility = Visibility.Collapsed;
                    this.PatientNumberTextBox.Visibility = Visibility.Collapsed;
                    FunctionButtonsCon.ExecuteButton.Content = "Add";
                    FunctionButtonsCon.DeleteButton.IsEnabled = false;
                    FunctionButtonsCon.DeleteButton.Visibility = Visibility.Hidden;
                    break;
                //**Setup Update
                case ActionType.Update:CurrentPar.Id = (long)IdTextBox.Text;
                    LoadSingle(CurrentPar);
                    this.PatientNumberTextBlock.Visibility = Visibility.Visible;
                    this.PatientNumberTextBox.Visibility = Visibility.Visible;
                    FunctionButtonsCon.ExecuteButton.Content = "Save";
                    FunctionButtonsCon.DeleteButton.IsEnabled = true;
                    FunctionButtonsCon.DeleteButton.Visibility = Visibility.Visible;
                    break;                
            LastNameTextBox.CaretIndex = LastNameTextBox.Text.Length;
            IsVisibleChanged += AutoFocus;
        public void LoadSingle(PatientParams parameters)
            var entity = itemMgr.Retrieve(parameters); //calls the BusinessLogic
            IdTextBox.Text = (entity.Id);
            PatientNumberTextBox.Text = (entity.PatientNumber);
            LastNameTextBox.Text = (entity.LastName);
            FirstNameTextBox.Text = (entity.FirstName);
            MiddleNameTextBox.Text = (entity.MiddleName);
            AddressTextBox.Text = (entity.AddressLine1);
            CitiesComboBox.SelectedValue = (short)entity.CityId;
            ProvincesComboBox.SelectedValue = (short)entity.ProvinceId;
        public void Save(ActionType action, int userId)
            itemMgr.Entity = GetPageEntity();
            bool doesExist = false;
            switch (action)
                case ActionType.Insert:
                    if (itemMgr.Insert((itemMgr.Entity), userId, ref doesExist))
                        System.Windows.Forms.MessageBox.Show("Successfully added a Patient!", "Patient Insertion");                  
                    else if (doesExist)
                        System.Windows.Forms.MessageBox.Show("Item already exists.", "Patient Insertion");
                    else
                        System.Windows.Forms.MessageBox.Show("Not all fields were filled in.", "Patient Insertion");
                    break;
                case ActionType.Update:
                    if (itemMgr.Update(itemMgr.Entity, userId, ref doesExist))
                        System.Windows.Forms.MessageBox.Show("Successfully updated a Patient!", "Patient Modification");
                        itemMgr.Parameters.Id = itemMgr.Entity.Id;
                        Action = ActionType.Update;
                        Setup();
                    else if (doesExist)
                        System.Windows.Forms.MessageBox.Show("Item already exists.", "Patient Modification");
                    else
                        System.Windows.Forms.MessageBox.Show("Not all fields were filled in.", "Patient Modification");
                    break;                
        public void Clearer()
            IdTextBox.Clear();
            PatientNumberTextBox.Clear();
            LastNameTextBox.Clear();
            FirstNameTextBox.Clear();
            MiddleNameTextBox.Clear();
            CitiesComboBox.SelectedIndex = 0;
            ProvincesComboBox.SelectedIndex = 0;
            AddressTextBox.Clear();            
        public void BindComboBoxes()
            CitiesComboBox.ItemsSource = new BindingSource(CommonMgr.GetCitiesDropDown(), null);// the CommonMgr is a static class from another project. It works just fine
            CitiesComboBox.DisplayMemberPath = "Value";
            CitiesComboBox.SelectedValuePath = "Key";           
            ProvincesComboBox.ItemsSource = new BindingSource(CommonMgr.GetProvincesDropDown(), null);
            ProvincesComboBox.DisplayMemberPath = "Value";
            ProvincesComboBox.SelectedValuePath = "Key";
            CitiesComboBox.SelectedIndex = 0;
            ProvincesComboBox.SelectedIndex = 0;
        #endregion
        #region Events
        private void FunctionButtonsCon_OnExecuteClick(object sender, RoutedEventArgs e)
            Save(Action, SessionHelper.MyUser.Id); //SessionHelper.MyUser.Id
        private void FunctionButtonsCon_OnUndoClick(object sender, RoutedEventArgs e)
            if (Action == ActionType.Insert)
                Clearer();
                return;
        private void FunctionButtonsCon_OnBackClick(object sender, RoutedEventArgs e)
            Exiter();
        private void FunctionButtonsCon_OnDeleteClick(object sender, RoutedEventArgs e)
            var ans = System.Windows.Forms.MessageBox.Show("Are you sure you want to delete this entry?", "Patient Deletion", MessageBoxButtons.YesNo);
            if (!Equals(ans, System.Windows.Forms.DialogResult.Yes)) return;
            Action = ActionType.Delete;
            Save(Action, SessionHelper.MyUser.Id);
            Exiter();
        #endregion

Hello Kokombads,
I thought you are using MVVM from your title but it seems your project is just a simple WPF project. In that way, please check the following msdn article to know how to Implement Property Change Notification
https://msdn.microsoft.com/en-us/library/ms743695(v=vs.110).aspx
using System.ComponentModel;
namespace SDKSample
// This class implements INotifyPropertyChanged
// to support one-way and two-way bindings
// (such that the UI element updates when the source
// has been changed dynamically)
public class Person : INotifyPropertyChanged
private string name;
// Declare the event
public event PropertyChangedEventHandler PropertyChanged;
public Person()
public Person(string value)
this.name = value;
public string PersonName
get { return name; }
set
name = value;
// Call OnPropertyChanged whenever the property is updated
OnPropertyChanged("PersonName");
// Create the OnPropertyChanged method to raise the event
protected void OnPropertyChanged(string name)
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
handler(this, new PropertyChangedEventArgs(name));
It is not so complex, you only need to refer to the interface from here:
https://msdn.microsoft.com/en-us/library/system.componentmodel.inotifypropertychanged(v=vs.110).aspx
And understand that you have to do the following:
For change notification to occur in a binding between a bound client and a data source, your bound type should either:
Implement the INotifyPropertyChanged interface (preferred).
Provide a change event for each property of the bound type
Best regards,
Barry
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How can we implement the currency translation in a query definition

    How can we implement the currency translation in a query definition and should it modified for each and every type of currencies

    hi rama krishna
    i think u can not get any translation in Query. this is only for het the report as it is there in tables. if u want to write a report take a help of the Abaper
    hope u goit,assign points if u ok for this
    thanks
    subbu

  • How can I implement the connection pool in my java stored procedure

    my java stored procedures (in database 'B') have to connect to another oracle database ,let's say 'A'. And how can I implement the behavior like the so-called connection pool in my java stored procedure in 'B', as below.
    1. database B, has 2 java stored procedures sp1 and sp2
    2. both sp1 and sp2 connects to databse 'A'
    whatever I call the sp1 and sp2 and the database 'A' always only one connected session from sp1 and sp2 in database 'B'.
    THANKS A LOTS...

    my problem is I have a lots of java stored procedures need to cnnect to the remote oracle db, and I hope the remote db can only have a connected session from my java stored procedures in my local db. I try as below
    class sp{
    static Connection conn=null; //the remote db connection,
    public static void sp1(){...}//procedure 1, using conn
    public static void sp2(){...}//procedure 2, using conn,too
    I can 'see' the 'conn' variable if I invoke the sp1() and sp2() from the same client application(maybe sqlplus). But if I invoke the sp1() from client 'A' and invoke sp2() from client 'B' then the sp1() and sp2() can not see the 'conn' variable for each other. I think it's because the two clients cause oracle to create two instances of the class 'sp' and the sp1() and sp2() located in different instance seperately. Thus the sp1() and sp2() can not see 'conn' for each other. They can only see its own 'conn'.
    To connect to the remote db from the java stored procedure is easy but is it possible to connect to the remote db via database link from the java stored procedure at my local db ? If so, then I also archive my goal .
    BTW , thanks a lots...
    andrew :-)

  • Hi how can i implement the scenario.......plz reply asap.........

    HI folks,
    i have a typical problem in bex .
    my scenario is:i am having 2 values say 'x','y'.
    i want to implement a formula like x-y.
    if the x value is negative then i have to get the result as negative after the 'y' value get subtracted.if 'x' is positive, i have to get positive value after subtracting 'y' value.
    please let me know how can i implement this scenario in bex.
    by using a formaula or condition or anything else. please let me know clearly including the expression asap.
    Best reagards,
    ashok.

    answered

  • How can I implement the security ports..?

    How can I use the security ports and SSL through javamail..?
    Can someone tell me what are the necessary things to b done while connecting to "Gmail" through Javamail??....like how to authenticate..etc??
    Edited by: shyamwdr on May 20, 2008 6:21 AM

    Did you read the FAQ?

  • How can i implement the default value for this variable?

    In one of our Stored procs,we have a variable RECS_TO_DELETE, which determines the number of records to delete from various DELETEs that happen within this proc.
    The value for RECS_TO_DELETE variable should be obtained from a configuration table sys_config
    select
    rec_num into RECS_TO_DELETE
    from sys_config
    where
    sys_code=55;
    But if something goes wrong with sys_config table or the above SELECT INTO, our client wants to makes sure that RECS_TO_DELETE should have a default value of 1000.
    In the code, how will i implement having this default value of 1000 for RECS_TO_DELETE variable  in case the above SELECT INTO fails for some reason.

    Hi,
    You have to assign a value before the execution...
    DECLARE
        RECS_TO_DELETE NUMBER(9) := 1000;
    BEGIN
        SELECT rec_num
        INTO   RECS_TO_DELETE
        FROM   sys_config
        WHERE  sys_code = 55;
        DBMS_OUTPUT.put_line(RECS_TO_DELETE);
    EXCEPTION
        WHEN NO_DATA_FOUND THEN
           DBMS_OUTPUT.put_line(RECS_TO_DELETE);
    END;
    /Regards,

  • How can I implement the equivilent of a temporary table with "on commit delete rows"?

    hi,
    I have triggers on several tables. During a transaction, I need to gather information from all of them, and once one of the triggers has all the information, it creates some data. I Can't rely on the order of the triggers.
    In Oracle and DB2, I'm using temporary tables with "ON COMMIT DELETE ROWS" to gather the information - They fit perfectly to the situation since I don't want any information to be passed between different transactions.
    In SQL Server, there are local temporary tables and global.  Local temp tables don't work for me since apparently they get deleted at the end of the trigger. Global tables keep the data between transactions.
    I could use global tables and add some field that identifies the transaction, and in each access to these tables join by this field, but didn't find how to get some unique identifier for the transaction. @@SPID is the session, and sys.dm_tran_current_transaction
    is not accessible by the user I'm supposed to work with.
    Also with global tables, I can't just wipe data when "operation is done" since at the triggers level I cannot identify when the operation was done, transaction was committed and no other triggers are expected to fire.
    Any idea which construct I could use to acheive the above - passing information between different triggers in the same transaction, while keeping the data visible to the current transaction?
    (I saw similar questions but didn't see an adequate answer, sorry if posting something that was already asked).
    Thanks!

    This is the scenario: If changes (CRUD) happen to both TableA and TableB, then log some info to TableC. Logic looks something like this:
    Create Trigger TableA_C After Insert on TableA {
      If info in temp tables available from TableB
            Write info to TableC
       else
           Write to temp tables info from TableA
    Create Trigger TableB_C After Insert on TableB {
      If info in temp tables available from TableA
            Write info to TableC
       else
           Write to temp tables info from TableB
    So each trigger needs info from the other table, and once everything is available, info to TableC is written. Info is only from the current transaction.
    Order of the triggers is not defined. Also there's no gurantee that both triggers would fire - changes can happen only to TableA / B and in that case I don't want to write anything to TableC.
    The part that gets and sets info to temp table is implemented as temp tables with "on commit delete rows" in DB2 / Oracle.
    What do you think? As I've mentioned, I could use global temp tables with a field that would identify the transaction, but didn't find something like that in SQL Server. And, the lifespan of local temp tables is too short.

  • How can i implement the event-dependent sequential operation of devices?

    I am trying to develop a code to automate the valve operations of a gas plumbing system. for example, i would like to select "leak test" from an enumerated list and then have the system open some valves (digital output), wait for user confirmation, open more valves, activate compressor, wait for certain pressure (analog input), close certain valves, continue compressing untill certain pressure, stop compressing, wait 60 minutes while logging pressure readings. That is basically what i'm trying to implement. i am stuck on how to carry this out. i already have somewhat of a state machine built, my trouble is with the structure of how to build the sequence. I know this is probably vague, i'll answer any questions anyone has. Thank you very much.
    Brian

    Take a look at a Queued State Machine.  Here you build a list of the order of steps to take.  It could either an array where at the end of each step, it picks off the next item on the array.  Or it could actually be a queue.   The next state to operate gets picked off the queue.  You would preload the queue with all of your desired steps.  On each iteration, it would dequeue the next state to do.  In the cases where you need to repeat a step (such as continually doing a step until a condition as been met) you would re-enqueue the same step at the front of the queue.

  • How can i implement the communication between processes?

    the processes must run in the machine which has small
    memory,no harddisk and tcp/ip protocol.

    pipes and or shared memory, much faster than using
    sockets IMO.In JAVA??????
    You do not know what you are talking about please return to "Kindergarder Languages Topics" and
    don't confuse others.

  • How can I implement the function atof in TestStand?

    Hi,
    I would like to convert a string to a number.....same as   num = atof(aString);
    How do you do it with TS functions?
    Thanks

    Rafi,
    There is an expression function used to convert strings to numbers.
    Val( string, <isValid> )
    ->Converts a string to number.
    Hope it helps.
    Antonio Lie.
    Message Edited by Antonio Lie (NI) on 10-04-2006 11:19 AM

  • How can I know the length of an array in the class?

    hard to express, I show guys an example:)
    public class code{
    pblic String[] str; // String array
    public test () {
    // I hope to print all items in the array after initiation;
    // e.g. if String[3] , then print str0, str1,str2; if String[4], then //print str0, str1, str2, str3;
    My puzzle here is, since the "str" may be not the same length in different initiation of code object, how can I implement the test method to print all items

    for (int i = 0; i < str.length; i++)
      System.out.println(str);

  • How can i implement 'Distribute Qty' function in BAPI_GOODSMVT_CREATE

    Hi all,
    Using MIGO For GR. if more than one Batch or Production Date or Vendor Batch for same Purchase Order Line Item and Deliv date, need to hit ‘Distribute Qty’ button to split the entry line into multiple lines before enter Production Date and Vendor Batch.
    So I want use bapi BAPI_GOODSMVT_CREATE  implement MIGO function for a interface. Anyone have some suggestion how can i implement the 'Distribute Qty' function in the bapi.
    My email address: [email protected]

    Hello,
    1. Use structure BAPIPAREX for passing custom fields. (There are several blogs/posts on how to make use of this).
    2. In the BAPI i noticed there is a BAdI to populate these fields into your business tables.
    Call BAdI MB_BAPI_GOODSMVT_CREATE to fill own fields
        TRY.
            get badi lo_mb_bapi_GOODSMVT_CREATE.
          CATCH cx_badi_not_implemented.                    "#EC NO_HANDLER
        ENDTRY.
        TRY.
            call badi lo_mb_bapi_goodsmvt_create->extensionin_to_matdoc
              EXPORTING
                EXTENSION_IN = EXTENSIONIN[]
              CHANGING
                CS_IMKPF     = S_IMKPF
                CT_IMSEG     = T_IMSEG[]
                CT_RETURN    = return.
          CATCH cx_badi_initial_reference.                  "#EC NO_HANDLER
        ENDTRY.

  • How can I implement IMAQ correlation for 16bit image?

    Hi
    When using IMAQ correlate. vi in Machine vision Filter catergory, the vi only works for 8 bit source and template image case.
    16 bit source image case makes error.
    But I need 16 bit source image without losing image information, I want to use full 16 bit image correlation with 8 bit template.
    How can I implement the code in labview?
    Need help.
    Many thanks.

    Unfortunately you can't do so.
    There are some functions in the Vision Lib that only accept 8bit images. In order to use them you have to convert your image to an 8bit Image.
    Keep in mind that converting an Image to 8bit will not necessary result in a loss of data. Check your Images, it might be that you are not using the full range of a 16bit value. you might be able to use a mixture of dynamic shifting and bit shifting in order to convert an image to an 8 bit, then embedding these criterias in the image and use them to convert back to a 16bit at a later time without losing any data, or in most cases minimal precision loss. 
    If you would like to attach one of the images you are using, I can take a look at it to see if this is possible in your case.
    Good luck,
    Dan,
    www.movimed.com - Custom Imaging Solutions

  • Re:How can we save the values in drafts

    Hi all,
    I am using jdev 11.1.2.3.0
    My requirement is I have one table as jobsheet.In jobsheet table some fields are mandatory.In this jspx page I have 2 buttons as save and draft.if i entered some data without entering mandatory fields and click the draft button it will saved in draft.if i modified the draft data and then clicks save it will save into the database.so how can i implement the logic.can anyone help me please.
    Thanks,
    G.Shilpa

    This is not that easy.
    First you have to think about where to save the data when the user clicks on draft. Then you have to think about how the data is saved. Finally you have to find out how to get to the data.
    If you have constraints on your DB (which I recommend), that you can't store the data in the table you later want to store the real data as the constraints will not allow this. As we are talking about a multi user environment you have to store multiple sets of data which you need to assign the user who stores the data.
    You can add another table to the db which look the same as the real one but does not have constraints like mandatory applied to it. When the user hits draft you store the data in this table. For the UI you then have to look into the too tables to find out if the user has saved a draft and read it from there if yes.
    Timo

  • How can I modify the item's in stock quantity via DI?

    I have a form which needs to adjust item’s in stock quantity (OITW.OnHand).  I tried using StockTaking object, but it only changed the Counted quantity (OITW.Counted).  I had to access the SBO client menu ‘Initial Quantities, Inventory Tracking and Stock Posting’ to reconcile the inventory.  How can I implement the same function through DI?
    Thanks,

    dont know about the stock taking object but may be the grpo object would help
    HTH
    Message was edited by:
            Manu Ashok

Maybe you are looking for

  • "Word was unable to open the data source" error message in mail merge

    I am trying to do a mail merge in Word 2008 for Mac and receive this message when I try to open the Excel file for the data.  Can someone please help?  I tried changing the filename to .xls (originally .xlsx) but it didn't work.

  • Macbook Pro sound problem... sometimes....

    My girlfriend has a MBP with a Bootcamp installation with windows XP on it for "windows only" programs. Macbook Pro 15" 2.4Ghz 2GB ram 2 partition hard drive (OSX and XP) Windows XP SP2 However, occasionally we have been having problems regarding sou

  • Blank postscript file

    Hi! We had Oracle Reports 6.0.28.x working on a NT webserver creating postscript files (conv. into pdf files via Adobe Distiller). Then we needed to produce UTF8 unicode files, so a bug made us switch to Oracle Reports 6.0.35.x and the bug disappeare

  • Automating labview tera term x modem transfers?

    Is it possible to automate tera term x modem transfers?  I am doing a serial upgrade and need to figure a way to automate things.  I am currently using tera term for the x modem tansfer but am open to any other suggestions.

  • Logical to Relational mapping

    Is it possible to define mapping between Logical and Relational objects (Entity->Table, Attribute->Column) manually?