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 50799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:38:59+00:00 2026-05-10T16:38:59+00:00

I have a number of code value tables that contain a code and a

  • 0

I have a number of code value tables that contain a code and a description with a Long id.

I now want to create an entry for an Account Type that references a number of codes, so I have something like this:

insert into account_type_standard (account_type_Standard_id, tax_status_id, recipient_id) ( select account_type_standard_seq.nextval, ts.tax_status_id, r.recipient_id from tax_status ts, recipient r where ts.tax_status_code = ? and r.recipient_code = ?) 

This retrieves the appropriate values from the tax_status and recipient tables if a match is found for their respective codes. Unfortunately, recipient_code is nullable, and therefore the ? substitution value could be null. Of course, the implicit join doesn’t return a row, so a row doesn’t get inserted into my table.

I’ve tried using NVL on the ? and on the r.recipient_id.

I’ve tried to force an outer join on the r.recipient_code = ? by adding (+), but it’s not an explicit join, so Oracle still didn’t add another row.

Anyone know of a way of doing this?

I can obviously modify the statement so that I do the lookup of the recipient_id externally, and have a ? instead of r.recipient_id, and don’t select from the recipient table at all, but I’d prefer to do all this in 1 SQL statement.

  • 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. 2026-05-10T16:39:00+00:00Added an answer on May 10, 2026 at 4:39 pm

    Outter joins don’t work ‘as expected’ in that case because you have explicitly told Oracle you only want data if that criteria on that table matches. In that scenario, the outter join is rendered useless.

    A work-around

    INSERT INTO account_type_standard    (account_type_Standard_id, tax_status_id, recipient_id)  VALUES(    (SELECT account_type_standard_seq.nextval FROM DUAL),   (SELECT tax_status_id FROM tax_status WHERE tax_status_code = ?),    (SELECT recipient_id FROM recipient WHERE recipient_code = ?) ) 

    [Edit] If you expect multiple rows from a sub-select, you can add ROWNUM=1 to each where clause OR use an aggregate such as MAX or MIN. This of course may not be the best solution for all cases.

    [Edit] Per comment,

      (SELECT account_type_standard_seq.nextval FROM DUAL), 

    can be just

      account_type_standard_seq.nextval, 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 68k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I finally came up with a routine for replacing these… May 11, 2026 at 12:05 pm
  • added an answer The most simple way would be to just use a… May 11, 2026 at 12:05 pm
  • added an answer The biggest problem I see is the obvious fact that… May 11, 2026 at 12:05 pm

Related Questions

I have a number of code value tables that contain a code and a
I have a fair number of Python scripts that contain reusable code that are
While refactoring some old code I have stripped out a number of public methods
I've seen a number of 'code metrics' related questions on SO lately, and have
I have a number of macros written for Visual Studio 2005, but they have
I have a number of tracks recorded by a GPS, which more formally can
I have a number of application settings (in user scope) for my custom grid
i have a number of jsp files under web-inf folder. Inside my web.xml i
I have a number of data classes representing various entities. Which is better: writing
I have a number of tables that use the trigger/sequence column to simulate auto_increment

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.