ROWTYPE to get better query ?

Hello,
I have two identical tables:
PHOTOS_TEMP AND IMAGES_TEST
(ID PK number ,
content blob,
filename varchar2 (200),
mimetype varchar2 (200),
filesize varchar2 (200),
res_id FK number,
watermarked varchar2 (1))I have CODE 1, I want to make it more effecient perhaps by using %ROWTYPE,
So, I tried CODE 2, but it did not work. It tells, "Too many values .... CONTENT must be declared ...."
Can you plesae tune Code 1 ??
h1. CODE 1 is working fine
DECLARE
type source_col is table of blob index by pls_integer ;
V_source source_col;
type id_col is table of number index by pls_integer ;
V_id id_col;
type char_col is table of IMAGES_TEST.FILENAME%TYPE index by pls_integer ;
V_filename char_col;
V_mimetype char_col;
begin
select content,filename,mimetype,id bulk collect into
V_source,v_filename,v_mimetype,v_id from photos_temp
where  temp = :P700_TEMP_IMAGE   for update  ;
for i in V_source.first .. V_source.last
loop
ORDSYS.ORDImage.process(V_source(i), 'fixedScale=800 500');
end loop;
forall i in V_source.first .. V_source.last
insert into IMAGES_test
(res_id ,CONTENT,filename,mimetype,filesize,watermarked)
values
(:P700_res_ID ,V_source(i),V_filename(i),V_mimetype(i),
dbms_lob.getlength(V_source(i)), 'Y');
COMMIT;
EXCEPTION
   WHEN OTHERS THEN
   RAISE;
END;h1. CODE 2 supposed to be more efficient, but not working ?
DECLARE
type new_row is table of IMAGES_TEST%rowtype index by pls_integer ;
v_row new_row;
begin
-- This may collect more than one row
select * bulk collect into
v_row from photos_temp
where  temp = :P700_TEMP_IMAGE   for update  ;
for i in v_row.id.first .. v_row.id.last
loop
ORDSYS.ORDImage.process(v_row.content(i), 'fixedScale=800 500');
end loop;
forall i in v_row.id.first .. v_row.id.last
insert into IMAGES_test
(res_id ,CONTENT,filename,mimetype,filesize,watermarked)
values
(:P700_res_ID ,v_row.contnet(i),v_row.filename(i),v_row.mimetype(i),
dbms_lob.getlength(v_row.content(i)), 'Y');
COMMIT;
EXCEPTION
   WHEN OTHERS THEN
   RAISE;
END;Best Regards,
Fateh
Edited by: Fateh on Nov 26, 2012 5:22 AM

hi,
In your CODE 1
select content,filename,mimetype,id bulk collect into
V_source,v_filename,v_mimetype,v_id from photos_temp
where  temp = :P700_TEMP_IMAGE   for update  ;
-- temp is not a collumn name nor a variable name
...So I think that does not work.
In code 2 you must use the index "( i)" on the table variable and not on the attribute. So:
v_row.contnet(i) --THIS IS WRONG!
v_row(i).contnet -- This is OK
Also:
v_row.id.first --THIS IS WRONG!
v_row.first --This is OK
Below is an working example:
insert into photos_temp (id ,filename) values ( 1,'peter');
insert into photos_temp (id ,filename) values ( 2,'Fateh');
commit;
DECLARE
type new_row is table of IMAGES_TEST%rowtype index by pls_integer ;
v_row new_row;
begin
  select * bulk collect into
   v_row from photos_temp
  --where  temp = :P700_TEMP_IMAGE  
  for update  ;
  --for i in v_row.id.first .. v_row.id.last
  for i in v_row.first .. v_row.last
  loop
  DBMS_OUTPUT.PUT_LINE('Id: ' || v_row(i).id || ' filename: ' || v_row(i).filename);
  end loop;
end;
Result:
Id: 1 filename: peter
Id: 2 filename: FatehAnd in your case for code 2 simplyfied:
DECLARE
type new_row is table of IMAGES_TEST%rowtype index by pls_integer ;
v_row new_row;
begin
  select * bulk collect into
   v_row from photos_temp
  --where  temp = :P700_TEMP_IMAGE  
  for update  ;
  --forall i in v_row.id.first .. v_row.id.last
  forall i in v_row.first .. v_row.last
  insert into IMAGES_test
  (id ,filename)
  values
  (v_row(i).id, v_row(i).filename);
