Inserting record in table on selection of another table

Hi All,
I have a table with multiple line items, and i have one insert button.
If i select line items in first table i want to create new records in 2nd table that is new structure( some values are same ).
Here problem is i am getting all records in second table eventhough i select only one? check this code and help...
here code i am using..in insert button.
  DATA lo_nd_it_lips TYPE REF TO if_wd_context_node.
  DATA lo_el_it_lips TYPE REF TO if_wd_context_element.
  DATA ls_it_lips TYPE wd_this->Element_it_lips.
  DATA lt_it_lips TYPE wd_this->Elements_it_lips.
  navigate from <CONTEXT> to <IT_LIPS> via lead selection
  lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).
  get element via lead selection
  lo_el_it_lips = lo_nd_it_lips->get_element( ).
  get all declared attributes
  lo_nd_it_lips->get_static_attributes_table( importing table = lt_it_lips ).
  DATA lo_nd_pack_mat TYPE REF TO if_wd_context_node.
  DATA lo_el_pack_mat TYPE REF TO if_wd_context_element.
  DATA ls_pack_mat TYPE wd_this->Element_pack_mat.
navigate from <CONTEXT> to <PACK_MAT> via lead selection
  lo_nd_pack_mat = wd_context->get_child_node( name = wd_this->wdctx_pack_mat ).
loop at lt_it_lips into ls_it_lips.
    ls_pack_mat-PACK_MATERIAL = 'PACKING1'.
    ls_pack_mat-packing_qty = ls_it_lips-PICK_QTY.
    ls_pack_mat-material = ls_it_lips-matnr.
    ls_pack_mat-plant = ls_it_lips-werks.
    append ls_pack_mat to lt_pack_mat.
endloop.
  lo_nd_pack_mat->bind_table( LT_PACK_MAT ).
Thanks,
venkat.

Hi
Try with tis code..
  DATA lo_nd_it_lips TYPE REF TO if_wd_context_node.
  DATA lo_el_it_lips TYPE REF TO if_wd_context_element.
  DATA ls_it_lips TYPE wd_this->Element_it_lips.
  DATA lt_it_lips TYPE wd_this->Elements_it_lips.
  DATA: wa_temp TYPE REF TO if_wd_context_element,
        lt_temp TYPE wdr_context_element_set.
  navigate from <CONTEXT> to <IT_LIPS> via lead selection
  lo_nd_it_lips = wd_context->path_get_node( path = `ZRETURN_DEL_CHANGE.CHANGING_3.IT_LIPS` ).
CALL METHOD lo_nd_it_lips->get_selected_elements
RECEIVING
set = lt_temp.
  DATA lo_nd_pack_mat TYPE REF TO if_wd_context_node.
  DATA lo_el_pack_mat TYPE REF TO if_wd_context_element.
  DATA ls_pack_mat TYPE wd_this->Element_pack_mat.
  DATA lt_pack_mat TYPE wd_this->Elements_pack_mat.
get element via lead selection
lo_el_pack_mat = lo_nd_pack_mat->get_element( ).
navigate from <CONTEXT> to <PACK_MAT> via lead selection
  lo_nd_pack_mat = wd_context->get_child_node( name = wd_this->wdctx_pack_mat ).
LOOP AT lt_temp INTO wa_temp.
CALL METHOD wa_temp->get_static_attributes
IMPORTING
static_attributes = ls_it_lips.
    ls_pack_mat-PACK_MATERIAL = 'PACKING1'.
    ls_pack_mat-packing_qty = ls_it_lips-PICK_QTY.
    ls_pack_mat-material = ls_it_lips-matnr.
    ls_pack_mat-plant = ls_it_lips-werks.
    append ls_pack_mat to lt_pack_mat.
CLEAR ls_pack_mat.
ENDLOOP.
  lo_nd_pack_mat->bind_table( new_items = LT_PACK_MAT ).
Cheers,
Kris.

