Open cursor for string and select from partition (cannot bind)

Hi,
i don't manage to use a bind variable for a select ... from ... PARTITION(...).
It doesn't work to use something like
open cur for 'select ... from ... PARTITION(:1) where ...' using 'NDAY_20120301';So i have to create the cursor string with string functions each time i change the partition.
But that means, that the string changes each time.
Doesn't that prevent from re-use in library_cache?
best regards,
Frank

>
So i have to create the cursor string with string functions each time i change the partition.
But that means, that the string changes each time.
>
Yes it does.
Doesn't that prevent from re-use in library_cache?
>
Yes it does.
So why do you care? Unless you have large numbers of partitions what difference does it make? Bind variables are useful to keep Oracle from doing hard parses of queries that are basically the same but use different filter values. Such as an INSERT statement that uses different values FOR EACH ROW rather
You are just constructing the main (non-filter) part of the query one time and need a single value for the entire query regardless of how many rows - that isn't really a use case for bind variables and isn't going to provide any real benefit.
So the real question is why do you even care about something that wouldn't provide any benefit to you even if you could do it?
Looks like you just want to 'roll your own' parallel processing rather that use, and pay for, Oracle's parallel functionality.
If each partition uses its own tablespace you could filter on the FILE Id of the ROWIDs since the file number will be different for each tablespace and datafile.
1. Determine the list of file numbers for each partitions tablespace.
2. Use a WHERE DBMS_ROWID.ROWID_RELATIVE_FNO (ROWID) = :n filter (or use IN (:n1, :n2))to filter rows based on file number(s) for the partition you want
See DBMS_ROWID.ROWID_RELATIVE_FNO in the PL/SQL Packages and Types doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28419/d_rowid.htm#i1004259

