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.

Similar Messages

  • Problem while importing table with blob datatype

    hi i am having a database 9i on windows xp and dev database 9i on AIX 5.2
    while i am taking export of normal tables and trying to import i am successful.but when i am trying to import a table with blob datatype it is throwing "tablespace <tablespace_name> doesn't exist" error
    here how i followed.
    SQL*Plus: Release 9.2.0.1.0 - Production on Mon Oct 8 14:08:29 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Enter user-name: test@test
    Enter password: ****
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL> create table x(photo blob);
    Table created.
    exporting:
    D:\>exp file=x.dmp log=x.log tables='TEST.X'
    Export: Release 9.2.0.1.0 - Production on Mon Oct 8 14:09:40 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Username: pavan@test
    Password:
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    About to export specified tables via Conventional Path ...
    Current user changed to TEST
    . . exporting table X 0 rows exported
    Export terminated successfully without warnings.
    importing:
    D:\>imp file=x.dmp log=ximp.log fromuser='TEST' touser='IBT' tables='X'
    Import: Release 9.2.0.1.0 - Production on Mon Oct 8 14:10:42 2007
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    Username: system@mch
    Password:
    Connected to: Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
    With the Partitioning, Real Application Clusters, OLAP and Oracle Data Mining op
    tions
    JServer Release 9.2.0.6.0 - Production
    Export file created by EXPORT:V09.02.00 via conventional path
    Warning: the objects were exported by PAVAN, not by you
    import done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
    import server uses US7ASCII character set (possible charset conversion)
    . importing TEST's objects into IBT
    IMP-00017: following statement failed with ORACLE error 959:
    "CREATE TABLE "X" ("PHOTO" BLOB) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS "
    "255 STORAGE(INITIAL 65536 FREELISTS 1 FREELIST GROUPS 1) TABLESPACE "TESTTB"
    "S" LOGGING NOCOMPRESS LOB ("PHOTO") STORE AS (TABLESPACE "TESTTBS" ENABLE "
    "STORAGE IN ROW CHUNK 8192 PCTVERSION 10 NOCACHE STORAGE(INITIAL 65536 FREE"
    "LISTS 1 FREELIST GROUPS 1))"
    IMP-00003: ORACLE error 959 encountered
    ORA-00959: tablespace 'TESTTBS' does not exist
    Import terminated successfully with warnings.
    why it is happening for this table alone?plz help me
    thanks in advance

    Here is exerpt from {
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:378418239571}
    =============================================
    Hi Tom,
    I have a dump file containing blob datatypes, when i import the dump file in a schema it gives an
    error stating that the tablespace for Blob datatype does not exists. My question is how do i import
    the dump file in the default tablespace of the importing user.
    Followup March 2, 2004 - 7am US/Eastern:
    You'll have to precreate the table.
    do this:
    imp userid=u/p tables=that_table indexfile=that_table.sql
    edit that_table.sql, fix up the tablespace references to be whatever you want to be, run that sql.
    then imp with ignore=y
    for any MULTI-SEGMENT object (iot's with overflows, tables with lobs, partitioned tables, for
    example), you have to do this -- imp will not rewrite ALL of the tablespaces in that
    multi-tablespace create -- hence you either need to have the same tablespaces in place or precreate
    the object with the proper tablespaces.
    Only for single tablespace segments will imp rewrite the create to go into the default if the
    requested tablespace does not exist.
    ===================================================
    To summarize: precreate target table when importing multi-segment tables

  • Export and Import Of Tables having BLOB and Raw datatype

    Hi Gurus,
    I had to export one schema in one database and import to another schema in another database.
    However my current database contains raw and blob datatype.I have exported the whole database by the following commnad
    exp SYSTEM/manager FULL=y FILE=jbrms_full_19APR2013.dmp log=jbrms_full_19APR2013.log GRANTS=y ROWS=y
    My question is if all the tables with raw and blob have been exported properly or not.I have done one more thing after taking the export , I have imported to local db and checked the no of rows in the both the envs are same.As I have not tested with the application to confirm.
    I am using this version of Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production
    not able to attach the complete log file but for the schema jbrms which has the blob and raw datatype.
    Please let me know if you find some potential concerns with the export for BLOB and raw
    . about to export JBRMS's tables via Conventional Path ...
    . . exporting table FS_FSENTRY 8 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table FS_WS_DEFAULT_FSENTRY 2 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table PM_WS_DEFAULT_BINVAL 60 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table PM_WS_DEFAULT_BUNDLE 751 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table PM_WS_DEFAULT_NAMES 2 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table PM_WS_DEFAULT_REFS 4 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table VERSIONING_FS_FSENTRY 1 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table VERSIONING_PM_BINVAL 300 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table VERSIONING_PM_BUNDLE 11654 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table VERSIONING_PM_NAMES 2 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.
    . . exporting table VERSIONING_PM_REFS 1370 rows exported
    EXP-00091: Exporting questionable statistics.
    EXP-00091: Exporting questionable statistics.

    You could see the 'QUESTIONABLE STATISTICS' warning for a couple of reasons. I don't remember them all but.
    1. If the target and source character set is different.
    2. system generated names (I think?)
    the best solution if you don't need the exact statistics that are on your source database would be to add
    statistics=none
    to your imp command and then regather statistics when the imp command is done.
    Dean

  • 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.

  • 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.

  • 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.

  • How to create a table using blob datatype and then selecting the output???

    I have created table
    create table imgloader(img_l blob);
    now i want to insert the image i.e. '/u1/archie.jpg' to this table
    what steps to be follwed to insert the image into table..and how to see the stored image??

    Is GOOGLE & SEARCH broken for you?
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:392618837633

  • How can we find size of a table having blob columns

    I have a problem in which i need to get the size of table that ishaving BLOB column in it.
    How to find the size?
    for ex: i am having a table DocBlob which is having a BLOB column DocObject. How to get the size of DocBlob table?
    Also how one can see the data of the BLOB column. In toad or Pl/Sql dev tool, we can not see anything. here we use to store the images in it. how we can verify that what image or data is stored in these columns??
    thanks..

    Tables are segments. LOB Segments are segments.
    SELECT blocks or bytes FROM user_segments
    You can also use dbms_lob.getlength to retrieve the length of a LOB.
    http://www.morganslibrary.org/reference/dbms_lob.html

  • 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

  • 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
    );

  • Reading contents of a BLOB datatype having more than 4000 characters.

    Hi,
    I am unable to read contents of a column having BLOB datatype.I tried using ult_raw.cast_varchar2(Col_name) procedure,but since varchar2 has a size limit of 4000 bytes,complete contents are not visible.
    Pl. suggest some way to view the contents.
    Regards,
    Saket Bansal

    In the link that you mentioned a procedure is used that gets the length first then loops through if length is greater than 32760.
    I mean to say can user get the output in a single SQL query e.g.
    select utl_raw.cast_to_varchar2(column_name) from table_name;something like this for bytes greater than 4000 bytes.
    ----- Read your reply a bit late thanks.
    Edited by: Avi on Mar 2, 2009 1:21 AM

  • SQLServer to oracle migration. Issue with table having image data.

    Hi,
    I am using the SQL Developer version 1.5.0.53 Build MAIN-53.38. I am trying to migrate from sql server database to oracle. Sql server database version is 2005 and oracle database version is 10g (10.1.0.2 and 10.2.0.3). Both Oracle and Sql server databases are on windows-xp.
    Everything (including data) migrated well except for the one table having blob (oracle) and image(sqlserver). I am getting the following error in sql developer while migrating data for the blob from sql server to oracle.
    Data Move information:Rows : 497 Errors: 10278
    Commit failed: Closed Connection
    Must be logged on to server
    [POCRepository].[td].[REPOSITORY] Closed Connection
    Io exception: Software caused connection abort: socket write error
    [POCRepository].[td].[REPOSITORY] OALL8 is in an inconsistent state
    No more data to read from socket
    [POCRepository].[td].[REPOSITORY] No more data to read from socket
    Inserting ' ' into column td_POCRepository.REPOSITORY.RP_DATA (Row number 498)
    I have created sqldeveloper.cmd file as suggested in other threads and I am using the same java provided with SQL Developer 1.5.0.53.
    The database alertsid.log shows the following error messages for this activity.
    ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [0x34EF9E5] [] [] [] []
    ORA-00600: internal error code, arguments: [kghasp1], [0x5F3B718], [], [], [], [], [], []
    ORA-07445: exception encountered: core dump [ACCESS_VIOLATION] [0x34EF9E5] [] [] [] []
    The error ORA-00600[kghasp1] refers to the problem with heap memory. I also restarted the database and tried the data migration for only this table but with the same error.
    I tried it on both 10g release1 and 10g release 2.
    Can someone please help me in resolving this issue.
    Thanks
    Raghavendra

    Hi Raghavendra,
    Are you saying the Microsoft SQL Server bcp dump of image data failed? It has been tested, it results in a hex dump rather than a binary dump, hence the clob to blob, and hextoraw workaround.
    What are the version numbers and what is the reproducible test case?
    -Turloch
    Note that the clob to blob process is automated:
    Tools->preferences->Migration->Generation Options->General Options->Generate Stored Procedure for Migrate Blobs Offline
    From Help:
    Generate Stored Procedure for Migrate Blobs Offline: Causes a stored procedure named CLOBtoBLOB_sqldeveloper (with execute access granted to public) to be created if the schema contains a BLOB (binary large object); this procedure is automatically called if you perform an offline capture. If this option is not checked, you will need to use the manual workaround described in Populating the Destination Database Using the Data Files. (After the offline capture, you can delete the CLOBtoBLOB_sqldeveloper procedure or remove execute access from public.)

  • 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

