Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
Facebook
Downloads
Home
>
mailing lists
Question on Multi-Table Inserts - Mailing list psycopg
From
Don Parris
Subject
Question on Multi-Table Inserts
Date
April 16, 2013
09:59:14
Msg-id
CAJ-7yokqa4Aynm85LRDR1yofU-yFXLLqYJvk8Dp57RNxz97hpQ@mail.gmail.com
Whole thread
Raw
Responses
Re: Question on Multi-Table Inserts
Re: Question on Multi-Table Inserts
List
psycopg
Tree view
Hi all,
This is more of a strategic question. If I want to enter a particular financial transaction in my DB, I need to use the following process:
Insert a new or select an existing payee
Insert a new transaction record (using the payee_id from the payee table)
Insert at least one, but usually more line items (using the transrec_id from the transrec table)
Insert a new or select an existing category for the transaction line item (using the cat_id) from the category table.
Is it as simple as running a series of insert statements in succession, passing on the PK of the first table to the next table in the process? I.e.,
BEGIN
INSERT into table payee(values...)
INSERT into table transrec(values...) # pass in payee_id variable
SELECT *from category (to get cat_id)
INSERT into table transdetails(values...) #pass in transrec_id and cat_id variables
COMMIT
Or is it more complicated than that?
Thanks!
Don
--
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
http://dcparris.net/
GPG Key ID: F5E179BE
psycopg
by date:
Previous
From:
David Gilman
Date:
11 April 2013, 20:52:38
Subject:
Building psycopg2 under cygwin
Next
From:
Joe Abbate
Date:
16 April 2013, 11:02:33
Subject:
Re: Question on Multi-Table Inserts
Есть вопросы? Напишите нам!
Соглашаюсь с условиями обработки персональных данных
I confirm that I have read and accepted PostgresPro’s
Privacy Policy
.
I agree to get Postgres Pro discount offers and other marketing communications.
✖
×
×
Everywhere
Documentation
Mailing list
List:
all lists
pgsql-general
pgsql-hackers
buildfarm-members
pgadmin-hackers
pgadmin-support
pgsql-admin
pgsql-advocacy
pgsql-announce
pgsql-benchmarks
pgsql-bugs
pgsql-chat
pgsql-cluster-hackers
pgsql-committers
pgsql-cygwin
pgsql-docs
pgsql-hackers-pitr
pgsql-hackers-win32
pgsql-interfaces
pgsql-jdbc
pgsql-jobs
pgsql-novice
pgsql-odbc
pgsql-patches
pgsql-performance
pgsql-php
pgsql-pkg-debian
pgsql-pkg-yum
pgsql-ports
pgsql-rrreviewers
pgsql-ru-general
pgsql-sql
pgsql-students
pgsql-testers
pgsql-translators
pgsql-www
psycopg
Period
anytime
within last day
within last week
within last month
within last 6 months
within last year
Sort by
date
reverse date
rank
Services
24×7×365 Technical Support
Migration to PostgreSQL
High Availability Deployment
Database Audit
Remote DBA for PostgreSQL
Products
Postgres Pro Enterprise
Postgres Pro Standard
Cloud Solutions
Postgres Extensions
Resources
Blog
Documentation
Webinars
Videos
Presentations
Community
Events
Training Courses
Books
Demo Database
Mailing List Archives
About
Leadership team
Partners
Customers
In the News
Press Releases
Press Info
By continuing to browse this website, you agree to the use of cookies. Go to
Privacy Policy
.
I accept cookies