Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2007
    Posts
    7

    Question Unanswered: ORA-00934: group function is not allowed here

    Im trying to insert data into a table. One of the fields (pac_n) is a number and i want to insert a line after the Max Value. However i am getting the error:

    ORA-00934: group function is not allowed here

    The error is at the MAX(pac_n) +1 section

    My isert is below. Any Ideas?

    Code:
    insert into usr_clear_setup & #40;pac_n,pac_acc,pac_mar_ref,pac_ctr_ref,pac_call,pac_broker,pac_msg,pac_acc_de
    scr,pac_acc_type,pac_open,pac_out_broker,pac_out_msg,pac_exec_fee,pac_job_in,pac
    _clear_broker,pac_clear_fee,pac_back_transco,pac_transco_market,pac_devise,pac_u
    sername) values(MAX(pac_n) +1,'ABC','DTB','*','*',' ',' ','DDRAX','A','A','FMLLO','0S821','','','','','DDRAX','DDRAX','','');

  2. #2
    Join Date
    Jul 2007
    Posts
    7
    Solved the problem. Changed (MAX(pac_n) +1 to ((select MAX(pac_n) from usr_clear_setup) +1

  3. #3
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    you are selecting the max of a column value so that you can add 1 and insert into the same table

    this can lead to race conditions if you aren't careful to isolate this query from all other concurrent queries

    can you explain why you are not using a sequence for this purpose?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •