sbl
sbl

Reputation: 39

PL\SQL - Fetch values from table and Item - Oracle Apex

I need to insert data of one table to another table. All the values are from the table except one SO_ID. It is coming from the Item on the page. How do I do it?

insert into T_SORDER_ITEM_INWARD
(
      select sd.ID, SO_ID 
        into :P25_SO_ID, sd.STOCK_ID,sd.ITEM_ID,sd.UOM_ID,
             sd.ITEM_CONDITION_ID,sd.ORIGINAL,sd.ACTUAL,sd.WIDTH,sd.LENGTH,sd.STOCKQTY,
             sd.KANTA,sd.RATE,sd.PACKET, sd.LABEL_METER, sd.EXCESS_SHORT,sd.LOCATION_ID,
             sd.CLIENT_INITIAL, sd.FIN_YEAR, sd.SERIAL_NO
        from T_STOCK_DETAIL sd join t_stock_master sm
        on sd.stock_id = sm.stock_id 
    where sm.customer_id = p25_customer
)

Upvotes: 0

Views: 723

Answers (1)

Littlefoot
Littlefoot

Reputation: 143103

A simplified example:

insert into another_table (id, name, location) 
  select :P25_SO_ID,
         t.name,
         t.location
  from this_table t

Always name all columns you're inserting into (first line in my example).

Your query is impossible to understand. Not just because syntax is wrong, but because we have no idea which column is supposed to get which value.

Upvotes: 4

Related Questions