Do not use on any
shared computer
August 30, 2008 02:17am pdt
 
[x]
Attachment Details

what is good way to insert into 3 tables with one query?

Tags: .NET 2.0 C#, postgresql
i'm importing values from excel to postgres database,
one line in my excel file has to be entered into three tables.
- the infos will be split up in order to insert into three tables -

my persistance layer, receives an arrayList with objets containing the infos.

what would be a good maner to enter all the infos with the same query?
having in mind that if one of the tables is not inserted the others shouldn't be.
if there's an insertion the insert must be complete.

should i pass all the values to a postgres function in order to create an atomic insert?
or can i do it with .NET 2.0 in c#?

an example of how to do this would be welcome.



1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
after recovering the values and creating the objects with a factory, 
here's where my question starts:
  
        public bool InsertContainersToCommunity(ArrayList alContainersObjects)
        {
            try
            {
                foreach (Molok container in alContainersObjects)
                {
                 .............................
                }
            }catch(Exception ex)
            {
                return false;
            }
 
            return true;
        }
Start your free trial to view this solution
Question Stats
Zone: Database
Question Asked By: toshi_
Question Asked On: 07.11.2008
Participating Experts: 1
Points: 500
Views: 0
Translate:
Loading Advertisement...
 
[+][-]Expert Comment by dknoodle
Expert Comment by dknoodle:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by toshi_
Author Comment by toshi_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
[+][-]Author Comment by toshi_
Author Comment by toshi_:

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080723-EE-VQP-34 / EE_QW_2_20070628