Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6870971
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:44:55+00:00 2026-05-27T03:44:55+00:00

Classic issue, new framework — thus problem. PostgreSQL + Scala + ScalaQuery. I have

  • 0

Classic issue, new framework — thus problem.

PostgreSQL + Scala + ScalaQuery. I have Master table with serial (autincrement) id and Slave table also with serial id.

I need to insert one master record and several slaves. I have to do it within transaction (to have ability to cancel all), so I cannot run a query after inserting master to find out id. As far as I see SQ “insert” method does not return any reference to inserted master record.

So how to do it?

SQ Examples cover this however without autoincremented field, so such solution (pre-set ids) is not applicable here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T03:44:56+00:00Added an answer on May 27, 2026 at 3:44 am

    If I understand it correctly this is not possible for now in automatic way. If one is not afraid, this can be done this way. Obtaining the id of last insert (per each master record insertion):

    postgreSQL function for last inserted ID

    Then using it in SQ:

    http://groups.google.com/group/scalaquery/browse_thread/thread/faa7d3e5842da82e

    This code shows the MySql way. I’m posting it to the list for
    posterity’s sake.

    val scopeIdentity = SimpleFunction.nullaryLong

    val inserted = Actions.insert(
    “cat”, “eats”, “dog)

    //Print out the count of inserted records. println(inserted )

    //Print out the primary key for the last inserted record.
    println(Query(scopeIdentity).first)

    //Regards //Bryan

    But since for auto incremented fields you have to use projections excluding autoinc fields, and then inserting tuples instead of named record types, there is a question if it is not worth to hold breath until SQ will support this directly.

    Note I am SQ newbie, I might just misinform you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Classic producer-consumer-problem. I have x app servers which write records in a DB table
I have the classic 'get all rows in one table with number of corresponding
I have hit a classic problem of needing to do a string replace on
I'm having an issue with Entity Framework where I have something similar to the
Is there an issue with IIS or ASP Classic where Request.ServerVariables(QUERY_STRING) returns blank if
I am having an issue related to executing a .Net dll from a classic
The classic problem of testing and setting individual bits in an integer in C
I am migrating a classic ASP web app to new servers. The database back
ASP.NET 4.0 Need some help with this vexing HTTP POST problem - I have
I have recently purchased some new windows server 2008 boxes all running IIS7. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.