end;
select
  id
  ,filename
from
  images_test;
Result:
ID FILENAME                                                                                                                                                                                              
1 peter                                                                                                                                                                                                   
2 Fateh                                                                                                                                                                                                    Whoever this works in:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
PL/SQL Release 11.2.0.1.0 - Production
"CORE     11.2.0.1.0     Production"
TNS for 64-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
I think in oracle 9 you must use seperate table variables and not one table variable of a scalar type.
Regards,
Peter

Similar Messages

  • On Demand process get url query string

    Hi,
    When I call On Demand process , is there way inside that process get url query sting or whole url did call On Demand process?
    I did try below but it returns null
    owa_util.get_cgi_env('QUERY_STRING')Regards,
    Jari

    You'd know this better than me - but I seem to recall there are 2 Oracle sessions involved in normal page processing - one for the request and one for the response. wwv_flow.show seems to correspond to the response session, not the request session (that might have the env variables you're looking for). Could that explain what you're seeing?

  • Help for efficient/better query

    DB Details:
    Oracle 11g R2 - 11.2.0.1
    CREATE TABLE workflow_routing_assoc
        wf_routing_assoc_id   NUMBER,                                 -- unique id
        routing_group_id      NUMBER,        -- common id for the four combination
        routing_rule_id       NUMBER, -- this column differnciates the information provided eg: date,day,month,year
        routing_rule_value    VARCHAR2 (50 BYTE), -- this column contains the information for the routing_rule_id(third column) eg: 01(date),wed(day),month(sep),year(2011)
        created_by            VARCHAR2 (50 BYTE),              --created user name
        created_date          timestamp (6),                        --created date
        modified_by           VARCHAR2 (50 BYTE),           -- modifying user name
        modified_date         timestamp (6)
    )                                                              --modified date
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (1,
                55,
                8,
                'test-example');
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (2,
                55,
                5,
                '12');
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (3,
                55,
                2,
                'sep');
    INSERT INTO workflow_routing_assoc (wf_routing_assoc_id,
                                        routing_group_id,
                                        routing_rule_id,
                                        routing_rule_value)
      VALUES   (4,
                55,
                9,
                '2010');
    COMMIT;
    -- NEED A BETTER QUERY INSTEAD OF THIS
    *SQL> SELECT   result0.routing_group_id*
      *2    FROM   (SELECT   routing_group_id, routing_rule_id*
      *3              FROM   workflow_routing_assoc*
      *4             WHERE   routing_rule_value = 'test-example') result0,*
      *5           (SELECT   routing_group_id, routing_rule_id*
      *6              FROM   workflow_routing_assoc*
      *7             WHERE   routing_rule_value = '12') result1,*
      *8           (SELECT   routing_group_id, routing_rule_id*
      *9              FROM   workflow_routing_assoc*
    *10             WHERE   routing_rule_value = 'sep') result2,*
    *11           (SELECT   routing_group_id, routing_rule_id*
    *12              FROM   workflow_routing_assoc*
    *13             WHERE   routing_rule_value = '2010') result3*
    *14   WHERE       result0.routing_rule_id = 8*
    *15           AND result1.routing_rule_id = 5*
    *16           AND result2.routing_rule_id = 2*
    *17           AND result3.routing_rule_id = 9*
    *18           AND result0.routing_group_id = result1.routing_group_id*
    *19           AND result1.routing_group_id = result2.routing_group_id*
    *20           AND result2.routing_group_id = result3.routing_group_id;*
    op:
    ROUTING_GROUP_ID
                  55Thanks in advance

    Hi,
    What's wrong with the solution in the other thread?
    Query simplification
    Point out where it's getting the wrong results, and explain how you get the right results in those places. Post some new sample data and results if necessary.

  • How to get the query name from  portal report name

    Hi Experts ,
    I am given a portal report Name and asked to do changes to the queries of that ,so how do i get the query name ,
    Thanks in Advance
    Nitya

    Hi Nithya,
    You can get the technical name by selecting the role in the portal where the report is enclosed you will generally find the report in description then identify the report you are looking then double click on that you will get a window pop-up in that you will have details tab there click on the details the your Query technical name will be displayed.
    EX : zqry_w001 Then replace W with Q and seach in analyser or Designer.
    Regards
    Amar.

  • How to setup airport time capsule to get better performance?

    I need to set up my wireless system with my new Airport time capsule 3T as primary base station to get better performance, and  If I have a cable modem  as primary device to get the signal (5MB) from the ISP then my network has one, Macbook pro, Macbook air, mac mini, 2 ipad's, 2 iphones, but neither of them is connected all time.
    What is the best way to do that?
    What wifi channel need choose to?

    What is the best way to do that?
    Use ethernet.. performance of wireless is never as good as ethernet.
    What wifi channel need choose to?
    There is no such thing as the best channel..
    Leave everything auto.. and see if it gives you full download speed.
    Use 5ghz.. and keep everything up close to the TC for the best wireless speed.
    If you are far away it will drop back to 2.4ghz which is slower.
    Once you reach the internet speed nothing is going to help it go faster so you are worrying about nothing.

  • How can I get a query in the search field to open in a new tab or new window from the current window?

    How can I get a query in the search field to open in a new tab or new window from the current window?

    If you are searching via the Search Bar on the Navigation Toolbar, this preference can be changed to have searches there open in a Tab.
    Type '''about:config''' in the Address Bar and hit Enter. Then answer "I'll be careful". Type this pref in the Search at the top.
    '''browser.search.openintab''' = double-click to toggle to '''true'''

  • How to get the query result of improvement (Before and After ) using sql de

    how to get the query result of improvement (Before and After ) using sql developer.

    Check
    http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html

  • How to get the Query output to Excel

    Hi ,
    Can you tell me how to get the Query output to excel with out using any third party tool?
    Can you tell me how to write the code in Webservice and call it..
    Please explain it Elaboartly..
    Thanks in Advance!!!
    Mini

    whats your source system?
    you can use Live office, or query as a webservice if you are getting data from universe
    if you're getting data from SAP BI query and you have a java stack on your netweaver then you can get the data directly using sap bi connector in xcelsius.
    good luck

  • How do I get Better Investing magazine on my iPad?

    How do I  get Better Investing Magazine on my ipad?

    iTunes 11.1 is for Macs and PCs.
    Are you trying to upgrade your iPad to iOS 7?

  • How to get better resolution on Blu-ray (1080/60i)

    I'm experimenting with my new AG-AC160A camcorder and have been shooting youth hockey games in AVCHD mode, 1080/60i, 1/120 shutter, manual gain and white balance set appropriately, and florescent scene file setting due to lighting in rink. I have PP CS5 and am disappointed with the relative lack of HD-crispness when the Blu-ray output is played on my HD LED set. I used the above settings based on recommendations I saw in the forum somewhere. Any suggestions on what I can try differently? Thank you.

    To elaborate on Ann's great advice, the Sequence preset you should be using is AVCHD 1080i30 (60i).
    A good way to start out with the correct sequence is to import your clips and then drag one onto the "New Item" icon at lower right of Project Bin. This will create a new sequence to match the source material automatically. As Ann mentioned, you have a non-HD preview format, so if you rendered the timeline to green, and checked "Use Previews" on the final export, then your Blu-ray could have "SD quality" footage in it!!
    Curious why the 1/120 shutter, hoping to get better action motion?
    If you have a current timeline using the incorrect settings, go ahead and add a NEW Sequence with correct settings, open original sequence and "Select All" which is CRTL + A, then CTRL + C to Copy. Then go to the proper AVCHD sequence and Ctrl + V to Paste entire contents. You will now have the edited sequence moved into correct sequence settings. Now use Export and in AME choose "H.264 Blu-ray" and choose the 1080i preset and export, then use results in Encore. The Blu-ray should look excellent when done correctly.
    When exporting from AME, do NOT check the box for "Use Previews", as you want to encode direct from original source and skip any intermediate render clips.
    Thanks
    Jeff Pulera
    Safe Harbor Computers

  • How to get better perform here

    hi there,
    bellow code is using with in the loop. how can i modify to get better performance.
    SELECT knumv kposn kwert FROM konv
                                    INTO CORRESPONDING FIELDS OF lt_konv
                                     WHERE knumv EQ lt_output-knumv
                                     AND kposn EQ lt_output-posnr
                                     AND kschl EQ 'VPRS'.
            COLLECT lt_konv.
          ENDSELECT.
    thx in adv.

    the better solution for the select statement whould be to use the aggreagte function sum for the field kwert:
    SELECT knumv kposn sum(kwert)
                 FROM konv
                 INTO CORRESPONDING FIELDS OF table lt_konv
                 WHERE knumv EQ lt_output-knumv
                       AND kposn EQ lt_output-posnr
                       AND kschl EQ 'VPRS'.
    The select is inside the loop an lt_output.
    Aggregate functions and FOR ALL ENTRIES can not be combined, the
    FOR ALL ENTRIES is a select distinct !!!
    So you must leave the loop around the select and you can't use the FOR ALL ENTRIES, but this is o.k.,
    Siegfried

  • How to get better resolution on graphical borders in Pages?

    When using the «line effect» on a picture frame and choose a «image border», these borders a very pixelated and low resoltion when i.e. printing on a quality printer. Seems to be only screen resolution (100-150 dpi)? Is this a bug in Pages – how to get better resolution for these borders when exporting for example to PDF?

    Here you see the issue. The Document's size is A6 landscape, means 14.8x10.5 cm, and it prints and shows really pixelated

  • OAF page : How to get its query performance from Oracle Apps Screen?

    Hi Team,
    How to get the query performance of an OAF page using Oracle Apps Screen ??
    regards
    sridhar

    Go through this link
    Any tools to validate performance of an OAF Page?
    However do let us know as these queries performance can be check through backend also
    Thanks
    --Anil
    http://oracleanil.blogspot.com/

  • How can I get the query name/aggregationslevel in my planning function?

    Hi,
    is it possiable to get the query name/aggregationslevel in a planning fuction?
    thanks for your idea.
    hongwei

    Hi,
    The interface IF_RSPLFA_INFOPROV_DESC
    provides methods for retrieving the most important properties of an InfoProvider from the point of view of the implementation class of a planning function type.
    Methods GET_T_CHARNM and GET_T_KEYFNM return the names of the characteristics and key figures in the InfoProvider.
    You can get the properties of the InfoObjects and compound information by calling method GET_TAB_IOBJ_PRO and GET_TAB_IOBJ_CMP .
    Does this help?
    Best Regards
    Shyam

  • How can I get better video quality using my appleTV

    I have an appleTV (1st) and I want to get better quality from youtube videos, What should I do ?

    Welcome to the Apple Community.
    YouTube video does not come from the main YouTube site, it is specially encoded for the Apple TV and other devices that don't play flash. Generally quality is fixed with no way to adjust it and is often restricted by the quality of the video that has been uploaded.