Maybe you are looking for

  • Xorg, xf86-video-ati - no OpenGL rendering [Mobility Radeon HD 5000]

    Hello I got a new laptop (Asus b53j, EU version with an i3 - should be same hardware otherwise) and of course it needs to run Arch, or it'll slowly rust. It has an option to switch the graphics card in Windows (From Intel to ATI Mobility Radeon HD 50

  • Tools for validate HTML and CSS Error in DW?

    Hello Guys, Want to know any addon or menu tool in Dreamweaver to validate HTML and CSS error. Because every time i have to check in w3c validation. If DW having in this options it wouldbe great to develop website with out error. Please let me know y

  • DVD-burner suddently GONE in /dev

    I rarely use my DVD-burner to read or write anything at all, but this other day I discovered it wasn't even listed in /dev .. Usually it's detected as /dev/sr0 .. That's why I can't figure out if this is a problem after updating to 2.6.25 .. dmesg: h

  • Changes in WAD are not reflecting after transport

    Moving thread to Business explorer Thank you Edited by: YJV on Dec 22, 2009 2:09 PM

  • No recognized audio in .M2TS files

    I've seen a couple of different threads about this issue that have said the same thing but all have referenced AVCHD from various Sony Cameras. In my case my footage is from  HDPVR. Why the capture device would matter doesn't make any sense to me but