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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:06:04+00:00 2026-05-25T00:06:04+00:00

Table before solve: ID NAME DATA 1 zhang 9 1 zhang 12 2 wang

  • 0

Table before solve:

       ID NAME             DATA


     1 zhang               9
     1 zhang              12
     2 wang                1
     2 wang                2

/this is the table before solved/

Table after solve:

    ID NAME             DATA

     1 DIY                13
     2 DIY                 3

/this is what I want to get result/
There is the procedure:

update A a 
set a.date=(select  max(f_get(f.id,f.date,g.date))
           from A f,A g 
            where f.date!=g.date 
            and f.id=a.id);


--function f_get()
create or replace function f_get
      (id in varchar2,date in varchar,date2 in varchar ) 
    return varchar is
  Result varchar     
      date3 varchar(4);

begin

      select nvl(date,date2) into date3 
      from dual;

      Result:=date3;

    delete  from A a 
    where a.ID=id  
    and a.date=date2;--there is error 

  return(Result);
end  f_get;
  • 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-25T00:06:05+00:00Added an answer on May 25, 2026 at 12:06 am

    Your question does its best to hide itself, but this is the point:

    “–there is error “

    The error you get is (presumably) ORA-14551: cannot perform a DML operation inside a query, which you are getting because you are calling a FUNCTION which includes a DELETE command from a SELECT statement.

    Oracle’s transactional model doesn’t allow queries to change the state of the database. Instead of a FUNCTION you need to write a procedure.

    Although, if you want to remove duplicate rows, a straight SQL solution will suffice. Something like

    delete from a
    where (id, date) not in 
        ( select id, max(date) from a
          group by id)
    / 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do encode the data before saving it to a database table
I wish to DELETE the data from a table before performing an INSERT INTO,
Before anyone suggests scrapping the table tags altogether, I'm just modifying this part of
Probably it has been asked before but I cannot find an answer. Table Data
I have a user-defined table type. I want to check it's existence before editing
Table: UserId, Value, Date. I want to get the UserId, Value for the max(Date)
I created a table Place in mysql. In this table there are three fields.
I want to drop a table in my SQLite Database file named database.db. After
I saw this topic before here, but it didnt solve my problem. I have
I know that I should have schema of a table before calling NewRow method

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.