title: Data insertion into multiple tables with one query using postgres
body: <p>I want to insert data into multiple related tables in one go - in a single transaction. I am using Postgres and Dapper ORM. Here is my query:</p>
  <pre><code>WITH userins AS (
      INSERT INTO public.&quot;user&quot;
  (
      &quot;FirstName&quot;, 
      &quot;LastName&quot;, 
      &quot;Email&quot;, 
      &quot;PasswordHash&quot;, 
      &quot;Address&quot;, 
      &quot;City&quot;, 
      &quot;State&quot;, 
      &quot;Zip&quot;, 
      &quot;Phone&quot;, 
      &quot;IsEnabled&quot;, 
      &quot;IsVerified&quot;, 
      &quot;IsDeleted&quot;,  
      &quot;CreatedDate&quot;, 
  )
      VALUES (@FirstName, @LastName, @Email, @PasswordHash, @Address, @City, @State, @Zip, @Phone, @IsEnabled, ?IsVerified, ?IsDeleted, @CreatedDate);
      RETURNING id AS user_id
     )
  , clientins AS (
      INSERT INTO public.client( &quot;Description&quot;, &quot;PlanCustomerId&quot;, &quot;IsActive&quot;, &quot;IsDeleted&quot;, &quot;CreatedBy&quot;, &quot;CreatedDate&quot;, userid)
                             VALUES(@Description, @PlanCustomerId, @IsActive,@IsDeleted, user_id, @CreatedDate,user_id) RETURNING id as client_id;
     )
     , clientsubins
     (
      INSERT INTO public.client_subscription(
      &quot;PlanId&quot;, 
      &quot;IsActive&quot;,
      &quot;StartDate&quot;, 
      &quot;EndDate&quot;, 
      &quot;IsDeleted&quot;, 
      &quot;CreatedBy&quot;, 
      &quot;CreatedDate&quot;, 
      clientid, 
      subscriptionid)
      VALUES (@PlanId, @IsActive, @StartDate, @EndDate, @IsDeleted, user_id, @CreatedDate, client_id, @subscriptionid);
     )
     RETURNING client_id
  </code></pre>
  <p>Will this query work or what I need to change?</p>