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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:20:55+00:00 2026-05-31T20:20:55+00:00

I run this command : select * from LIST where JCODE = 8 and

  • 0

I run this command :

select * from LIST where JCODE = 8 and
KCODE = 01 and LCODE = 2011

and if the above retruns no rows then perform the below :

insert into LIST
select * from LIST@LNDB where JCODE = 8 and
KCODE = 01 and LCODE = 2011 and ban
in (select BAN from billing_account)

Update LIST set STS = null where JCODE = 8
AND KCODE = 01;

Update LIST set NO = '1' where JCODE = 8 AND
KCODE = 01;

moreover can i use some variable in the begininng which
sets

JCODE= somevalue
KCODE= anothervalue
LCODE=someothervalue

so that i dont have to edit every line every time i run it.
I am using :

Oracle 9i Enterprise Edition release 9.2.8.0 - 64 bit Production
  • 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-31T20:20:56+00:00Added an answer on May 31, 2026 at 8:20 pm

    I can’t tell for the SELECT, but you should be allowed to UPDATE several fields at once:

    UPDATE LIST set STS = null , NO = '1' WHERE JCODE = 8 AND KCODE = 01;
    

    Edit: I don’t understand why you need the second SELECT (with LIST@LNDB), but in both queries I don’t think you really need all the fields, so instead of using SELECT *, which is heavy for the system, use only and explicitly the primary key’s field name (like SELECT id FROM ...).

    And there is a way to do it in one request, probably something like:

    UPDATE LIST set STS = null , NO = '1' WHERE JCODE = 8 AND KCODE = 01 AND 0<(SELECT COUNT(*) FROM LIST WHERE JCODE = 8 AND KCODE = 01 AND LCODE = 2011);
    

    This way, if there is no result found by SELECT, the WHERE clause in UPDATE will be false for every row, as 0<0 is false. There may also be a way to use COUNT() with a named field instead of *, I don’t know Oracle enough for that.

    Re-edit: indeed, if your second SELECT is actually an INSERT, you probably need that * 🙂 But I don’t think you can apply the same trick on the INSERT as the one on the UPDATE…

    Re-re-edit: to write better what I put in the comment – taken from http://www.oradev.com/oracle_insert.jsp – your one and only request could be:

    INSERT 
    WHEN (0=(SELECT COUNT(id) FROM LIST WHERE JCODE=8 AND KCODE=01 AND LCODE=2011)) 
    INTO LIST (field1, field2, field3, STS, field4, field5, NO, field6) 
    SELECT field1, field2, field3, null, field4, field5, 1, field6 
        FROM LIST@LNDB 
        WHERE JCODE=8 AND KCODE=01 AND LCODE=2011 
        AND ban IN (SELECT BAN FROM billing_account)
    

    Naturally you can add the GuZzie touch, use DECLARE, BEGIN and END to make the writing of parameters easier 😉

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

Sidebar

Related Questions

When I run this command in MySQL: SELECT * FROM v WHERE v.firstname LIKE
I want to do this: run a command capture the output select a line
I'm trying to run this command through KennethReitz's Envoy package: $ sqlite3 foo.db 'select
How do I run this command with subprocess? I tried: proc = subprocess.Popen( '''ECHO
I can run this command in SqlManager to detach the db ALTER DATABASE mydb
how to insert inner array in mongodb using php I run this command in
How can I run this on linux command line when my username has an
I am trying to run this dreadfully simple command in Bash java -cp nasa-top-secret.jar
I want to run this as a batch rather than through the command line:
I want to run weka through the command line. I type in this command:

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.