Select count into versus create table as in functions/procedures

I am working on a dynamic PL/SQL script that will count the number of records in a remote database
based on certain criteria and then if the number is "acceptable" will create a table in the connecting
database with those records.
My where clauses are supposed to be the same but I am presented with the problem, when I run the
first code ... select in to rowcount I get 122000 records, when I later do the create table as
with the same whereclause code, I get 77 records. So now I am attempting to validate that the two
where clauses are the same ... you'd think it would be obvious, but it's not.
My first operation does a select count(*) into rowcount with the where clause behind it.
The second operations creates a "sql command literal' that gets executed and returns the less value.
I build it like testscript := 'create table '||tablename ||'as select * from '||remotetablename||'@'||linkname;
testwhere := ' xxxxxxx'
then I do an execute immediate teststring ||' ' testwhere; which works but gives me 77 rows in the table.
Since I believe my where clause might be different, how can I run the first operation ... select count into rowcount
as a normal SQL statement in the script...
When I attempt to just run it I get -- PLS-00428: an into clause expected in this select statement......
I will provide the source code in my next posting. Working to get it moved to this system.. Once you see it you'll understand
why I don't think, it's the same, but I need a way to run them exactly as they are written to understand the different results.
so How can I make the select count (*) into rowcount from .... work just like a normal select

Here is first part of the procedure --- I get returned value of 122000 records ....
SELECT COUNT (*)
               INTO ROWCOUNT
               FROM A_K_A_D_TBL@FCA08_INGRES
               WHERE (( "a_" = '1' OR "a_" = '6' ) AND
                         ( "d_t" <> '3' OR "k_c_s" = 'Y' ) AND
                         "d_d" < DATECUTOFFDATE AND
                    "k_c_d" < DATECUTOFFDATE )OR
(( "a_" = 4 OR "a_" = 7 ) AND
                         ( "d_t" <> '3' OR
"k_c_s" = 'Y' OR
"r_t" = '0' OR
                    "r_t" = '2' OR
               "r_t" = '3' ) AND
                    "d_d" < DATECUTOFFDATE AND
                    "k_c_d" < DATECUTOFFDATE AND
                    "r_d" < DATECUTOFFDATE AND
                    "s_d" < DATECUTOFFDATE);
then I attempt to duplicate it for string literals.... when this runs ... I get only 77 records. So that makes me think that my strings are not
done properly.
So I want to try to run the first sql itself ... but then I get the errors about needing select into ..... etc..
               TESTWHERE := q'[WHERE (( "a_" = '1' OR "a_" = '6' ) AND ( "d_t" <> '3' OR "k_c_s" = 'Y' )]'||
          q'[ AND "d_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                         q'[ AND "k_c_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[')]'||
                         q'[ OR (( "a_" = 4 OR "a_" = 7 )]'||
                         q'[ AND ( "d_t" <> '3' OR "k_c_s" = 'Y' OR "r_t" = '0' OR "r_t" = '2' OR "r_t" = '3' )]'||
                         q'[ AND "d_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                         q'[ AND "k_c_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                         q'[ AND "r_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[']'||
                         q'[ AND "s_d" < DATE ']'||TO_CHAR(DATECUTOFFDATE,'YYYY-MM-DD')||q'[')]';
                    TESTSTRING := 'CREATE TABLE '||UCASEXTABLENAMETEMP||' AS SELECT * FROM '||UCASEXTABLENAME||'@'||XLINKNAME;
                    DBMS_OUTPUT.PUT_LINE(TESTSTRING);
                    DBMS_OUTPUT.PUT_LINE(TESTWHERE);
                    EXECUTE IMMEDIATE TESTSTRING||' '||TESTWHERE;

Similar Messages

  • Select data into deep internal table

    Dear Experts.
    I created a dynamiv deep internal table.
    while selecting data , into the internal table it is giving a dump. saying that deep structure.
    SELECT OBJTY OBJID ARBPL WERKS from crhd
    INTO CORRESPONDING FIELDS OF TABLE <f_tab>
    where WERKS = pr_werks.
    I used the field catalog also.even same error is comming.
    how to get data into deep internal table by select statement.
    Please help me,
    Regards,
    Rahul

    HI,
    Try creating dynamic internal table like:
    Field-symbols: <dyn_table> type standard table,
                                 <dyn_wa>   ,
                                 <dyn_field>.
      Data: dy_table      type ref to data,
                ifc                  type lvc_t_fcat ,
                xfc                 type lvc_s_fcat ,
               Count             type i          ,
               Count1           type i          ,
               Index              type i          ,
               dy_line           type ref to data.
             Data counter   type i.
      Data: line   type string       ,
                List    like table of line.
      Data: idetails           type abap_compdescr_tab,
                   xdetails           type abap_compdescr    .
      Data: ref_table_des type ref to cl_abap_structdescr.
    *Looping at field cat internal table to populate another field cat to be passed
    * In method used below for creating final dynamic internal table
      Loop at fieldcat into fieldcat1.
        Clear xfc.
           Xfc-fieldname            = fieldcat1-fieldname.
           Xfc-datatype              = fieldcat1-datatype.
           Xfc-intlen                    = fieldcat1-intlen.
         Append xfc            to ifc.
      endloop.
    Clear fieldcat1.
    *Method called to create dynamic internal table on the basis of field catalog created above
      Call method cl_alv_table_create=>create_dynamic_table
        Exporting
          it_fieldcatalog = ifc                     u201Cfield catalog appended above
        Importing
          ep_table        = dy_table.            u201CDynamic internal table which will be created
      Assign dy_table->* to <dyn_table>.
    *Create dynamic work area and assign to FS
      Create data dy_line like line of <dyn_table>.
      Assign dy_line->* to <dyn_wa>.
    Then use this dynamic internal table created from above method
    in the Select Query.
    Hope it helps
    Regards
    Mansi

  • Syntax equivalent of CREATE TABLE AS for Functions?

    Hello,
    I'm trying to refresh my functions with a copy of them from another database. Is there a syntax equivalent of CREATE TABLE AS for Functions? Basically I want to drop my old function in my dev environment and recreate it with the version on prod. I need to use this in a loop for all functions in prod, so just using the plsql statement itself won't solve my issue.
    Thanks,
    John

    >
    Is there a syntax equivalent of CREATE TABLE AS for Functions?
    >
    No.
    >
    Basically I want to drop my old function in my dev environment and recreate it with the version on prod. I need to use this in a loop for all functions in prod, so just using the plsql statement itself won't solve my issue.
    >
    The proper way to do that is:
    1. check the DDL out of the PROD version control system
    2. check the DDL into the DEV version control system
    3. execute the DDL for each function using sql*plus or another tool
    If you don't have your production DDL in a version control system you need to solve that problem first and now is a good time to do it.
    Functions typically make references to other database objects (e.g. tables, views, synonyms, procedures, packages, etc) and those objects need to be updated in your 'dev' environment also or the function may produce different results than expected.

  • Privilege error while running Create Table Script inside Stored Procedure.

    Hello All,
    I have Oracle 10G server and SQL Developer Client,
    I have One User with Appropriate Rights, Login with that user from SQL Developer(client),
    Within my Procedure, Dynamic SQL script is like If I pass in a TABLE NAME as parameter, It Creates that table, but now problem is It throws an error for Privilege.
    Where as if I Execute Create table script outside the procedure(as Normal SQL), it executes Ok, but why it throws Privilege error within procedure ?
    Whether any extra Rights needed for this user to execute such Create Table Dynamic SQL?
    Please Help.
    Thanks,
    j@y

    Elic
    Thanks a lot dude...
    It works now,
    regards,
    j@y

  • Create Package of existing functions/procedures

    Hey,
    I've some functions and procedures.I want to group them together to one package... is it possible to use the existing functions in the Database or do i have to create the whole body which means copying the functions/procedures?
    Thanks!

    Hi there,
    If you need to package the functions and procedures up then you should move the code into a package body. However if you move the code and there are existing calls to these functions / procedures then you could break existing usages.
    An alternative would be to create a package with functions / procedure that encapsulate them. e.g. you have a standalone function called get_me_a_value
    and you create a function in a package which calls the standalone function ie. packaged_function.get_me_a_value
    Mark

  • Selecting values into same internal table from 2 differrnt select statement

    Hi Friends,
    code :
    types :
       begin of ty_bsad,
         augbl type bsad-augbl,
      end of ty_bsad.
    begin of ty_bsad1,
         augbl type bsad-augbl,
         belnr type bsad-belnr,
      end of ty_bsad1.
      select augbl
               from bsad
              into table it_bsad
              where belnr = l_vbeln and
                       bukrs = l_bukrs and
                      kunnr  = l_kunrg.
           if sy-subrc = 0 .
               select belnr
                         into table lt_bsad1
                         from bsad
                        for all entries in lt_bsad
                       where augbl = lt_bsad-augbl and
                                kunnr = l_kunnr  and
                                burks  = l_bukrs and
                                blart   = 'xy'.
    now my requiremnt is i need to get both the augbl and belnr in single internal table but not in differnrnt internal table.
    how can i get it.
    Regards,
    Priyanka.
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:53 AM

    HI.
    No Need to create two internal table because your feyching values from same table BSAD with diffrent where condition.try this code.it s work.
    select augbl
    from bsad
    into table it_bsad
    where belnr = l_vbeln and
    bukrs = l_bukrs and
    kunnr = l_kunrg and
    blart = 'xy'.
    else Refer this code.
    LOOP AT it_bill_data INTO wa_bill_data.
        MOVE-CORRESPONDING wa_bill_data TO wa_final_data.
        READ TABLE it_material_data INTO wa_material_data
                                    WITH KEY matnr = wa_bill_data-matnr.
        IF sy-subrc = 0.
          wa_final_data-meins_mara = wa_material_data-meins.
        ENDIF.
        APPEND wa_final_data TO it_final_data.
    ENDLOOP.
    Regards.
    Jay
    Edited by: Jay on Jan 8, 2009 2:53 PM
    Edited by: Jay on Jan 8, 2009 2:57 PM
    Code Formatted by: Alvaro Tejada Galindo on Jan 8, 2009 10:56 AM

  • Insert items from two different Multiple Select Lists into a single table

    I need help. I have a training tracking system that tracks the courses taken by employees.
    I have created two multiple select lists, one is SelectEmployees and the other is SelectCourses. I want to insert
    the selected item from those two multiple select lists into Training_Record table.
    Note, SelectEmployees" is from Employee table and SelectCourses is from Courses table. Those two table has no intersetion.
    Train_Record is the table that joins those two together.
    Please advice and your help is appreciate.

    Thank you for your help.
    I tried your code and changed the table/field name to my actual table/field name and the iitem name to actual item name.
    declare
    cursor c_Employees is
    select PERSONNEL_NEW.EMPLOYEEID from PERSONNEL_NEW where PERSONNEL_NEW.EMPLOYEEID in (:P15_SELECTEDEMP);
    cursor c_Courses is
    select COURSES.COURSE_ID from COURSES where COURSES.COURSE_ID in
    (:P15_SELECTEDCOUR);
    begin
    foreach :=r_employee in c_Employees loop
    foreach :=r_course in c_Courses loop
    insert
    into COPYOFTRAINREC ( EMPLOYEEID, COURSEID )
    values ( r_employee.EMPLOYEEID, r_course.COURSE_ID );
    end loop;
    end loop;
    end;
    I got error message as :
    ORA-06550: line 12, column 25: PLS-00103: Encountered the symbol "C_EMPLOYEES" when expecting one of the following: (
    Error
    OK

  • Select count( * ) command at internal tables

    Hi,
    it is not possible to use a select quiry at internal tables.
    I would like determine the number of person with a where
    condition at an internal table.  How does it work ?
    I cant say :
    select count( * ) from xxx into xxxxxxx
                      where xx= xx.
    What else can I do ?
    Regards
    ertas

    hi check this..
    PARAMETERS: p_carrid TYPE sbook-carrid,
                p_connid TYPE sbook-connid.
    TYPES: BEGIN OF sbook_type,
             fldate  TYPE sbook-fldate,
             smoker  TYPE sbook-smoker,
             smk_cnt TYPE i,
           END OF sbook_type.
    DATA sbook_tab TYPE TABLE OF sbook_type.
    SELECT fldate smoker COUNT( * ) AS smk_cnt
           FROM sbook
           INTO CORRESPONDING FIELDS OF TABLE sbook_tab
           WHERE connid = p_connid
           GROUP BY carrid fldate smoker
           HAVING carrid = p_carrid
           ORDER BY fldate smoker
    regards,
    venkat

  • Select count(x) on a table with many column numbers?

    Hi all,
    i have a table with physical data with 850 (!!) colums and
    ~1 Million rows.
    The select count(cycle)from test_table Statement is very, very slow
    WHY?
    The select count(cycle)from test_table is very fast by e.g 10 Colums. WHY?
    What has the number of columns, to do with the SELECT count(cyle).... statement?
    create test_table(
    cycle number primary key,
    stamp date,
    sensor 1 number,
    sensor 2 number,
    sensor_849 number,
    sensor_850 number);
    on W2K Oracle 9i Enterprise Edition Release 9.2.0.4.0 Production
    Can anybody help me?
    Many Thanks
    Achim

    hi lennert, hi all,
    many thanks for all the answers. I�m not an Oracle expert.
    Sorry for my english.
    Hi Lennert,
    you are right, what must i do to use the index in the
    query? Can you give me a pointer of direction, please?
    Many greetings
    Achim
    select count(*) from w4t.v_tfmc_3_blocktime;
    COUNT(*) ==> Table with 3 columns (very fast)
    306057
    Ausf�hrungsplan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 SORT (AGGREGATE)
    2 1 TABLE ACCESS (FULL) OF 'V_TFMC_3 _BLOCKTIME'    
    Statistiken
    0 recursive calls
    0 db block gets
    801 consistent gets
    794 physical reads
    0 redo size
    388 bytes sent via SQL*Net to client
    499 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed
    select count(*) from w4t.v_tfmc_3_value;
    COUNT(*)==> Table with 850 columns (very slow)
    64000
    Ausf�hrungsplan
    0 SELECT STATEMENT Optimizer=CHOOSE
    1 0 SORT (AGGREGATE)
    2 1 TABLE ACCESS (FULL) OF 'V_TFMC_3 _VALUE'    
    Statistiken
    1 recursive calls
    1 db block gets
    48410 consistent gets
    38791 physical reads
    13068 redo size
    387 bytes sent via SQL*Net to client
    499 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    0 sorts (memory)
    0 sorts (disk)
    1 rows processed

  • Select count from large fact tables with bitmap indexes on them

    Hi..
    I have several large fact tables with bitmap indexes on them, and when I do a select count from these tables, I get a different result than when I do a select count, column one from the table, group by column one. I don't have any null values in these columns. Is there a patch or a one-off that can rectify this.
    Thx

    You may have corruption in the index if the queries ...
    Select /*+ full(t) */ count(*) from my_table t
    ... and ...
    Select /*+ index_combine(t my_index) */ count(*) from my_table t;
    ... give different results.
    Look at metalink for patches, and in the meantime drop-and-recreate the indexes or make them unusable then rebuild them.

  • Parameter into a CREATE TABLE with PRO*C

    Hi,
    I use PRO*C and i've a problem with a CREATE TABLE request.
    My program asks for the name of my variable mission, quite simply that I get with a scanf.
    So, I want to create a table where one of the fields of the table must be the same that the char of the name of the mission. But, the function doesn't do anything… But when i write the name of the variable there is no problem.
    Thanks for your answers and sorry for my english.
    Code :
         void creer_table1(char nom_mission[50])
    EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR TABLE[50];
    EXEC SQL END DECLARE SECTION;
    strcpy(TABLE.arr,nom_mission);
    TABLE.len =strlen(TABLE.arr);
    EXEC SQL CREATE TABLE mission.msn_test AS
    SELECT * FROM mission.msn_mission
    WHERE missionname=:TABLE;
    printf("Table MSN_TEST creee dans le schema MISSION\n");
    PS: My IDE is code::blocks
    Bonjour à tous,
    J'utilise Pro*C et j'ai un problème avec une requête CREATE TABLE. Je m'explique:
    Mon programme demande quel est le nom de ma variable mission, que je récupère tout bêtement avec un scanf.
    Je veux alors créer une table où un de mes champs doit avoir comme valeur le char qui est le nom de la mission. Mais voila, la fonction qui doit créer la table ne la crée pas... Alors que quand je rentre cette variable en dur, cela fonctionne très bien. J'aimerais avoir un petit coup de pouce de votre part si c'est possible. Si ça se trouve j'essaie de faire quelque chose pas forcément possible.
    Voila mon code de la fonction servant à lire la table:
    Voila le code servant créer la fonction:
    Code :
    void creer_table1(char nom_mission[50])
    EXEC SQL BEGIN DECLARE SECTION;
    VARCHAR TABLE[50];
    EXEC SQL END DECLARE SECTION;
    strcpy(TABLE.arr,nom_mission);
    TABLE.len =strlen(TABLE.arr);
    EXEC SQL CREATE TABLE mission.msn_test AS
    SELECT * FROM mission.msn_mission
    WHERE missionname=:TABLE;
    printf("Table MSN_TEST creee dans le schema MISSION\n");
    Merci d'avance pour votre aide.
    PS:Je travaille sous code blocks et avec oracle
    Laurent Barale
    Edited by: 899981 on 30 nov. 2011 08:16

    Hi,
    I hadn't got errors.
    Bit, i solved my problem using dynamic sql.
    exemple:
    void function(char name[50]){
    EXEC SQL BEGIN DECLARE SECTION;
    char *varsql;
    EXEC SQL END DECLARE SECTION;
    char toto[150]="CREATE TABLE test AS SELECT * FROM tutu WHERE employe='";
    varsql=strcat(toto,name);
    strcat(varsql,"'");
    EXEC SQL EXECUTE IMMEDIATE :varsql;
    I hope that could help somebody.
    Bye and thank you for your answer.
    Edited by: 899981 on 20 déc. 2011 05:28

  • How to create tables and views and procedures in other users as one

    HI to all,
    I am having a user named vijay and i am trying to create the tables in user srini as user vijay
    in user vijay i'm having tables
    1. company
    2. department
    i wrote one procedure
    create or replace procedure sp_createobjects{short_name in varchar2}
    {my openbracket key is not working so that i put open braces here}
    as
    cursor table_name is select object_name from dba_tables where object_type = 'TABLE';
    var_table_name varchar2{1000};
    begin
    open table_name;
    loop
    fetch table_name into var_table_name;
    execute immediate 'create table ' || short_name || '.' || var_table_name || ' as select * from '||var_table_name;
    end loop;
    end;
    the procedure is created sucessfully. but when i am trying to execute the procedure it is throwing the error as insufficient privileges.
    my 2nd question is how to create the procedures into the other user?
    Thanks in advance

    First of all, your query "from dba_tables where object_type = 'TABLE'" returns all tables, not just the tables of the user vijay.
    So there are two possibilities, you may be getting the error because you cannot select from another user's table or you may be getting the error because you cannot create a table under the user srini. To create tables in another schema you need the "create any table" privilege.

  • Create table statement in stored procedures

    Hi,
    I am including the following statement in a stored procedure and receive the following error:
    STATEMENT:
    create table wrk_date (date date,
    qty smallint)
    tablespace temptabs;
    ERROR:
    PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
    begin declare exit for goto if loop mod null pragma raise
    return select update while <an identifier>
    <a double-quoted delimited-identifier> <a bind variable> <<
    close current delete fetch lock insert open rollback
    savepoint set sql commit <a single-quoted SQL string>
    Is this statement not allowed or is there a possible syntax error above?
    I am using Oracle database version 8.0.5.
    Thanks.
    null

    Jimmy - You might want to buy the Following book from Oreilley Press Oracle Built in Pacakages it's very very good and came in handy when I has to write dynamic SQL (DBMS_SQL package).
    You might want to try www.bookpool.com which has technical books cheaper than amazon.
    Hope this helps.
    _Satish
    Oracle 8 Certified D.B.A.
    Sun Certified Sysadmin

  • Create table statement inside a procedure.

    Hi,
    I'm trying to write a procedure creates some tables. The procedure has not arguments. I have written it in this way:
    CREATE OR REPLACE PROCEDURE MIGRAZIONE
    IS
        var varchar2(2000);
    BEGIN
    --INIZIO tabella dominio spr_klers_bor_borsa
    CREATE TABLE SPR_KLERS_BOR_BORSA34
      ID           VARCHAR2(4 BYTE)                 NOT NULL,
      DESCRIPTION  VARCHAR2(80 BYTE)
    CREATE UNIQUE INDEX SPR_KLERS_IAZ_BORSA_PK ON SPR_KLERS_BOR_BORSA
    (ID)
    LOGGING
    TABLESPACE FIN_DATA
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    ALTER TABLE SPR_KLERS_BOR_BORSA ADD (
      CONSTRAINT SPR_KLERS_IAZ_BORSA_PK
    PRIMARY KEY
    (ID)
        USING INDEX
        TABLESPACE FIN_DATA
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    MINEXTENTS       1
                    MAXEXTENTS       2147483645
                    PCTINCREASE      0
    --FINE tabella spr_klers_bor_borsa
    END MIGRAZIONE;When I compile I receive this message:
    PLS-00103: Encountered the symbol "CREATE" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with <an identifier>
    What does it mean?
    How can I solve?
    I have tried to change the procedure in this way:
    CREATE OR REPLACE PROCEDURE MIGRAZIONE
    IS
        var varchar2(2000);
    BEGIN
    --INIZIO tabella dominio spr_klers_bor_borsa
    var := 'CREATE TABLE SPR_KLERS_BOR_BORSA
      ID           VARCHAR2(4 BYTE)                 NOT NULL,
      DESCRIPTION  VARCHAR2(80 BYTE)
    CREATE UNIQUE INDEX SPR_KLERS_IAZ_BORSA_PK ON SPR_KLERS_BOR_BORSA
    (ID)
    LOGGING
    TABLESPACE FIN_DATA
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL;
    ALTER TABLE SPR_KLERS_BOR_BORSA ADD (
      CONSTRAINT SPR_KLERS_IAZ_BORSA_PK
    PRIMARY KEY
    (ID)
        USING INDEX
        TABLESPACE FIN_DATA
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    MINEXTENTS       1
                    MAXEXTENTS       2147483645
                    PCTINCREASE      0
    execute immediate var;
    --FINE tabella spr_klers_bor_borsa
    END MIGRAZIONE;And when I compile the version above I receive:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    begin case declare end exception exit for goto if loop mod
    null pragma raise return select update while with
    How can I solve?
    Thanks all, bye bye.

    Here you have to user dynamic sql for create table, cerate index etc.
    like
    CREATE OR REPLACE PROCEDURE MIGRAZIONE
    IS
        var varchar2(2000);
    BEGIN
    --INIZIO tabella dominio spr_klers_bor_borsa
    var := 'CREATE TABLE SPR_KLERS_BOR_BORSA
      ID           VARCHAR2(4 BYTE)                 NOT NULL,
      DESCRIPTION  VARCHAR2(80 BYTE)
    Execute immediate var;
    var := 'CREATE UNIQUE INDEX SPR_KLERS_IAZ_BORSA_PK ON SPR_KLERS_BOR_BORSA
    (ID)
    LOGGING
    TABLESPACE FIN_DATA
    PCTFREE    10
    INITRANS   2
    MAXTRANS   255
    STORAGE    (
                INITIAL          64K
                MINEXTENTS       1
                MAXEXTENTS       2147483645
                PCTINCREASE      0
                BUFFER_POOL      DEFAULT
    NOPARALLEL' ;
    Execute immediate var;
    var := 'ALTER TABLE SPR_KLERS_BOR_BORSA ADD (
      CONSTRAINT SPR_KLERS_IAZ_BORSA_PK
    PRIMARY KEY
    (ID)
        USING INDEX
        TABLESPACE FIN_DATA
        PCTFREE    10
        INITRANS   2
        MAXTRANS   255
        STORAGE    (
                    INITIAL          64K
                    MINEXTENTS       1
                    MAXEXTENTS       2147483645
                    PCTINCREASE      0
    execute immediate var;
    --FINE tabella spr_klers_bor_borsa
    END MIGRAZIONE;YOu can specify all the ddl statements in one execute immediate.
    Edited by: s_2 on Oct 17, 2008 6:59 PM

  • Problem while creating table dynamically using stored procedure

    Hi all
    When i try to execute the following lines get insufficient privilege error.
    FYI: i m able to create table statically.(i.e without using stored procedure)
    CREATE OR REPLACE PROCEDURE pcalling IS
    str varchar2(60);
    BEGIN
    str:='create table t15(tno number,tname varchar2(5))';
    execute immediate str;
    END;
    Thanks in advance
    Satya

    hi
    SQL> CREATE OR REPLACE PROCEDURE runddl (ddl_in in VARCHAR2)
      2     AUTHID CURRENT_USER
      3  IS
      4  BEGIN
      5     EXECUTE IMMEDIATE ddl_in;
      6  END;
      7  .
    SQL> /
    Procedure created.AUTHID CURRENT_USER clause before the IS keyword which runddl executes, it should run under the authority of the invoker, or current user not the authority of the definer.
    if you omit it then it will no longer will be run if the creator doesnt have privelege to run this ddl regardless invoker has or not.
    i hope you got it
    Khurram Siddiqui
    [email protected]

Maybe you are looking for

  • I need to chart a standard deviation of a moving average in Numbers

    In order to complete my statistical analysis of a large ammount of performance data- I was to graph a +/- 2 standard deviation of a moving average AS A SHADED region on my charts.  I tried to do this today for Four hours.  HELP!  PLEASE and thank you

  • Screen Savers in java

    Is anyone aware of the basic method for creating screen savers in java? I wrote some code that displays falling matrix code in a window, but I would like to convert the graphic window into a full screen graphic installable as a screen saver. Thanks..

  • Disappointed in service and support received

    I am grossly disappointed in the support and service I have received from att. I asked if services were available in an area I'm moving, just asking a question resulted in my services being cancelled and new services added to a home address that is s

  • Can't get interceptor example to work?

    hey i'm trying to learn about interceptors and wanted to create the example i found here. http://www.mastertheboss.com/en/jboss-server/177-ejb-interceptors-in-depth.html but I'm not sure how to configure Eclipse so that it will work. I downloaded fro

  • Runtime.getRuntime().exec

    hi all, im running my java under Linux. i want to copy a big bulk of files from one folder to other folder. when i implement Runtime.getRuntime().exec("cp -r /sourcefolder /destintationfolder"). its been execute but the copy process didnt complete ye