How to query the partition of plsql table

Hello
I have a table tab1 and tab2 partition created on it.

I want to write a plsql program to check if a value is present in my default partition. Here I want to hard-code the value of the partition in my sql because this value is coming as INPUT in my procedure when I try it doesn't work. can someone help me on this pls...

For example.
procedure p1 (l_part_string varchar2)
is
number of l_cnt_part;
Start
Select count (1)
in l_cnt_part
tab1 partition (l_part_string).

dbms_output.put_line ('l_cnt_part -' | l_cnt_part);

Select count (1)
in l_cnt_part
tab2 partition (l_part_string).
dbms_output.put_line ('l_cnt_part -' | l_cnt_part);

end;

rocedure p1 (l_part_string varchar2)
is
number of l_cnt_part;
Start
immediate execution
' Select count (1).
tab1 partition ('| l_part_string |') '
in l_cnt_part;

dbms_output.put_line ('l_cnt_part -' | l_cnt_part);

immediate execution
' Select count (1).
tab2 partition ('| l_part_string |') '
in l_cnt_part;

dbms_output.put_line ('l_cnt_part -' | l_cnt_part);
end;
/

-----------
Sybrand Bakker
Senior Oracle DBA

end;

Tags: Database

Similar Questions

  • How to configure the partition table for SSD?

    Drive: 32 GB SSD

    I accidentally delete without backup partition table information and would like to know how to put the partition table, I can access the tools of partition table, but do not know how to define.

    Does anyone have any suggestions?

    Thanks in advance for your suggestions

    Hello

    Thanks for posting your query in Microsoft Community.

    The SSD could be seen in the disk management window, and you could name and set up as another hard drive internal. To create a partition or volume on a hard disk, you must be logged in as an administrator, and there must be unallocated disk space or free space in an extended hard disk partition. To repartition your hard drive, please consult the following link and check if it helps.

    I can I repartition my hard disk?

    Additional information:

    Create a new Partition on a hard disk in Windows 7

    Hope this information is useful. Let us know if you need more help, we will be happy to help you.

  • query the partition tables

    Hi all

    I want to query the partition tables that are over 1 GB in size?

    How can I ask questions?

    Salvation;

    You can also try with dba_tab_partitions view

    Respect of
    HELIOS

  • How to remove the partition from disk on Tecra?

    Any ideas how to remove the partition that Toshiba create by default when the operating system is installed?

    Hello

    Which partition do you mean? And what laptop do you have?
    I got my satellite repeatedly and didn t see any partition made by Toshiba.

    Of course, I read in this forum that some owners of Qosmio with Qosmio player have this partition that has been specially designed for the Qosmio player.

    So, what do you mean exactly?

    PS: If you want to remove a single partition if you do to the title of the disk management in the computer management option.

  • How to reduce the height of a table which is with PanelCollection and pc will find panelbox and pb is panelgridlayout and pgl is at the center of tableFirstTemplate?

    Mr President.

    How to reduce the height of a table which is with PanelCollection and pc will find panelbox and pb is panelgridlayout and pgl is at the center of tableFirstTemplate?

    Concerning

    Normally at the height of the table control you need property autoheightRows -1 and then set height in the table like this inlinestyle

    height: 300px;

  • How to get the title of a table with FDK?

    How to get the title of a table with ad FDK C++?

    I did people. I get objects table paragraph and later the textual elements for each of them.

  • How to use the Type of Oracle Table values in the Select statement.

    Hello

    I get the initial set of values in the Table of Type Records of the Oracle and want to use the list of values in the Select statement.

    For example, try something like the following:

    TYPE t_record () IS RENDERING
    ID TABLEA.ID%type,
    NO TABLEA.NO%type

    );
    v_record t_record;
    T_table TYPE IS the v_record TABLE % TYPE;
    v_table t_table;

    -Code to fill the values of v_table here.

    SELECT ID, NO, COLLECT in BULK IN < some other table variabes here > FROM TABLEA
    WHERE ID IN (i) v_table USER.USER;

    I want to know how to use the Type of Oracle Table values in the Select statement.

    Something like this:

    create or replace type t_record as  object (
    id number,
    no number
    )
    /
    
    CREATE or replace type t_table AS TABLE OF t_record;
    /
    
    set serveroutput on
    declare
    
      v_table t_table := t_table();
      v_t1 t_table := t_table();
    
    begin
    
      v_table.extend(1);
      v_table(1).ID := 1;
      v_table(1).No := 10;
    
      v_table.extend(1);
      v_table(2).ID := 2;
      v_table(2).ID := 20;
    
      SELEC t_record (ID,NO) BULK COLLECT INTO v_t1
      from TableA
      FROM TABLEA
      WHERE ID IN (select t.ID from table(v_Table) t);
    
      for i in 1..v_t1.count loop
        dbms_output.put_line(v_t1(i).ID);
        dbms_output.put_line(v_t1(i).No);
      end loop;
    end;
    /
    

    No test!

    P;

    Published by: bluefrog on March 5, 2010 17:08

  • Help, how to query the database using pagination

    Hello

    How to query the database using paging for large data.

    any API for this?

    Thank you in advance!

    Hello

    You can specify XmlQueryContext::Lazy as the type of assessment and only call XmlResults:: next() comes as many times as you need.

    John

  • How to create the partition on a column in a table on a daily basis

    Hi all
    I wrote a query that does not, I have a column of varchar type, and I want to create the partition of the table on that column based daily interval. but ist is in error...

    my query is...

    create the table user_detail
    (username varchar2 (50))
    The user ID number,
    country varchar2 (25).
    accupation varchar2 (100),
    company varchar2 (100),
    joindate varchar2 (14))
    partition by range (joindate)
    INTERVAL (NUMTOYMINTERVAL (1, 'DAY'))
    (PARTITION newone VALUES LESS THAN (to_date (April 13, 19 ', 'aa-mm-dd')));


    error is:

    Error from the 1 in the command line:
    create the table user_detail
    (username varchar2 (50))
    The user ID number,
    country varchar2 (25).
    accupation varchar2 (100),
    company varchar2 (100),
    joindate varchar2 (14))
    partition by range (joindate)
    INTERVAL (NUMTOYMINTERVAL (1, 'DAY'))
    (PARTITION newone VALUES LESS THAN (to_date (April 13, 19 ', 'aa-mm-dd')))
    Error in the command line: 1 column: 0
    Error report:
    SQL error: ORA-14751: type of invalid data for the partitioning column of a partitioned table interval


    Can I create partition on the varchar data type?

    On ORA11gR1 it works:

    --virtual column
    CREATE TABLE TEST(joindate VARCHAR2(14), part_joindate AS (to_date(joindate,'dd.mm.yyyy'))) partition by range (part_joindate)
    INTERVAL(NUMTOYMINTERVAL(1, 'YEAR'))
    (PARTITION newone VALUES LESS THAN (to_date('2013-04-19', 'yyyy-mm-dd')))
    ;
    
    INSERT INTO TEST(joindate) VALUES('19.04.2013');
    SELECT * FROM TEST;
    
    DROP TABLE TEST;
    --aux column
    CREATE TABLE TEST(joindate VARCHAR2(14), part_joindate AS (to_date(joindate,'dd.mm.yyyy'))) partition by range (part_joindate)
    INTERVAL(NUMTOYMINTERVAL(1, 'YEAR'))
    (PARTITION newone VALUES LESS THAN (to_date('2013-04-19', 'yyyy-mm-dd')))
    ;
    
    INSERT INTO TEST(joindate) VALUES('19.04.2013');
    SELECT * FROM TEST;
    
    DROP TABLE TEST;
    

    Published by: spajdy on April 19, 2013 14:58

  • How to use the partition instead of group by?

    Hello

    I'm unable to use the partition by clause in the following cases,

    the column with null values other_number contains 10 records in 'une_table '.
    5 records where the date 01/11/2009, item_code = 1
    5 records where the date 01/10/2009, item_code = 2

    This query returns all of the records of 10, (which assume back 2)
    SELECT count (a.anumber) on (partition TO_char(a.some_date,'MM'), a.item_code) AS i_count, a.item_code,.
    TO_char (a.some_date, 'MM')
    Of une_table
    WHERE to_char (a.some_date, 'yyyy') = 2009
    AND a.other_number IS NULL


    Works great if I wrote like this,
    SELECT count (a.anumber) AS i_count, a.item_code,.
    TO_char (a.some_date, 'MM')
    Of une_table
    WHERE to_char (a.some_date, 'yyyy') = 2009
    AND a.other_number IS NULL
    TO_char(a.some_date,'MM') group, a.item_code

    How to use partition of in this case?

    Hello

    Almost all of the aggregate functions (the ones you use in a GROUP BY query) have analytical equivalents.
    You seem to have already discovered that, regardless of the values returned by
    a comprehensive funcition using ' GROUP BY x, y, z "can also be found
    an analytical function by using "PARTITION BY x, y, z".

    Aggregate queries to collapse the result set.
    The COUNT aggregate function:

    SELECT    deptno
    ,         COUNT (*)   AS cnt
    FROM       scott.emp
    GROUP BY  deptno
    ;
    

    indicates how many 14 employees are in each of 3 departments.
    The fact the analytical COUNT function:

    SELECT    deptno
    ,         COUNT (*) OVER (PARTITION BY deptno)   AS cnt
    FROM       scott.emp
    ;
    

    but the first query produces 3 production lines, the second query produced 14.
    You could get 3 rows of output using the analytical function and SELECT SEPARATE , but it is inefficient.

    Which should you use? As with many other things, the answer depends on what data you have and what results you want from this data.
    If you want has collapsed of results (one line per group), it is an indication of striong you'll want features global, not analytical.
    If you want a row of output for each row in the table, it is a strong indication that you'll want to analytical functions.

    If you have a specific question, ask. Post some sample data and the results desired from this data, as Rob has said.

    There is another important difference between the aggreate and analytical functions: analytic functions can easily be restricted to a window , or a subset DataSet. It's something like a WHERE clause and a WHERE clause applies to the entire request: a condition of wondowing applies only to a single line.
    If you need calculate a SUM of lines with a previous of this line order_date , or an average of last 5 lines, then proabably you want to use the analytical function.

  • How to use the PARTITION of EXCHANGE IKM

    Hi all

    I use IKM EXCHANGE PARTITION to load lots of data from a table that is not partitioned for a partitioned table.

    Is there any step that I have to follow?

    I put the source table in the source area and the target in the area.

    I select the IKM and run the task.

    Cattura.JPG

    ODI-1228: Prova_exch (Integrazione) of the task fails when the target SASSYS ORACLE connection.
    Caused by: java.sql.SQLException: ORA-14006: invalid partition name
    ORA-06512: at line 1

    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:462)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:931)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:481)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:205)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:548)
    at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:217)
    at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1115)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1488)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3769)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3904)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1512)
    at com.sunopsis.sql.SnpsQuery.executeUpdate(SnpsQuery.java:712)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.executeUpdate(SnpSessTaskSql.java:3470)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.execStdOrders(SnpSessTaskSql.java:1877)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTaskTrt(SnpSessTaskSql.java:3056)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSqlI.treatTaskTrt(SnpSessTaskSqlI.java:68)
    at com.sunopsis.dwg.dbobj.SnpSessTaskSql.treatTask(SnpSessTaskSql.java:2623)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatAttachedTasks(SnpSessStep.java:577)
    at com.sunopsis.dwg.dbobj.SnpSessStep.treatSessStep(SnpSessStep.java:468)
    at com.sunopsis.dwg.dbobj.SnpSession.treatSession(SnpSession.java:2128)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ 2.doAction(StartSessRequestProcessor.java:366)
    at oracle.odi.core.persistence.dwgobject.DwgObjectTemplate.execute(DwgObjectTemplate.java:216)
    at oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.doProcessStartSessTask(StartSessRequestProcessor.java:300)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor.access$ 0 (StartSessRequestProcessor.java:292)
    to oracle.odi.runtime.agent.processor.impl.StartSessRequestProcessor$ StartSessTask.doExecute (StartSessRequestProcessor.java:855)
    at oracle.odi.runtime.agent.processor.task.AgentTask.execute(AgentTask.java:126)
    to oracle.odi.runtime.agent.support.DefaultAgentTaskExecutor$ 2.run(DefaultAgentTaskExecutor.java:82)
    at java.lang.Thread.run(Thread.java:745)

    This is the code:

    Start

    run immediately ' ALTER TABLE SASKPI. TEST_MILA SWAP WITH SASKPI TABLE PARTITION. I HAVE _TEST_MILA $ WITH VALIDATION';

    end;

    It's like ODI is unable to get the name of the Partition

    The following article describes how to properly use the KM

    http://www.Ateam-Oracle.com/using-Oracle-partition-Exchange-with-Oracle-data-integrator-ODI/

  • How to extract the indictments of several tables

    Hi all

    I have 10 tables that all have the same columns, but different data in each column. I would like to get a count of how many fields is not null for a specific column in each table. I tried to figure this out for hours without success. We use oracle 10g and I use Toad to write my SQL.

    I will try to give you an example.

    The SQL below returns the numbers for one of the tables. I would like to get the counts for each table with a single query.

    SELECT COUNT(*) FROM RRM_HOME_EQ
     WHERE unit_id is not null
     AND   account_off is not null;
    

    Thanks in advance

    OR

    Try as below...

    Select (select count (*) from emp where deptno = 10) tab1, tab2 (select count (*) of the Department)

    Double;

    TAB1 TAB2

    ---------- ----------

    3          7

    Hope this helps... !

  • How to query the name summary of custom line of Section header information

    I need a query which can help me to retrieve the contents of a header line custom section information name.  We have a couple of tables Denorm when data are denormalized, the field row_name is only show the name of alias denormalized.  We would like to be able to draw the contents of the line header information section name?  How can we use the alias denorm name and join another table to find the associated summary name?

    The following query returns the name of the line as well as the line name denorm, for a custom section, where we specify the section custom denorm table. Deserve you this to do otherwise, it depends on how you want to retrieve information. Is that what you are looking for?

    SELECT ml. Name [rowName], ml.langID, dr.NAME [denormRowName], Dr. FKROWTEMPLATE, dt. GENERATED_TABLE_NAME

    OF DENORM_CS_ROW dr

    DENORM_CS_TABLE dt on Dr. FK_DENORM_TABLE_ID = dt.ID inner join

    commonextendedattributeml ml on Dr. FKROWTEMPLATE = ml.fkOwner inner join

    where dt.NAME = 'myDenormTableName. '

  • Problem with trunacating the partitions of a table.

    Hi all

    I have a table partitioned, called temp1_list_cmpgn_hist_dtl, and it is partitioned by month (campaign_start_date).

    I tried, queries
    TRUNCATE TABLE temp1_list_cmpgn_hist_dtl PARTITION t_list_cmpgn_201006
    TRUNCATE TABLE temp1_list_cmpgn_hist_dtl PARTITION t_list_cmpgn_201006 REUSE STORAGE

    but it throws me the following error message:
    SQL error: ORA-03291: Invalid truncate option - missing keyword STORAGE
    03291 00000 - "invalid truncate option - missing keyword STORAGE"
    * Cause: Keyword STORAGE planned
    * Action: Specify DROP STORAGE or reuse STORAGE

    Also, I'll try to find the nom_partition for the 'temp1_list_cmpgn_hist_dtl' table, but it shows not all partitions, although there are partitions.
    I tried the query,
    SELECT Nom_partition from user_tab_partitions WHERE table_name = 'temp1_list_cmpgn_hist_dtl '.

    THX,
    Rod.

    You cannot truncate individual partitions of a table. The closest you could come would be to do a swap partition with an empty table created to match your partition.

    Also, I'll try to find the nom_partition for the 'temp1_list_cmpgn_hist_dtl' table, but it shows not all partitions, although there are partitions.
    I tried the query,
    SELECT Nom_partition from user_tab_partitions WHERE table_name = 'temp1_list_cmpgn_hist_dtl '.

    All the names of objects in the Oracle database, by default, are stored in uppercase letters, so make sure the upper case of the table name.

    John

  • How to join the partitions in an external hard drive?

    I have an external hard drive. Empty, but divided into two partitions. (I see two drives)

    How can I meet two partitions?

    I tried using the disk utilities, but I got the message that I couldn't change the partitions.

    (In Dutch: "Deze kan niet worden gewijzigd partitie"; in English, something like: "this partition is not editable")

    What is the procedure that you follow?

    1. Select the disk in the sidebar that contains the partition you want to enlarge, then click on the Partition.

    2. in the list of available Partition, select the partition in the partition you want to enlarge, then click on remove.

    The partition is immediately erased, leaving the space it occupied available.

    3. resize the partition by doing one of the following:

    • Drag the separators between the partitions in the list of available Partition.

    • Select a partition in the Partition layout list, and then enter a value in the size field.

    4. click on apply.

    Disk utility (Yosemite): partition a drive

Maybe you are looking for

  • How can I get the same results from Google Images like in internet Explorer

    If I search Google Images in IE8, I get a list of result pages with a fixed number of items per page. These thumbnail images download quickly, and under each image there is useful information about the content of the image and its source. Images on t

  • 360 can not understand me

    After the update my watch is unable to understand my language (Danish) Please help me. or I'm going to buy a Apple Watch, and I don't want to do that, because I am very satisfied with the 360.

  • My file began to just show the share icon in the lower left corner. How can I remove it?

    There is a small box with 2 heads in the lower left corner of all my icons, photos, docs, exc. HELP? There is a small box with 2 heads in the lower left corner of all my icons, photos, docs, exc. HELP?http://ImageShack.us/photo/my-images/703/desktopV

  • Cannot connect to PayPal using the overdraft facility

    Whenever I try to pay for something (online shopping) by using the PayPal cheque made on another Web site, it will not open a session. I enter my email address and password and just get an error message saying wrong password or e-mail address, even t

  • OfficeJet Pro 8100 Duplex printing problem

    When I try to print double-sided, the second page prints upside down.  I tried to fix with the changes made to the different settings, but have not been able to find a way to fix this problem.  Any help would be appreciated. I use Windows 7 and the p