sql - Select insert with sequence and distinct -


i'm trying perform select insert need use sequence , distinct clause.

i know can't use sequences distinct so, i've nested subquery inside from, this:

insert  schemaname.xxson_st_b2b_ctr_pricing (seq_no,seeb_key,message_id,message_type,create_dtime,change_dtime,status)    select           xxson.xxson_b2b_ctr_pricing_seq.nextval   seq_no,          'sess_no'          seeb_key,           srp.item          message_id,          'message_type'     message_type,           sysdate           create_dtime,           sysdate           change_dtime,           'i'               status          (select distinct srp.item        schemaname.nb_pricelist_ctrl pctrl,             schemaname.nb_pricelist_srp srp       status = 'w'       , source_table = 'nb_pricelist_srp'); 

however, this, can't insert srp.item message_id because have invalid identifer (ora-00904), no surprise here. there workaround can insert properly?

to rid of ora-00904: invalid identifier srp.item have assign alias derived table serves normal table stored in memory. alias in from clause assigned inside block not visible outside.

insert  schemaname.xxson_st_b2b_ctr_pricing     (seq_no,seeb_key,message_id,message_type,create_dtime,change_dtime,status)         select                 xxson.xxson_b2b_ctr_pricing_seq.nextval   seq_no,                 'sess_no'          seeb_key,                 alias.item          message_id,                 'message_type'     message_type,                 sysdate           create_dtime,                 sysdate           change_dtime,                 'i'               status                  (select distinct srp.item              schemaname.nb_pricelist_ctrl pctrl,                     schemaname.nb_pricelist_srp srp             status = 'w'             , source_table = 'nb_pricelist_srp') alias; 

Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -