Way to programmatically drop-and-create-tables?

Hi all,
I have a persistence unit which exists to provide lookup information to my application. It is populated by data that is available at runtime. It takes a long time to parse this data, and therefore my intention is to only parse it once at the deployment target. To do this, I have created a main method that does all the parsing, and I do not set the toplink.ddl-generation property in persistence.xml. This causes the application to fail if the database is not created.
However, this means that during the population stage, I must drop and create any existing tables. I had thought it would be possible to do this by obtaining an EntityManagerFactory which has a property map sent to it, containing the property toplink.ddl-generation set to drop-and-create-tables. But this does not work... the tables are not dropped (if they exist) and are not created (if the database is empty).
Is it possible to do the drop-and-create-tables programmatically using the JPA?
I may have another EntityManagerFactory open at the same time, which has been opened with the default options... would this be conflicting?

I don't think there is any easy way to generate the default tables once your have created the EntityManagerFactory. You could use the EclipseLink/TopLink schemaframework or TableCreator to create tables using a EclipseLink/TopLink DatabaseSession.
There is a DefaultTableGenerator in org.eclipse.persistence.tools.schemaframework, which may give you what you are looking for.
-- James : http://www.eclipselink.org

Similar Messages

  • How to create stored procedure to drop and create table

    Version: Oracle 10g
    I am trying to create a stored procedure that will drop and create a table based on a select statement. I can create the table but I can't drop it.
    CREATE OR REPLACE procedure EC_LOAD is
    begin
    INSERT INTO Sales_table
    (FSCL_WK,
    DIV,
    ACCT_TYPE)
    Select
    FSCL_WK,
    DIV,
    ACCT_TYPE
    from
    sales_revenue;
    end ecload;
    I need to drop Sales_table before inserting the values. How do i do this?

    Or with a drop:
    SQL> desc emp2
    ERROR:
    ORA-04043: object emp2 does not exist
    SQL>
    SQL> declare
      2    cnt      int := 0;
      3  begin
      4    select max (1)
      5      into cnt
      6      from user_tables
      7     where table_name = 'EMP2';
      8
      9    if cnt = 1
    10    then
    11      execute immediate 'drop table emp2';
    12    end if;
    13
    14    execute immediate 'create table emp2 as select * from emp';
    15  end;
    16  /
    PL/SQL procedure successfully completed.
    SQL>
    SQL> desc emp2
    Name                                      Null?    Type
    EMPNO                                              NUMBER(4)
    ENAME                                              VARCHAR2(10)
    JOB                                                VARCHAR2(9)
    MGR                                                NUMBER(4)
    HIREDATE                                           DATE
    SAL                                                NUMBER(7,2)
    COMM                                               NUMBER(7,2)
    DEPTNO                                             NUMBER(2)
    SQL>

  • Drop and recreate table in stored procedure

    Hi all
    When creating tables using Transact-SQL scripts, I have always preferred to drop the table if it exists and then create it explicitly using CREATE TABLE.  For two reasons:
    1) It does not matter if it is the first time the SP is run ie. if I create the table manually in the first instance and just use TRUNCATE TABLE it could fail if the table is deleted
    2) I have control over the data types of the table fields
    Just recently though I discovered the error that can occur when dropping and creating a table in the same batch (see link below)
    Microsoft Website
    This causes me a problem when dropping and creating tables in stored procedures, as I understand that a stored procedure is in itself a single batch?
    Can I avoid this error in a stored procedure whilst continuing to drop and create tables?  Or should I be taking a different approach?
    Coding best practice advice would be greatly appreciated.
    Thank you

    Thanks Ronen
    Please see my second post immediately before your reply.
    Given that I need to store the data output in a physical table for use in QlikView, would you suggest truncating the table each time the SP runs?  And then having a script that handles both dropping and creating the physical table, and also creating
    the SP?
    >> QlikView
    QlikView is an Israeli company, right?
    In any case I am not familiar with QlikView's application, therefore I can only give you general information, based on assumptions regarding the application, and facts regarding the SQL Server.
    >> for use in QlikView
    I assume that external application use specific database structure (table
    structure) and it is change only in rare situations (for example CMS interface might change the tables if and when a module s update/install). In this case there is no need to drop the table and recreate it and TRUNCATE is the solution.
    >> would you suggest truncating the table each time the SP runs
    I am sorry but i cant recommend on TRUNCATE a table each time you execute SP, without know the exact reason for this logic. It sound to me, at this point of time (with the information that we have), that this
    is very bad logic (application architecture). As I wrote above, basing your application on TRUNCATING the table each time mean that you have problems with multi users. Thins about 2 people that try to execute the same SP at almost the same time. Think about
    locking in the SQL Server and bad data (one truncate while the other already inserted the new data and get no rows, if there is no locking).
    But TRUNCATE is much better in this case probably then DROP and DELETE, since it is faster, and locking will be shorter (hopefully the application use the correct locking). There are other reasons why TRUNCATE is better, and other people already mentioned
    most of them, but time in this scenario might be critical.
    >> having a script that handles both dropping and creating the physical table, and also creating the SP?
    I do not undestand what is this second step. we said that you truncate the table, so why do you need to
    dropping and creating the physical table and who
    creating the SP?
    Are you meaning that the application create the tables and SP?
    There are lot of application that during installation create the database structure. is this what you mean?
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • Expdp fail and create table SYS_EXPORT_SCHEMA_20

    Hi Gurus
    I am using Oracle 10.2.0.3 in AIX env
    My database size is around 1600 GB. Sometime my expdp fail and create table like SYS_EXPORT_SCHEMA_20, SYS_EXPORT_SCHEMA_05. As I run expdp from system user , I notice that it create this type of table into system tablespace. It time it consume around 5gb space. Now my system tablespace size is 68 GB.
    Can I drop those table? If I drop these table then it create any problem? This is my production database.
    Regards
    Rabi

    user13134974 wrote:
    Hi Gurus
    I am using Oracle 10.2.0.3 in AIX env
    Regards
    RabiThose tables you were mentioning, SYS_EXPORT_SCHEMA_nn , are the data pump master tables used for data pump jobs;their purpose is to
    hold the info about the job details.
    Once the job has finished table should be droped, but in case of a job failure table remains so every new dp job must create new SYS_EXPORT_SCHEMA_nn table
    with the +1 nn iteration depending on the name of the last master table that was left due to the dp job failure.
    Cleaning those tables can be done with the dbms_datapump STOP_JOB Procedure, check the docs about the details :
    http://download.oracle.com/docs/cd/B12037_01/server.101/b10825/dp_export.htm
    You can also go visit youroracle support to see examples and instructions for cleaning your db from those dismised master tables,
    How To Cleanup Orphaned DataPump Jobs In DBA_DATAPUMP_JOBS ? [ID 336014.1]

  • What is the difference between the drop and create the index and rebuild index ?

    Hi All,
    what is the difference between drop and create index & rebuild index ? i think both are same...Please clarify if both are same or any difference...
    Thanks in Advance,
    rup

    Both are same. Rebuilding an index drops and re-creates the index. 
    Ref:
    SSMS - https://technet.microsoft.com/en-us/library/ms187874(v=sql.105).aspx
    TSQL - https://msdn.microsoft.com/en-us/library/ms188388.aspx
    I would suggest you to also refer one of the best index maintenance script as below:
    https://ola.hallengren.com/sql-server-index-and-statistics-maintenance.html

  • Basic anonymous block which drops and creates a table

    Version: 11.2.0.3
    I am fairly new to PL/SQL.
    We have a table named CHK_CNFG_DTL.
    I want to create a backup table for CHK_CNFG_DTL which will be named like CHK_CNFG_DTL_BKP_<timestamp> eg: CHK_CNFG_DTL_BKP_JULY_22_2013
    Creation of this backup table has to be automated so, I want to create an anonymous block which will first drop the existing backup table and then create a new backup table from the original table.
    The below code works fine. But the very first time when you run it , the loop won't iterate because there is no such table named CHK_CNFG_DTL_BKP%.
    declare
    v_stmt varchar2(1000);
    v_date date;
    begin
      for rec in
      (select * from user_tables where table_name like 'CHK_CNFG_DTL_BKP%' )
        loop
            begin
                execute immediate 'alter session set nls_date_format=''DD_MON_YYYY''';
                v_stmt := 'drop table '||rec.table_name|| ' purge';
                dbms_output.put_line(v_stmt);   ----- Drops Old backup table
                execute immediate v_stmt;
                select sysdate into v_date from dual;
                v_stmt := 'create table CHK_CNFG_DTL_BKP_'||to_date(v_date)||' as select * from CHK_CNFG_DTL';
                dbms_output.put_line('Creating Bkp table CHK_CNFG_DTL_BKP_'|| to_date(v_date) );
                dbms_output.put_line(v_stmt);
                execute immediate v_stmt;  --- Creates new Backup table
            exception
            when others
            then
            dbms_output.PUT_LINE (rec.table_name||'-'||sqlerrm);
            end;
        end loop;
    end;
    PL/SQL procedure successfully completed.
    -- Backup table not created.
    SQL> select table_name from user_Tables where table_name like 'CHK_CNFG_DTL%';
    TABLE_NAME
    CHK_CNFG_DTL
    Of course, this can fixed by creating a table like bleow before executing the anonymous block
    SQL> create table CHK_CNFG_DTL_BKP_JULY_22_2013 (x varchar2(37));
    Table created.
    and now the block will succesfully run like
    24  end;
    25  /
    drop table CHK_CNFG_DTL_BKP_JULY_22_2013 purge
    Creating Bkp table CHK_CNFG_DTL_BKP_22_JUL_2013
    create table CHK_CNFG_DTL_BKP_22_JUL_2013 as select * from CHK_CNFG_DTL
    PL/SQL procedure successfully completed.
    But this is going to production . We can't a table like CHK_CNFG_DTL_BKP_JULY_22_2013 without a proper business reason.
    How can I modify the above code so that if even if there is no such table like 'CHK_CNFG_DTL_BKP%' , it will proceed to create the backup table?

    Hi,
    Why won't you push the creation of the backup out of the loop ?
    declare
    v_stmt varchar2(1000);
    v_date date;
    begin
      for rec in
      (select * from user_tables where table_name like 'CHK_CNFG_DTL_BKP%' )
        loop
            begin
                execute immediate 'alter session set nls_date_format=''DD_MON_YYYY''';
                v_stmt := 'drop table '||rec.table_name|| ' purge';
                dbms_output.put_line(v_stmt);   ----- Drops Old backup table
                execute immediate v_stmt;
            exception
            when others
            then
            dbms_output.PUT_LINE (rec.table_name||'-'||sqlerrm);
            end;
        end loop;
                select sysdate into v_date from dual;
                v_stmt := 'create table CHK_CNFG_DTL_BKP_'||to_date(v_date)||' as select * from CHK_CNFG_DTL';
                dbms_output.put_line('Creating Bkp table CHK_CNFG_DTL_BKP_'|| to_date(v_date) );
                dbms_output.put_line(v_stmt);
                execute immediate v_stmt;  --- Creates new Backup table
    end;

  • Newbie: dropping and creating an identical user

    Oracle 10g
    Hi: I need to drop and recreate the user. This is what I had from my previous notes.
    1. how do I figure out what is the current default tablespace
    2. how do I figure out the current temporary tablespace?
    3. the table space and temporary table space get deleted when I drop the user. if Yes, Is it possible some other user's default tablespace and temporary tablespace is the same as well.
    Drop user systems cascade;
    CREATE USER SYSTEMS
      IDENTIFIED BY VALUES 'Test123'
      DEFAULT TABLESPACE USERS
      TEMPORARY TABLESPACE TEMPts1
      PROFILE DEFAULT
      ACCOUNT UNLOCK;
    /

    When I do a "SELECT DBMS_METADATA.GET_DDL('USER', 'Test123') || '/' DDL FROM DBA_USERS;", I get 34 rows. What does that mean. They all look identical.
    SELECT DBMS_METADATA.GET_DDL('USER', 'Test123') || '/' DDL FROM DBA_USERS;
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
       CREATE USER "Test123" IDENTIFIED BY VALUES 'F42EB0B11017F065'
          DEFAULT TABLESPACE "ARSYSTEM"
          TEMPORARY TABLESPACE "TEMP"
    34 rows selected.

  • Best way to give tablename in create table statement

    hi all,
    what's the best way to give table name while "create statement" in case of performance.. 
    for eg:
    create table tablename(id int,name varchar(20))
    a.) tablename
    b.) [tablename]
    c.) (tablename)
    d.) "tablename"
    pls its urgent..
    thanks in advance..
    lucky

    >b.) [tablename]
    As Naomi pointed it out, the above is dangerous because unintentionally special characters or space can be included and accepted by SQL Server.
    Once you introduce special characters in the table name, you have to use [....] forever.
    Related QUOTENAME:
    http://technet.microsoft.com/en-us/library/ms176114.aspx
    a is the best choice.
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012

  • Insert, select and create table as give different results

    Hi all
    I have a strange situation with this three cases:
    1) select statement: SELECT (...)
    2) insert statement with that same select as above: INSERT INTO SELECT (...)
    3) create table statement again with that same select: CREATE TABLE AS SELECT (...)
    Each of these cases produce different number of rows (first one 24, second 108 and third 58). What's more the data for second and third case doesn't have any sense with what they should return. The first case returns good results.
    One interesting thing is that select uses "UNION ALL" between 2 queries. When simple UNION is used, everything works fine and all three cases return 24 rows. Also if each query is run seaprately, they work fine.
    Anyone encountered something like this? (before i create an SR :)
    Database is 10.2.0.2 on AIX 5.3. It's a data warehouse.
    Edited by: dsmoljanovic on Dec 10, 2008 3:57 PM

    I understand UNION vs UNION ALL. But that doesn't change the fact that same SELECT should return same set of rows wether in INSERT, CREATE TABLE AS or a simple SELECT.
    DB version is 10.2.0.2.
    Here is the SQL:
    INSERT INTO TMP_TRADING_PROM_BM_OSTALO
    select
    5 AS VRSTA_PLANIRANJA_KLJUC, u1.UNOS_KLJUC, t1.TRADING_TIP_KLJUC, i1.IZVOR_KLJUC, m1.ITEMNAME AS MJESEC,
    l1.PLAN AS IZNOS, l1.TEKUA AS TEKUCA, l1.PROLA AS PROSLA, l1.PLANTEKUA_ AS IZNOS_TEKUCA, l1.PLANPROLA_ AS IZNOS_PROSLA, l1.TEKUAPROLA_ AS TEKUCA_PROSLA, l1.DATUM_UCITAVANJA
    from
    HR_SP_PLAN.L_12_ET_PROMETI_I_BRUTO_MARZA l1,
    select
    m1.ITEMIID, m1.ITEMNAME
    from
    HR_SP_PLAN.L_12_IT_4_MJESECI m1
    where
    UPPER (m1.ITEMNAME) NOT LIKE '%KVARTAL%' AND UPPER (m1.ITEMNAME) NOT LIKE '%GODINA%' AND UPPER (m1.ITEMNAME) NOT LIKE '%PROC%' and
    m1.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy')
    union all
    select -99, null from dual
    ) m1,
    HR_SP_PLAN.L_12_IT_5_SEKTORI l2,
    HR_SP_PLAN.L_12_IT_2_TIPOVI_OSTALO l3, HR_SP_PLAN.D_UNOS u1, HR_SP_PLAN.D_TRADING_TIP t1, HR_SP_PLAN.L_12_IT_1_PROMET_I_BM_OSTALO p1, HR_SP_PLAN.D_IZVOR i1
    where
    l1.ELIST = l2.ITEMIID and
    l2.ITEMNAME = u1.UNOS_NAZIV and u1.USER_KLJUC = 12 and l2.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    l1.DIMENSION_1_PROMET = p1.ITEMIID and
    p1.ITEMNAME = i1.IZVOR_NAZIV and i1.USER_KLJUC = 12 and p1.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    nvl(l1.DIMENSION_4_MJESEC , -99) = m1.ITEMIID and
    l1.DIMENSION_2_TIPOVI = l3.ITEMIID and
    l3.ITEMNAME = t1.TRADING_TIP_NAZIV and l3.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    l1.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    'PROC' = 'PLAN'
    union all
    select
    4 AS VRSTA_PLANIRANJA_KLJUC, u1.UNOS_KLJUC, t1.TRADING_TIP_KLJUC, i1.IZVOR_KLJUC, m1.ITEMNAME AS MJESEC,
    l1.PROCJENA AS IZNOS, l1.TEKUA AS TEKUCA, l1.PROLA AS PROSLA, l1.PROCJENATEKUA_ AS IZNOS_TEKUCA, l1.PROCJENAPROLA_ AS IZNOS_PROSLA, l1.TEKUAPROLA_ AS TEKUCA_PROSLA, l1.DATUM_UCITAVANJA
    from
    HR_SP_PLAN.L_13_ET_PROMETI_I_BRUTO_MARZA l1,
    select
    m1.ITEMIID, m1.ITEMNAME
    from
    HR_SP_PLAN.L_13_IT_4_MJESECI m1
    where
    UPPER (m1.ITEMNAME) NOT LIKE '%KVARTAL%' AND UPPER (m1.ITEMNAME) NOT LIKE '%GODINA%' AND UPPER (m1.ITEMNAME) NOT LIKE '%PROC%' and
    nvl(ceil(to_number(m1.ITEMNAME)/3), mod(4, 5)) = mod(4, 5) and m1.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy')
    union all
    select -99, null from dual
    ) m1,
    HR_SP_PLAN.L_13_IT_5_SEKTORI l2, HR_SP_PLAN.L_13_IT_2_TIPOVI_OSTALO l3,
    HR_SP_PLAN.D_UNOS u1, HR_SP_PLAN.D_TRADING_TIP t1,
    HR_SP_PLAN.L_13_IT_1_PROMET_I_BM_OSTALO p1, HR_SP_PLAN.D_IZVOR i1
    where
    l1.ELIST = l2.ITEMIID and
    l2.ITEMNAME = u1.UNOS_NAZIV and u1.USER_KLJUC = 13 and l2.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    l1.DIMENSION_1_PROMET = p1.ITEMIID and
    p1.ITEMNAME = i1.IZVOR_NAZIV and i1.USER_KLJUC = 13 and p1.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    nvl(l1.DIMENSION_4_MJESEC , -99) = m1.ITEMIID and
    l1.DIMENSION_2_TIPOVI = l3.ITEMIID and
    l3.ITEMNAME = t1.TRADING_TIP_NAZIV and l3.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    l1.DATUM_UCITAVANJA = to_date('24.11.2008','dd.mm.yyyy') and
    'PROC' = 'PROC';

  • Drop and create tablespace for users

    I am using Oracle 8i. I have created some users and, assigned the default & temporary tablespace to them.
    I would like to drop and re-create the temporary tablespace, should I assign the tablespace to users again?
    my script for creation of users:
    CREATE USER USER01 IDENTIFIED BY ABC
    DEFAULT TABLESPACE WEB_DATA
    TEMPORARY TABLESPACE TEMPORARY_DATA
    PROFILE DEFAULT;

    Hi,
    I would like to drop and re-create the temporary tablespace, should I assign the
    tablespace to users again?If temp tbs is not in usage, you can drop and recreate it without reassign. Users keep this one.
    Nicolas.

  • PLSQL and Create Table

    Hi
    I was wondering whether someone would help me with my first ever piece of PLSQL. I am trying to embed a create table as select statement into a PLSQL loop so that I can create a number of tables automatically. I am unclear as to whether this is possible or not, but my attempts so far has been unsucessful. My code so far is as follows:
    declare
    l_loops number :=1;
    begin
    loop
    if l_loops > 4 then
    exit;
    end if;
    create table l_loops as select year, month from caadatanum
    where month = l_loops;
    l_loops := l_loops +1;
    end loop;
    end;
    I am trying to use the loop to change the where condition
    as it loops through. The error message I get tells me
    that it doesn't expect the create statement so I am quite confused. Any help anyone could give me would be greatly appreciated.
    Thanks
    John

    Hi
    Firstly can I thanks you all for your help. The code no runs ok apart from one thing. It concerns the labelling of the table itself
    so 'create table '||l_loops||' as select ...
    errors with invalid table name presumably because it doesn't like giving tables numbers as names. I have tried
    'create table '||to_char(l_loops)||' as select .. but to no avail
    Is it possible to concatenate the l_loops number with a string somehow to get the statement to work ?
    create table mytable||'||l_loops||' doesn't work so I am not really sure what to do.
    Once again thanks
    John

  • Find/Change Item Numbers and create Table of Contents

    Hello! I need help to find all my item numbers and apply a paragraph style to it so I can use them to create a Table of Contents page.
    Sample item numbers
    #12345
    #12345-5
    #12345-20
    #12345-ABC
    #12345/N
    I tried entering #^?^?^?^?^? on the Find/Change box and but this will find exactly the 5 characters after the # sign. I wonder if you can find all characters starting with # and until the last characters.
    Once I find all the item numbers, how can I apply the paragraph style for only those characters after the # sign? Because I only want to show the item numbers without the # sign on the Table of contents/Index page.
    By the way, I have InDesign CS2 which have no GREP function Maybe I can do this without the GREP?
    I really appreciate any help. Thank you very much.

    You actually have two problems here. The first is to assign the paragraph style. For that you can use GREP.
    Find #\d+ and leave the change field blank, but in the change formatting pick the paragraph style. Stricly speaking you only need to find #\d or even just # because a paragraph style applies to an entire paragraph, so assigning it to any character inthe paragraph will assign it to the entire paragraph.
    Which is your second problem. The TOC is based on paragraph styles and will include all of the text in each paragraph (up to the character limit for a TOC entry, which I think is 256 characters). You can't make a TOC and only use some of the paragraph. For that you need to use an index, or you need to make hidden or non-pinting frames with only the exact text you want in the TOC and assign a unique style to those.
    It's also possible someone has written (or could write) a script that can find text strings that match a pattern such as your numers, assign a character style to them (you could actually do that part in the paragraph style by adding a nested GREP style), then making a list of the text strings along with the page number on which they appear -- almost the same as an index except it would be based on character style, not an index marker.

  • How to create one procedure which can drop and create materialized view

    Hi,
    I want to create one pl/sql procedure which can first drop materialized view CATEGORY_PK and after that create same materialized view CATEGORY_PK.
    programme is as follows:
    DROP MATERIALIZED VIEW CATEGORY_PK;
    CREATE MATERIALIZED VIEW CATEGORY_PK REFRESH FORCE WITH PRIMARY KEY AS
    SELECT cav1.ownerid AS categoryid, p.uuid AS productid ,p.domainID AS productdomainid,pav.stringvalue AS NAME
         ,pav2.stringvalue AS ID, pav3.stringvalue AS SHORT
    FROM product p, product_av pav, catalogcategory_av cav1, catalogcategory_av cav2,product_av pav2,product_av pav3
    WHERE
    cav1.NAME = 'PRODUCT_BINDING_ATTRIBUTE' AND
    cav2.NAME = 'PRODUCT_BINDING_VALUE' AND
    cav1.ownerid = cav2.ownerid AND
    p.uuid = pav.ownerid AND
              p.uuid = pav2.ownerid AND
              p.uuid = pav3.ownerid AND
    pav.NAME = cav1.stringvalue AND
              pav2.NAME = cav1.stringvalue AND
              pav2.NAME = cav1.stringvalue AND
    pav.stringvalue = cav2.stringvalue AND
              pav2.stringvalue = cav2.stringvalue AND
              pav3.stringvalue = cav2.stringvalue
    UNION
    SELECT catalogcategoryid AS categoryid, productid, repdomainid AS productdomainid,pav1.stringvalue AS NAME
         ,pav2.stringvalue AS ID, pav3.stringvalue AS SHORT
    FROM productcategoryassignment ,product_av pav1,product_av pav2,product_av pav3
         WHERE pav1.ownerid=productid
         AND pav2.ownerid=productid
         AND pav3.ownerid=productid
         AND pav1.NAME='name'
         AND pav2.NAME='productID'
         AND pav3.NAME='shortDescription';

    user498566 wrote:
    I want to create one pl/sql procedure which can first drop materialized view CATEGORY_PK and after that create same materialized view CATEGORY_PK.That sounds like a waste of time and resources. What do you hope to achieve by this? A refresh? If so, a simple refresh of the old materialized view will do.
    If you truly want to continue this road, you'll have to use the EXECUTE IMMEDIATE command to execute DDL commands from within PL/SQL.
    Regards,
    Rob.

  • Best way to link GL and AP tables in R12

    In R11 I can link the gl_je_lines and the PO tables via the ap_invoice_distributions_all, In R12 I apparently need to add an extra step and link the GL tables to the XLA table then the ap_invoice_distributions_all. I have seen many ways to do this on line, are there any guidelines or advice on the best practice most efficient way of performing this join?

    >
    are there any guidelines or advice on the best practice most efficient way of performing this join?
    >
    based on business requirements
    btw used
    invoice->sla->gl for r12
    if you need track for invoice
    Re: how to track invoices transfered to gl - Re: how to track invoices transfered to gl

  • Best way to downsize images and create timelapse/stop motion sequences of various durations

    I`m wanting to know should I use compressor to add image sequence and downsize images, or aperture to downsize a folder of images, (i`m talking 4000 to 10,000 photos in one folder). What app is faster and more stable (reliable in converting the whole batch without crashing) ?
    I had been doing some mix of stop motion and timelapse and wanted to downsize the images, then take them into FCP.X to create a video,
    from there I would be adjusting the frame duration for different groups of photos in the one time line, some groups will have slower frame durations, others faster frame durations depending on the effect I want.
    Is FCPX the best choice to do this in? Or should I select the photos I want at a particular frame duration and process/output them in another software first.
    Then take them into FCPX to put with other sequences of footage.
    Another related question, Compressor, Ive applied a destination and setting by dragging them from the templates, but the following message comes up for the video when I click "submit.."
    - Each target assigned to a job must have a setting and destination.
    the source is small, for smallest quicktime output, the destination is users movies folder...
    any suggestion would be great,
    thanks,

    If I want to keep the original image file size I would choose a different location? (to make a copy at lower resolution). (some images I want for printing at A2 but haven`t the time to siphon those out yet).
    Thanks for the request I hope it is moved (will I be notified via email?)
    regards my 2nd question, i`ll clarify that a bit more for the FCPx forum,
    ...Compressor, Ive applied a destination and setting by dragging them from the templates, but the following message comes up for the video when I click "submit.."
    - Each target assigned to a job must have a setting and destination.
    I already set the source to small, for smallest quicktime output, the destination is "users movies folder"...both were dragged up into the fields required near the video thumbnail.
    Not sure what to do from there it wont let me proceed.

Maybe you are looking for

  • How to load XML files ? HELP!

    Hi folks. We have an old Oracle database 7.3.. So we need to load XML files into its tables. As we understand Oracle Loader doesn't help us. Is the way to load that files? Thanks in advance Alex

  • How do I edit suggestions Firefox makes to automatically fill in a field?

    When I attempt to fill in a form, as I type,a Firefox will offer suggestions as to what to fill in. For example, the web form asks for a date. I want to enter 5/25/2011. As I have filled out this form before, Firefox offers suggestions of 5/25/2009,

  • Help a Complete Beginner Improve Quality of Exported Videos

    Hello all, I'm completely new to Adobe Premiere Pro and I am experiencing lots of difficulty with the quality of my exported videos. My source material is a 720 x 480 .AVI (Note: I intend to export in a format like .WMV or .MOV) that was recorded wit

  • IBook with Dell Monitor

    I'm thinking of getting a Dell 2005FPW monitor. According to Dell, it a system needs to support WSXGA+ resolution (1680 x 1050)to maximize performance out of the monitor. Can an iBook do this? Thanks.

  • Dynamical declaration of SELECT-OPTIONS / RANGE possible

    Hi fellow programmers, does anybody know whether there is a way to declare a SELECT-OPTION respectively a RANGE dynamically during runtime? I have both the name of the range to be created and the DDIC-referencefield stored in variables. Thanks in adv