Similar Messages

  • Procedure Problem - Open Cursor for SQL

    in my form I added a procedure. this is working fine in SQL but when I try to run through form it gives error.
    Code of Procedure:-
    PROCEDURE Proc_Purchase_all IS
    BEGIN
      declare
         v_sql varchar2(4000);
         v_user varchar2(30);
         v_sep varchar2(20);
         v_cur SYS_REFCURSOR;
       pur_rec    purchase%ROWTYPE;
       begin
         for u in (SELECT * FROM ALL_TABLES WHERE OWNER LIKE 'BMP%' and table_name ='PURCHASE') loop
           v_sql := v_sql || v_sep || 'SELECT * from '||u.owner||'.purchase';
          v_sep := ' UNION ALL ';
        end loop;
        open v_cur for v_sql;
      Loop
      Fetch v_cur into pur_rec;
      Exit when v_cur%NOTFOUND;
      --DBMS_OUTPUT.PUT_LINE (PUR_REC.S_CODE||' '||Pur_rec.s_name);
      End Loop;
        close v_cur;
    end;
    END;Error Line
    * open v_cur for v_sql;*
    Error is :-
    Encountered the symbol 'V_SQL' when expecting one of the following.
    select
    Encountered the symbol END when expecting one of the following.
    Begin function package pragma procedure external

    I changed my code ALSO Showing SAME error .
    SQL> Declare 
      2    v_sql varchar2(4000);
      3       v_user varchar2(30);
      4       v_sep varchar2(20);
      5    TYPE R_CURSOR IS REF CURSOR RETURN purchase%ROWTYPE;
      6       C_Pur R_CURSOR;
      7       ER C_pur%ROWTYPE;
      8       BEGIN
      9    for u in (SELECT * FROM ALL_TABLES WHERE OWNER LIKE 'BMP%' and table_name ='PURCHASE') loop
    10         v_sql := v_sql || v_sep || 'SELECT * from '||u.owner||'.purchase';
    11        v_sep := ' UNION ALL ';
    12      end loop;
    13   OPEN C_Pur FOR V_sql;
    14       LOOP
    15       FETCH C_Pur INTO ER;
    16      EXIT WHEN C_Pur%NOTFOUND;
    17    
    18      END LOOP;
    19      CLOSE C_Pur;
    20     END; 
    21  /
    OPEN C_Pur FOR V_sql;
    ERROR at line 13:
    ORA-06550: line 13, column 7:
    PLS-00455: cursor 'C_PUR' cannot be used in dynamic SQL OPEN statement
    ORA-06550: line 13, column 2:
    PL/SQL: Statement ignoredEdited by: Ahmed on Jan 13, 2011 1:58 AM

  • Open cursor for ...using...

    Hi all
    1 general question- can someone explain me how 'using keyword in 'open cursor for ...' statement works.
    Does it replace where clause and how?
    open cur_xx for qry_xxx using text_xxx
    where 'text_xxx' is going to be my codition in select statement
    Tahnks everyone

    http://oraclesvca2.oracle.com/docs/cd/B10501_01/appdev.920/a96624/13_elems35.htm

  • Having connected my new iPhone 6 to itunes and setting it up as normal... i transferred music to it as normal but when i open the music app and select a playlist it has a download cloud next to each track...

    After connecting my new iPhone 6 to iTunes, i transferred my music as i always have done. After opening the music app and selecting a playlist there is a download cloud next to each track... this is also the case with each podcast. Also once i reconnect the phone to iTunes go to add another playlist, at the top the "sync music" check tick has disappeared. when i re check that box again it says "Do you want to sync this iPhone all data will be erased"
    can anyone help at all?
    Thank you

    Hello henryscott3,
    Thanks for using Apple Support Communities.
    From your post it appears that you either have iTunes Match on your iPhone, or are seeing items that are available in iTunes in the Cloud and not on your device.  To learn more about both of these features, please see the articles below.
    iTunes Store: Subscribing to iTunes Match
    iCloud: Content everywhere
    Take care,
    Alex H.

  • Creating and selecting from a dynamic table

    Hi,
    Iam trying to create a table dynamically and selecting from it in same plsql block, but am getting "table doesnot exist" error. however if i just create a table dynamically and then do a select on it seperately it works..
    below is sample code for the same,
    working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    end;
    select count(*) from emp_bglr ...works and return me 0 rows
    Line: -----
    but when i include select in plsql block ..it throws "Table does not exists" error...(iam running below plsql block after dropping the created table)
    not working
    Line: -----
    DECLARE
    loc VARCHAR2(20):='bglr';
    l_cnt pls_integer;
    BEGIN
    -- create an employee information table
    EXECUTE IMMEDIATE
    'CREATE TABLE ' || 'emp_bglr' ||
    empno NUMBER(4) NOT NULL,
    ename VARCHAR2(10),
    job VARCHAR2(9),
    sal NUMBER(7,2),
    deptno NUMBER(2)
    --COMMIT;
    END;
    Select count(*) into l_cnt from emp_bglr;
    dbms_output.put_line('cnt is '||l_cnt);
    end;
    Line: -----

    Becuase your code is first checked for syntax/object existance during compilation and throws an error saying the table does not exist.
    Try this:
    SQL> ed
    Wrote file afiedt.buf
      1   DECLARE
      2   loc VARCHAR2(20):='bglr';
      3   l_cnt pls_integer;
      4   BEGIN
      5   -- create an employee information table
      6   EXECUTE IMMEDIATE 'CREATE TABLE emp_bglr(
      7   empno NUMBER(4) NOT NULL,
      8   ename VARCHAR2(10),
      9   job VARCHAR2(9),
    10   sal NUMBER(7,2),
    11   deptno NUMBER(2)
    12   )';
    14  Select count(*) into l_cnt from all_objects where object_name = 'EMP_BGLR';
    15  dbms_output.put_line('tab cnt is '||l_cnt);
    16  IF (l_cnt = 1) THEN
    17  l_cnt := 0;
    18  EXECUTE IMMEDIATE 'SELECT count(*) from apps.emp_bglr' into l_cnt;
    19  dbms_output.put_line('data cnt is '||l_cnt);
    20  END IF;
    21* end;
    SQL> /
    tab cnt is 1
    data cnt is 0
    PL/SQL procedure successfully completed.
    SQL> Edited by: AP on Aug 5, 2010 5:51 AM
    Edited by: AP on Aug 5, 2010 5:52 AM

  • Issuing certificates for user and clients from different forest/domain

    Hello,
    at first I would like to say that I have made some researches on this forum and in the Internet overall.
    I have AD Forest with ~10 sites all over the Europe, DFL and FFL is 2008 R2, right now we are migrating site by site from old domain (samba) to AD.
    Last time I have deployed PKI based on offline root CA and 2 Enterprise acting as 2-node Failover Cluster.
    Everything in my AD Forest is OK, I mean, autoenrollment works perfect for users and computers from my forest, 
    now I need to deploy a certificate (for test) to one web-based pbx server in samba domain, there are no trusts etc. Samba domain as well as AD Forest are working on the same network, with routeable subnets in each site, so there is no problem with connectivity,
    What are possible way to achieve this goal? I mean to issue cert to client from different forest, so that this client is able to validate it, validate certificate chain and renew it when needed?
    I have Installed and Configured CE Web Service and CE Policy Web Service. Now I have configured Enrollment Policies on my virtual machine (being part of different domain), I selected username/password authentication, I am able to request certificate, I can
    see all templates which I should see, but when I try to enroll I got an error:
    (translated from my language)A certification chain processed correctly, but one of the CA certificates is not trusted by the policy provider
    My root CA cert is added to trusted publishers for computer and user node as well.
    What could be wrong? If you have any ideas or questions, please share or ask. 
    Thank you in advance.

    Everything is clear, I have Certificate Enrollment Web Services installed and configured,
    problem is what i get from certutil - TCAInfo
    ================================================================
    CA Name: COMPANY-HATADCS002-ISSUING-CA
    Machine Name: COMPANYClustGenSvc
    DS Location: CN=COMPANY-HATADCS002-ISSUING-CA,CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,DC=COMPANY,DC=COM
    Cert DN: CN=COMPANY-HATADCS002-ISSUING-CA, DC=COMPANY, DC=COM
    CA Registry Validity Period: 2 Years -- 2016-03-04 12:20
     NotAfter: 2019-02-14 12:44
    Connecting to COMPANYClustGenSvc\COMPANY-HATADCS002-ISSUING-CA ...
    Server "COMPANY-HATADCS002-ISSUING-CA" ICertRequest2 interface is alive (1078ms)
      Enterprise Subordinate CA
    dwFlags = CA_VERIFY_FLAGS_NT_AUTH (0x10)
    dwFlags = CA_VERIFY_FLAGS_CONSOLE_TRACE (0x20000000)
    dwFlags = CA_VERIFY_FLAGS_DUMP_CHAIN (0x40000000)
    ChainFlags = CERT_CHAIN_REVOCATION_CHECK_CHAIN_EXCLUDE_ROOT (0x40000000)
    HCCE_LOCAL_MACHINE
    CERT_CHAIN_POLICY_NT_AUTH
    -------- CERT_CHAIN_CONTEXT --------
    ChainContext.dwInfoStatus = CERT_TRUST_HAS_PREFERRED_ISSUER (0x100)
    ChainContext.dwRevocationFreshnessTime: 18 Days, 4 Minutes, 1 Seconds
    SimpleChain.dwInfoStatus = CERT_TRUST_HAS_PREFERRED_ISSUER (0x100)
    SimpleChain.dwRevocationFreshnessTime: 18 Days, 4 Minutes, 1 Seconds
    CertContext[0][0]: dwInfoStatus=102 dwErrorStatus=0
      Issuer: CN=HATADCS001-COMPANY-ROOT-CA
      NotBefore: 2014-02-14 12:34
      NotAfter: 2019-02-14 12:44
      Subject: CN=COMPANY-HATADCS002-ISSUING-CA, DC=COMPANY, DC=COM
      Serial: 618f3506000000000002
      Template: SubCA
      9e1bea4ffa648e5fe3e9f8c4be3c604c49af04e9
      Element.dwInfoStatus = CERT_TRUST_HAS_KEY_MATCH_ISSUER (0x2)
      Element.dwInfoStatus = CERT_TRUST_HAS_PREFERRED_ISSUER (0x100)
        CRL 02:
        Issuer: CN=HATADCS001-COMPANY-ROOT-CA
        ThisUpdate: 2014-02-14 12:16
        NextUpdate: 2024-02-15 00:36
        d7bafb666702565cae940a389eaffef9c919f07a
      Issuance[0] = 1.2.3.4.1455.67.89.5 
    CertContext[0][1]: dwInfoStatus=10c dwErrorStatus=0
      Issuer: CN=HATADCS001-COMPANY-ROOT-CA
      NotBefore: 2014-02-14 11:55
      NotAfter: 2024-02-14 12:05
      Subject: CN=HATADCS001-COMPANY-ROOT-CA
      Serial: 18517ac8a4695aa74ec0c61b475426a8
      b19b85e0e145da17fc673dfe251b0e2a3aeb05e9
      Element.dwInfoStatus = CERT_TRUST_HAS_NAME_MATCH_ISSUER (0x4)
      Element.dwInfoStatus = CERT_TRUST_IS_SELF_SIGNED (0x8)
      Element.dwInfoStatus = CERT_TRUST_HAS_PREFERRED_ISSUER (0x100)
      Issuance[0] = 1.2.3.4.1455.67.89.5 
    Exclude leaf cert:
      5b309c67a8b47c50966088a4d701c8526072c9ac
    Full chain:
      413b91896ba541d252fc9801437dcfbb21d37d91
      Issuer: CN=HATADCS001-COMPANY-ROOT-CA
      NotBefore: 2014-02-14 12:34
      NotAfter: 2019-02-14 12:44
      Subject: CN=COMPANY-HATADCS002-ISSUING-CA, DC=COMPANY, DC=COM
      Serial: 618f3506000000000002
      Template: SubCA
      9e1bea4ffa648e5fe3e9f8c4be3c604c49af04e9
    A certification chain processed correctly, but one of the CA certificates is not trusted by the policy provider. 0x800b0112 (-2146762478 CERT_E_UNTRUSTEDCA)
    Supported Certificate Templates:
    Cert Type[0]: COMPANYOnlineResponder (COMPANY Online Responder) -- No Access!
    Cert Type[1]: COMPANYWebServer(SSL) (COMPANY WebServer (SSL))
    Cert Type[2]: COMPANYUser(Autoenrollment) (COMPANY User (Autoenrollment))
    Cert Type[3]: COMPANYKeyRecoveryAgents (COMPANY Key Recovery Agents)
    Cert Type[4]: COMPANYEnrollmentAgent(Computer) (COMPANY Enrollment Agent (Computer))
    Cert Type[5]: COMPANYEnrollmentAgent (COMPANY Enrollment Agent)
    Cert Type[6]: COMPANYComputer(Autoenrollment) (COMPANY Computer (Autoenrollment)) -- No Access!
    Validated Cert Types: 7
    ================================================================
    COMPANYClustGenSvc\COMPANY-HATADCS002-ISSUING-CA:
      Enterprise Subordinate CA
      A certification chain processed correctly, but one of the CA certificates is not trusted by the policy provider. 0x800b0112 (-2146762478 CERT_E_UNTRUSTEDCA)
      Online
    CertUtil: -TCAInfo command completed successfully.
    please put some light on it because it's driving me crazy :/
    Thanks in advance
    one remark: certutil -tcainfo performed on CA directly is 100% OK, no errors regarding 
    "A certification chain processed correctly, but one of the CA certificates is not trusted by the policy provider. 0x800b0112 (-2146762478 CERT_E_UNTRUSTEDCA)"

  • What is the defference between select single * from and select * from Where

    What is the defference between select single * from and select * from Where
    which is prefferable and best one.

    Hai,
    *Difference Between Select Single and Select * from table UpTo One Rows:*
    According to SAP Performance course the SELECT UP TO 1 ROWS is faster than SELECT SINGLE because you are not using all the primary key fields.
    select single is a construct designed to read database records with primary key. In the absence of the primary key, it might end up doing a sequential search, whereas the select up to 1 rows may assume that there is no primary key supplied and will try to find most suitable index.
    The best way to find out is through sql trace or runtime analysis.
    Use "select up to 1 rows" only if you are sure that all the records returned will have the same value for the field(s) you are interested in. If not, you will be reading only the first record which matches the criteria, but may be the second or the third record has the value you are looking for.
    The System test result showed that the variant Single * takes less time than Up to 1 rows as there is an additional level for COUNT STOP KEY for SELECT ENDSELECT UP TO 1 ROWS.
    The 'SELECT SINGLE' statement selects the first row in the database that it finds that fulfils the 'WHERE' clause If this results in multiple records then only the first one will be returned and therefore may not be unique.
    Mainly:  to read data from
    The 'SELECT .... UP TO 1 ROWS' statement is subtly different. The database selects all of the relevant records that are defined by the WHERE clause, applies any aggregate, ordering or grouping functions to them and then returns the first record of the result set.

  • Day of year bug - format date/time string and scan from string?

    I've noticed that the day of year returned by "Format Date/Time String.vi" starts with a value of 1 for Jan-1 while "Scan from String.vi" wants a 0 index.  Is this a bug or feature?  
    (I'm using Labview 2010 Service Pack 1)

    I think the best idea is to use seconds since for your arithmetic, because it is going to be the most consistent and robust solution. Knowing that a day has 86400 seconds is all that is needed and you won't run in possible inconsistencies with date time implementations caused by our anything but logic calender. I would hazard that the functionality of converting a timestamp into year and day of year and back is impossible to make consistent without sacrificing other possibly conflicting transformation in the Timestamp into String and Timestamp from String manipulations.
    "Seconds since" being the actual base unit in all LabVIEW timestamps, it is best to do any arithmetic on it in this base unit.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Multi color gradient for touch and selected color of spark mobile list

    multi color gradient for touch and selected color of spark mobile list
    how to get dat?

    or how about a bitmap as the background for the touch and selected color for the items in a list.

  • [svn:fx-trunk] 10876: Add support for drag-and-drop from Spark List to Spark List.

    Revision: 10876
    Author:   [email protected]
    Date:     2009-10-05 15:20:07 -0700 (Mon, 05 Oct 2009)
    Log Message:
    Add support for drag-and-drop from Spark List to Spark List.
    - List drop related handlers
    - LayoutBase APIs
    - VerticalLayout DND support
    Notes:
    - ListSkin is not final.
    - Drag-scrolling not yet implemented.
    QE notes: Only VerticalLayout works, HorizontalLayout still not implemented.
    Doc notes: None
    Bugs: None
    Reviewer: Deepa
    Tests run: checkintests
    Is noteworthy for integration: No
    Modified Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/components/List.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/VerticalLayout.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/supportClasses/LayoutBase.as
        flex/sdk/trunk/frameworks/projects/spark/src/spark/skins/spark/ListSkin.mxml
        flex/sdk/trunk/frameworks/spark-manifest.xml
    Added Paths:
        flex/sdk/trunk/frameworks/projects/spark/src/spark/layouts/supportClasses/DropLocation.as

    Whoops, disregard my question - I just read the spec that indicates drag and drop is scheduled for later work.
    David

  • I Have Elements13 and Apple Yosemite:  When I open the organizer, import and select folder it locks up.

    I am using PS Elements 13 with Apple Yosemite.   When I open the Organizer, import and select folder, it locks up.

    I Did what you said.  But when I click on Folders and try to open  a sub folder it still locks up. All of the media I have opened is not divided into folder. Is there any way to remove all of them and start over?   I have been using Bridge with PSE13 and it work great.  With Organizer I get missing files. My organizer PSE12 works ok on my laptop.

  • I can't log in on my mac book pro, when I open ask for name and password

    I can't log in on my mac book pro, when I open ask for name and password but it doesn't acept ...

    Which OS is installed on your Mac?

  • DTW template to import opening Balences for BP and Items

    Hi all,
    Is there any DTW template to import opening Balences for BP and Items
    Thanks & Regards,
    Naresh K

    Naresh,
    When you are talking about opening balances of BP and Items, I believe you are talking about Open AR and AP transactions and Opening Stock for Items.
    If this is the case then,
    For BP Opening Balance, you will need to import them as AR and AP Service Invoice using the template inside folder oInvoices and oPurchaseInvoices
    For Opening Stock, you will use template inside oStockTaking
    Suda

  • When I open a PDF document and select print, Adobe stops working and closes.  How do I correct this?

    When I open a PDF document and select print, Adobe stops working and closes.  How do I correct this?

    Hi tbytrzll,
    In order to help you better please let me know below mentioned information:
    - Operating system version and name.
    - Version of Adobe reader.
    - Have you tried to update the Reader and if you are trying to print using any other application what is the result.
    Have you tried any steps to resolve the issue.
    Regards,
    Ajlan Huda.

  • SELECT DISTINCT With OPEN cursor FOR

    Hello.
    I have the following procedure. All it does is open a cursor for an SQL string passed into it, and return the open cursor.
    PROCEDURE sp_execute_dynamic (hold_input_string IN CLOB,
    hold_cursor OUT hold_cursor_type) IS
    BEGIN
    OPEN hold_cursor FOR TO_CHAR(hold_input_string);
    END sp_execute_dynamic;
    It works fine except when I perform SELECT DISTINCT. I get the following error.
    SQL> declare
    2 TYPE hold_cursor_type IS REF CURSOR;
    3 hold_cursor hold_cursor_type;
    4 hold_object_name VARCHAR2(1024);
    5 hold_object_type VARCHAR2(1024);
    6 begin
    7 dynamic_sql_pkg.sp_execute_dynamic('select distinct object_name from user_objects where object_
    name in (''PLAN_TABLE'',''DBA_OBJECTS'')',hold_cursor);
    8 loop
    9 fetch hold_cursor into hold_object_name, hold_object_type;
    10 exit when hold_cursor%NOTFOUND;
    11 dbms_output.put_line('Object Name = '||hold_object_name||' Object Type = '||hold_object_type);
    12 end loop;
    13 end;
    14 /
    declare
    ERROR at line 1:
    ORA-01007: variable not in select list
    ORA-06512: at line 9
    It does the same thing with SELECT UNIQUE or SELECT with a GROUP BY. Can anyone tell me why this happens and what I could to to work around it?
    Thanks
    Chris

    see at line 7 you are selecting only one column and at line 9you are fetching into two variables
    7 dynamic_sql_pkg.sp_execute_dynamic('select distinct object_name from user_objects where object_
    name in (''PLAN_TABLE'',''DBA_OBJECTS'')',hold_cursor);
    8 loop
    9 fetch hold_cursor into hold_object_name, hold_object_type;
    HTH

Maybe you are looking for

  • Error ORA-00928: missing SELECT keyword

    Dear All, I have created package and also create function in it return me error.. ORA-00928: missing SELECT keyword.. Package Specification CREATE OR REPLACE PACKAGE PERSONLIZATION_NEW AS FUNCTION PO_ITEM_BRANCH (ITEM_ID NUMBER, BRANCH_CODE VARCHAR2)

  • Queues for RFC-Destination

    Hallo, must i assign a rfc-destination to a outbound queue? what happens when this is not done? Thanks in advance, Frank

  • Long List Of CFLOGIN Roles and Performance

    I have a very long list of Roles for the "roles" attribute of cflogin (around 60). Is this going to be a severe performance problem? Boybles

  • The variants are saved where?

    Hi all, I want to delete the variant I have created using alv(slis alv) and it is not available an option to delete the variant... So I want to delete it from db but where are they saved? Thanks in advance. Deniz.

  • Ovi Suite 3.0.0.284 not recognizing N8

    After I updating to new version of Ovi Suite, N8 device is not recognized. I did re-install/re-boot my windows 7 64-bit. No use.  I did try to revert back the Ovi install, funny thing is it is not allowing me to use the older version.  I doubt that N