Similar Messages

  • Unable to insert record in table

    Hi,
    I want to insert record in database table, but when I execute insert command(at When List changed trigger) as select from query and issue commit, the form trying to insert record from datablock which is obviously having empty items, how can I commit at database level not at form level.
    *******************Below the SQL Statement issued by Form******************
    INSERT INTO BILL_OF_MATERIALS_TABLE(PROJECTNO,GROUP_,ITEM,STATUS,QUANTITY,UNIT_PRICE,REASON_FOR_CHANGE,REMARKS,AWARD_COPY,LOCKED,VO_COPY) VALUES (:1,:2,:3,:4,:5,:6,:7,EMPTY_CLOB(),:9,:10,:11) RETURNING ROWID,PROJECTNO,GROUP_,ITEM,STATUS,QUANTITY,UNIT_PRICE,REASON_FOR_CHANGE,REMARKS,AWARD_COPY,LOCKED,VO_COPY INTO :12,:13,:14,:15,:16,:17,:18,:19,:20,:21,:22,:23
    ***************Error Raised by Form********
    ORA-01400: cannot insert NULL into ("CAPEX"."BILL_OF_MATERIALS_TABLE"."ITEM")

    Remember that when you write "commit;" within your forms code then Forms interprets it as a commit_form statement. That's why the form-level commit is launched as you mentionned.
    So if you want to make a database commit then I think that you should create a stored procedure which makes the insert , and you call this stored procedure within your forms code.
    Try it.

  • Insert record in table having BLOB datatype

    Hi All,
    I have a table with BLOB datatype, Pls assist me how to insert a record in this table?
    CREATE TABLE document_BLOB_tab (
    doc_id_no NUMBER
    , doc_name VARCHAR2(200)
    , doc_value BLOB);
    What are the process to execute DBMS_LOB.fileOpen ?
    Rgds
    Sarfaraz

    1- Create a table that has a list of all directory, filenames combination
    SQL> create table listpic (directory varchar2(10), filename varchar2(10));
    Table created.
    2- Insert into that table all your directories and the filenames of the images within each
    directory (directory, filename) combination
    on my file system, I have
    d:\tars\samples1\lilies.jpg
    d:\tars\samples1\Sunset.jpg
    d:\tars\samples2\Blue.jpg
    d:\tars\samples1\Winter.jpg
    Here is my insert statment
    SQL> insert into listpic values('Samples1', 'lilies.jpg');
    1 row created.
    SQL> insert into listpic values('Samples1', 'Sunset.jpg');
    1 row created.
    SQL> insert into listpic values('Samples2', 'Blue.jpg');
    1 row created.
    SQL> insert into listpic values('Samples2', 'Winter.jpg');
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from listpic;
    DIRECTORY FILENAME
    Samples1 lilies.jpg
    Samples1 Sunset.jpg
    Samples2 Blue.jpg
    Samples2 Winter.jpg
    3- Create the table where you are going to store your pictures
    SQL> create table pictures (id number(5), image blob);
    Table created.
    4- Create a directory pointing to the common parent Directory
    SQL> create or replace directory IMAGES as 'd:\tars';
    Directory created.
    5- Create the following procedure to insert the image
    SQL> set serveroutput on
    SQL> create or replace procedure insert_image as
    2 f_lob bfile;
    3 b_lob blob;
    4 i number := 1;
    5 cursor image_cur is select directory, filename from listpic;
    6 pic_rec image_cur%ROWTYPE;
    7 begin
    8
    9 OPEN image_cur;
    10 Loop
    11 fetch image_cur into pic_rec;
    12 EXIT WHEN image_cur%NOTFOUND;
    13 insert into pictures values ( i, empty_blob() )
    14 return image into b_lob;
    15
    16 f_lob := bfilename( 'IMAGES','\'||pic_rec.DIRECTORY||'\'||pic_rec.FILENAME);
    17 dbms_lob.fileopen(f_lob, dbms_lob.file_readonly);
    18 dbms_lob.loadfromfile( b_lob, f_lob, dbms_lob.getlength(f_lob) );
    19 dbms_lob.fileclose(f_lob);
    20 dbms_output.put_line (pic_rec.directory ||'\'||pic_rec.filename);
    21 commit;
    22 i := i+1;
    23 END LOOP;
    24 end;
    25 /
    Procedure created.
    6- execute the procedure
    SQL> exec insert_image;
    Samples1\lilies.jpg
    Samples1\Sunset.jpg
    Samples2\Blue.jpg
    Samples2\Winter.jpg
    PL/SQL procedure successfully completed.
    SQL> select count(*) from pictures;
    COUNT(*)
    4
    SQL> select length(image) from pictures;
    LENGTH(IMAGE)
    83794
    71189
    28521
    105542
    Image has been uploaded to the dataabase.

  • Inserting records into Table with check table logic in place

    I want to insert records into a table, and have the check table to not allow invalid entries.  Is there a function out there that will allow this?  I am currently using the insert statement and it is working except that it is not giving an error when the value does not exist in the check table for the particular fields.
    INSERT INTO ZSD_XREF VALUES WA_XREF.
    That is the basic statement I'm using ZSD_XREF has several fields one being the material number field tied to the check table which happens to be MAKT file.  The insert statement is not validating the material numbers using the check table, or at least it is not giving an error.  Any ideas?

    Paul,
    Unfortunately, open SQL statements such as INSERT, UPDATE do not go through the check table logic as they directly hit the database layer. Check table checks are performed only if you go through application layer that is when you enter the same data through a screen.
    You have to do the checks yourself.
    Happy checking!!!
    Srinivas

  • How to insert record in table using ADF Table

    Hi,
    I am developing and application in ADF .it consist 5 tables.i need to insert into 1 table that contains IDs that are reffered from other tables and on ADF Table fi i dont want to show those IDs. Can somebody provide me solution how to do that?
    like i have a SkillTable - that contains attributes Resource No(number) ,module Id(number), Track id(number), skill_type(number), skill_rating(number), experience(number).
    Track id is reffered from track table
    Module id is reffered from module table
    Resource table is reffered from resource table
    skill_type and skill_rating from lookup table
    and i need to insert into SkillTable using ADF Table. we dont want to show Track id,module id,codes for skill_type nad skill_rating on ADF Table instead we want to show trackname and module name ,code values for skill_type and Skill_rating .
    when we create ADF table for this skill table it shows me ids but what i want is that in each row it should show resource name,modulename,track name,and for skill_type and skill_rating it should show name of skill_types and Skill_rating rather than codes for each skill_type and Skill_rating.
    we tried to insert by creating view ,but didnot work.
    plz provide any solution.
    Thnakls

    Hi,
    Thanks for quick reply.but let me tell u my problem in more detail.
    To insert into skill_table I have created a VO that contains ResourceNo, track_id, module_id,skill_type,skill_rating,experience. And I drag it on ADF creation form and also have created read only LOV for resource_name from resorce_table, LOV for skill_type,skill_rating from Lookup table,
    And mapped those LOV to resource_no,skill_type,skill_rating on insert page.
    For track_id I have converted inputtextBox to SelectinputText to create databound LOV which will popup a window that contain master detail for track_table and module_table which shows all track_names in master and corresponding module_names in detail table, and on that window I have select button when we click that button selected track_id and selected module_id will get populated to insert skill page in track_id selectinputtextbox and module_Id inpiuttextbox.
    Now what I want is that instead of track_id and module_id populated on insert page coz these are of id's actually and we want to show values of these id's from other tables, I need to show selected track_name and module_name over on insert page.
    Not getting any idea how to do that???
    Plz help.

  • Problem inserting records in table using cursors

    hi all
    i have a block in which i m trying to take records from a table pass it to a procedure which in turn calls some procedures
    and than the procesed records are dumped into another table
    this is my code
    set serveroutput on
    declare
    lastcall date;
    srcip varchar2(50);
    username varchar2(50):='9204';
    duration number;
    callto varchar2(50);
    accountid varchar2(50);
    calltime date;
    subscriberid varchar2(50);
    country varchar2(50);
    cost varchar2(50);
    CURSOR process_cdr
              IS
    SELECT
              srcip,
              username,
              callto,
              calltime,
              duration
    FROM rawcdr
    WHERE     calltime>lastcall;
    begin
    select max(calltime_gmt) into lastcall from
    processed_cdr;
    open process_cdr;
    fetch process_cdr into srcip,username,callto,calltime,duration;
    dbms_output.put_line(callto);
    if (instr(callto,'00')=5) then
    callto:=SUBSTR(REPLACE(callto,SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 3, 50);
    dbms_output.put_line(callto);
    elsif (instr(callto,'011')=5) then
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 4, 50);
    dbms_output.put_line(callto);
    else
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') +1 , 50);
    end if;
    process_call(srcip,username,duration,callto,accountid,subscriberid,country,cost);
    dbms_output.put_line(cost);
    dbms_output.put_line('trying to insert');
    insert into processed_cdr values(accountid,subscriberid,srcip,username,callto,country,calltime,duration,cost) ;
    dbms_output.put_line('inserted successfully');
    FETCH process_cdr INTO srcip, username, callto, calltime, duration;
    close process_cdr;
    end;
    now the problem is that
    records are not getting inserted nor an error is shown
    i guess i m not that much familiar with cursors
    and thats creating prob
    please help

    Hallo,
    but you haven't a loop ! :-)
    Try this,
    (not tested)
    set serveroutput on
    declare
    lastcall date;
    srcip varchar2(50);
    username varchar2(50):='9204';
    duration number;
    callto varchar2(50);
    accountid varchar2(50);
    calltime date;
    subscriberid varchar2(50);
    country varchar2(50);
    cost varchar2(50);
    CURSOR process_cdr
    IS
    SELECT
    srcip,
    username,
    callto,
    calltime,
    duration
    FROM rawcdr
    WHERE calltime>lastcall;
    begin
    select max(calltime_gmt) into lastcall from
    processed_cdr;
    open process_cdr;
    LOOP
    fetch process_cdr into srcip,username,callto,calltime,duration;
    EXIT WHEN process_cdr%NOTFOUND;
    dbms_output.put_line(callto);
    if (instr(callto,'00')=5) then
    callto:=SUBSTR(REPLACE(callto,SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 3, 50);
    dbms_output.put_line(callto);
    elsif (instr(callto,'011')=5) then
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') + 4, 50);
    dbms_output.put_line(callto);
    else
    callto:=SUBSTR(REPLACE(callto, SUBSTR(callto, INSTR(callto, '@'), 50), ''), INSTR(callto, ':') +1 , 50);
    end if;
    process_call(srcip,username,duration,callto,accountid,subscriberid,country,cost);
    dbms_output.put_line(cost);
    dbms_output.put_line('trying to insert');
    insert into processed_cdr values(accountid,subscriberid,srcip,username,callto,country,calltime,duration,cost) ;
    dbms_output.put_line('inserted successfully');
    /* Second fetch is not needed
    --FETCH process_cdr INTO srcip, username, callto, calltime, duration; */
    END LOOP;
    close process_cdr;
    COMMIT; -- eventually
    end;You didn't answered - do you do COMMIT elsewhere ?
    I placed COMMIT also, if you don't need it, you can comment it
    Regards
    Dmytro

  • Inserting  records in table .

    requirement is like this
    we have three message text input filelds the fields are
    finance,MMd,User depts,using lovs we are searching for person id (coming from different tables according some conditions) and return to the input field based on the personid we are getting membername and designation same process for the remaining two deparments. we want save only person Ids and groupid into table(new table) .

    Your new VO must be based on a EO, the EO must be based on the table.
    On press of "Apply" or "Save" button, invoke a method in AM from the CO.
    The new VO must be there in the root AM
    In this method write
    this.getOADBTransaction().commit();
    Thanks
    Tapash

  • Why grant select is needed on a table when you are only inserting records

    Please can you tell me why a grant select is needed when inserting records which are being inserted across a link?
    We have a table in database1 which we are trying to insert records from database2. database2 has a db_link to database1.
    The table residing in database1 has grant insert to the named user in the db_link. But unless there is also a grant select to that user we cannot insert records. We do not actually need to be able to select the records across the db_link, but nevertheless we get the following error on trying to insert records without the grant select being in place:
    ORA-01031: insufficient privileges
    Cause: An attempt was made to change the current username or password without the appropriate privilege. This error also occurs if attempting to install a database without the necessary operating system privileges. When Trusted Oracle is configure in DBMS MAC, this error may occur if the user was granted the necessary privilege at a higher label than the current login.
    Action: Ask the database administrator to perform the operation or grant the required privileges. For Trusted Oracle users getting this error although granted the the appropriate privilege at a higher label, ask the database administrator to regrant the privilege at the appropriate label.
    Your thoughts would be appreciated.

    Since there is no remote describe function, a select must be done to get the table structure. This is talked about in Note: 1004923.6.

  • Insert record from one table to another with help of cursor

    Plz help!!!
    tables are - 1. country( country_id pk, country_name, region_id)
    2. a( country_id , country_name, region_id)
    table a data are
    1 a 1
    2 b 2
    3 c 3
    null d 4
    5 e 5
    6 f 6
    7 g 7
    insert record from table a to country table with help of cursor, insert all not null records.
    this procedure does not give correct result
    create or replace
    procedure amit as
    cursor c1 is select * from a;
    rw a%rowtype;
    begin
    open c1;
    fetch c1 into rw;
    while(c1%found)
    loop
    insert into countries values(rw.country_id,rw.country_name,rw.region_id);
    commit;
    fetch c1 into rw;
    if rw.country_id is null then
    fetch c1 into rw;
    end if;
    end loop;
    close c1;
    exception
    when others then
    dbms_output.put_line('exception name= '||rw.country_name);
    end;

    bluefrog wrote:
    You don't need cursor at all;
    create or replace procedure amit as
    begin
    insert into countries (Country_ID, Country_Name, Region_ID)
    (select a.Country_ID
    ,a.Country_Name
    ,a.Region_ID
    from a
    dbms_output.put_line('Rows inserted : ' || sql%rowcount);
    commit;
    end;
    Bluefrog you missed where clause. :)
       insert into countries (Country_ID, Country_Name, Region_ID)
       (select a.Country_ID
              ,a.Country_Name
              ,a.Region_ID
        from a
        where country_id is not null
    );

  • Add date stamp to insert record

    This should be easy. I would think it's a standard procedure but 5 hours of searching the net, the forums, and experimenting has left me with a loss.
    I've created a simple form with 3 fields, firstName, lastName, eMail
    I've created a SQL database and table with the fields id, date, firstName, LastName, eMail
    The id is an int and the primary key, date is set to datetime the rest are varchar
    I've created a successful Insert Record behavior and now all I want to do is to update the date field with the datetime value when the record is added.
    Things I've tried include a java script to create a date variable, SQL NOW in various forms, a ton of other complex solutions. I've added hidden fields to the form, which got me the closest when I manually entered a value in the same format that I see in the SQL table when I add a row to the table from the PHP admin page.
    Please tell me this is not going to require 30 lines of code and another half day of fussing around.

    Hi Rick,
    Please tell me this is not going to require 30 lines of code and another half day of fussing around.
    with ADDT it´s pretty easy: just make sure that your datetime column gets ADDT´s "datetime" placeholder {NOW_DT} inserted as "entered value":
    Open the Insert Record Transaction dialog box, select the date column and define these settings:
    - Submit as: Date
    - Get value from: Entered Value
    - Value: {NOW_DT}
    Cheers,
    Günter Schenk
    Adobe Community Expert, Dreamweaver

  • Problem about inserting records ? ?

    hello ,
    i want to insert record in table abc which have 3 column
    i want to insert 2 values from xyz table and one values is from variable
    i write following query
    vMYQUERY :='INSERT INTO abc(NO, TYPE, SUB_TRAN) SELECT '||vSR_NO||',TYPE,SUB_TRAN FROM xyz ;
    EXECUTE IMMEDIATE vMYQUERY;
    is it correct ?
    pankaj

    Did it work?
    You could try the USING clause;
    SQL> create table abc(NO number, TYPE varchar2(10), SUB_TRAN varchar2(10))
    Table created.
    SQL> create table xyz(NO number, TYPE varchar2(10), SUB_TRAN varchar2(10))
    Table created.
    SQL> insert into xyz values(0,' col1', 'col2')
    PL/SQL executed.
    SQL> declare
       vmyquery varchar2(100);
       vsr_no number := 99;
    begin
       vmyquery :='INSERT INTO abc(NO, TYPE, SUB_TRAN) SELECT :1,TYPE,SUB_TRAN FROM xyz' ;
       EXECUTE IMMEDIATE vmyquery USING vsr_no;
    end;
    PL/SQL procedure successfully completed.
    SQL> select * from abc
            NO TYPE       SUB_TRAN 
            99  col1      col2     
    1 row selected.

  • Insert Data into Table from TXT or CSV file !!!!!

    Dear All,
    Recently I have started working on APEX. In Oracle Forms, we used to use TEXT_IO for inserting records into tables from txt files. Now I want to do the same thing in apex 3.2. How can I insert data into tables from txt of csv files.
    Waiting of your valuable suggestions.
    With kind regards,
    Yousuf.

    Yousuf
    wwv_flow_files is used by APEX to hold uploaded files.
    If you incorporate a file browse item on you page, browse for the selected file, then submit the page (having the PL/SQL process described as an on suibmit process) then what I detailed should work.
    If you don't need users to have access to this then just go to Home>Utilities>Data Load/Unload in APEX and there is a handy load utility there that does it all for you.
    Cheers
    Ben

  • Delete inserted record

    I bulid trigger in tabel and check condition, if for example check_statment = X i need to delete inserted record (that mead not insert record) and when check_statment = Y then insert record in table, i try to write delete statment and rollback but there is error appear that the current record are reserved.
    How i can solve it.

    1. Triggers cannot Issues ROLLBACK, SAVEPOINT, COMMIT statements.
    2. I guess you are trying to avoid duplicate records, Create a unique index on the key(col1,col2) which you want to prevent duplicates on.
    3. Or you can Add a column Flag Chr(1) to your table. While inserting you allow the records to get inserted, but based on your condition change the Flag to 'D' - deleted , 'A' -active. Build a View which the user uses for application filtering out the 'D'eleted records.
    Does this look like what you are trying to do !
    Ss

  • How to insert records with LONG RAW columns from one table to another

    Does anybody know how to use subquery to insert records with columns of LONG RAW datatype from one table to another? Can I add a WHERE clause in the subquery statement? Thanks.

    Insert into ... Select statements are not supported for long or long raw. You will have to either use PL/SQL or convert your long raw to blobs.

  • Selecting Records from 125 million record table to insert into smaller table

    Oracle 11g
    I have a large table of 125 million records - t3_universe.  This table never gets updated or altered once loaded,  but holds data that we receive from a lead company.
    I need to select records from this large table that fit certain demographic criteria and insert those into a smaller table - T3_Leads -  that will be updated with regard to when the lead is mailed and for other relevant information.
    My question is what is the best (fastest) approach to select records from this 125 million record table to insert into the smaller table.  I have tried a variety of things - views, materialized views, direct insert into smaller table...I think I am probably missing other approaches.
    My current attempt has been to create a View using the query that selects the records as shown below.  Then use a second query that inserts into T3_Leads from this View V_Market.  This is very slow. Can I just use an Insert Into T3_Leads with this query - it did not seem to work with the WITH clause?    My Index on the large table is t3_universe_composite and includes zip_code, address_key, household_key. 
    CREATE VIEW V_Market  as
    WITH got_pairs    AS  
         SELECT /*+ INDEX_FFS(t3_universe t3_universe_composite) */  l.zip_code, l.zip_plus_4, l.p1_givenname, l.surname, l.address, l.city, l.state, l.household_key, l.hh_type as l_hh_type, l.address_key, l.narrowband_income, l.p1_ms, l.p1_gender, l.p1_exact_age, l.p1_personkey, e.hh_type as filler_data, 1.p1_seq_no, l.p2_seq_no 
         ,      ROW_NUMBER () OVER ( PARTITION BY  l.address_key 
                                      ORDER BY      l.hh_verification_date  DESC 
                      ) AS r_num   
         FROM   t3_universe  e   
         JOIN   t3_universe  l  ON   
                l.address_key  = e.address_key
                AND l.zip_code = e.zip_code
              AND   l.p1_gender != e.p1_gender
                 AND   l.household_key != e.household_key         
                 AND  l.hh_verification_date  >= e.hh_verification_date 
      SELECT  * 
      FROM  got_pairs
      where l_hh_type !=1 and l_hh_type !=2 and filler_data != 1 and filler_data != 2 and zip_code in (select * from M_mansfield_02048) and p1_exact_age BETWEEN 25 and 70 and narrowband_income >= '8' and r_num = 1
    Then
    INSERT INTO T3_leads(zip, zip4, firstname, lastname, address, city, state, household_key, hh_type, address_key, income, relationship_status, gender, age, person_key, filler_data, p1_seq_no, p2_seq_no)
    select zip_code, zip_plus_4, p1_givenname, surname, address, city, state, household_key, l_hh_type, address_key, narrowband_income, p1_ms, p1_gender, p1_exact_age, p1_personkey, filler_data, p1_seq_no, p2_seq_no
    from V_Market;

    I had no trouble creating the view exactly as you posted it.  However, be careful here:
    and zip_code in (select * from M_mansfield_02048)
    You should name the column explicitly rather than select *.  (do you really have separate tables for different zip codes?)
    About the performance, it's hard to tell because you haven't posted anything we can use, like explain plans or traces but simply encapsulating your query into a view is not likely to make it any faster.
    Depending on the size of the subset of rows you're selecting, the /*+ INDEX hint may be doing your more harm than good.

Maybe you are looking for