Maybe you are looking for

  • TEMP usage in Parallel Query  |  Why can't it use the spare RAM?

    Hi All I have a query running with parallel degree 8 on Red Hat 64 bit, 10.2.0.4.0, with 16 CPUs and 32GB of RAM. My PGA target is 28 GB, SGA target at 2 GB. I am using this Oracle instance purely for some datamart ETL, in order to deliver data to a

  • What can Lightroom do for me that Photoshop and Bridge can't?

    I've been using Creative Suite Design Pro since CS2 (now on CS4).  Lately I've been getting more into photography and have started hearing and reading about Lightroom.  Does Lightroom have features that Photoshop Extended and Bridge in CS don't?  Can

  • Importing OIM AD connector config XML files

    Hello All, I am importing the AD connector files in the OIM admin and user console. After selecting the AD connector files, in step 2 i need the perform 3 operations as stated below. My operation fails when I try to import XML files using deployment

  • Premiere freezes when opening Help PDF file

    When I click help in the help menu, the PDF opens right away, but then Premiere freezes for about 40 seconds. I suspect it is trying to download some Internet content, but this behavior needs to be fixed. My Mac Pro is connected to an AirPort Extreme

  • How to disable repeating keys

    I need to accent some characters when typing in French.  According to what I read, repeat keys should no longer work in Mountain Lion, except for asterisks and dots etc.  In theory I should be able,  by holding down the letter on the keyboard, to get