Stored procedure to remove a number of tables with a common name attribute

Hi all

This is my first post so I hope I posted level with enough information. This is my first stored procedure (SP) and Oracle 10.

I'm trying to write a script to remove 11 paintings and some lines of another 3 tables, which are named with a number I want to enter at the time of the creation of MS below is the script that I wrote and edited. My original was lost by crashing the servers!

When I run the script, it gives me the following output:

"WARNING: execution completed with warning.
procedure ScenarioDelete update"

MS has not deleted one of these tables and I don't know if it's because my script is poor or because of something else. Any help is greatly appreciated!

-table remove SP
--
-Race start ScenarioDelete ('x'); with the idscenario x

create or replace procedure ScenarioDelete (ScenarioNo IN varchar2);
countstable: = "C_". ScenarioNo;
CHANGETABLE: = "CG_" | ScenarioNo;
countsinfotable: = 'CI_ ' | ScenarioNo;
DataTable1: = "D_0_" | ScenarioNo;
datatable2: = "D_1_" | ScenarioNo;
datatable3: = 'D_2_ ' | ScenarioNo;
hietable1: = 'HI_0_ ' | ScenarioNo;
hietable2: = 'HI_1_ ' | ScenarioNo;
hietable3: = 'HI_2_ ' | ScenarioNo;
hielinktable1: = 'HL_1_ ' | ScenarioNo;
hielinktable2: = 'HL_2_ ' | ScenarioNo;

AS

run immediately 'drop table ' | countstable;
run immediately 'drop table ' | CHANGETABLE;
run immediately 'drop table ' | countsinfotable;
run immediately 'drop table ' | DataTable1;
run immediately 'drop table ' | datatable2;
run immediately 'drop table ' | datatable3;
run immediately 'drop table ' | hietable1;
run immediately 'drop table ' | hietable2;
run immediately 'drop table ' | hietable3;
run immediately 'drop table ' | hielinktable1;
run immediately 'drop table ' | hielinktable2;

immediately execute "delete from USERACESS where IDSCENARIO = ' |" ScenarioNo;
run immediately "remove scenario where IDSCENARIO = ' |" ScenarioNo;
immediately execute "delete from SCENARIOINFO where IDSCENARIO = ' |" ScenarioNo;

-or-

run immediately "delete from USERACESS where IDSCENARIO =" | " ScenarioNo | ''';
run immediately "remove scenario where IDSCENARIO =" | " ScenarioNo | ''';
run immediately "delete from SCENARIOINFO where IDSCENARIO =" | " ScenarioNo | ''';

END;

Hello

Welcome to the RTO

If you allow me, I would like to make a suggestion to simplify your code

Create OR Replace Procedure ScenarioDelete(ScenarioNo IN Varchar2)
As
   Type t_DropTable Is Table Of Varchar2(30);
   v_DropTable t_DropTable := t_DropTable( 'C_', 'CG_', 'CI_', 'D_0_', 'D_1_', 'D_2_', 'HI_0_', 'HI_1_', 'HI_2_', 'HL_1_', 'HL_2_' );

   Type t_DeleteTable Is Table Of Varchar2(30);
   v_DeleteTable t_DeleteTable := t_DeleteTable( 'USERACESS', 'SCENARIO', 'SCENARIOINFO' );
Begin
   -- Drop tables
   For i IN v_DropTable.First .. v_DropTable.Last Loop
      Execute Immediate 'DROP TABLE ' || v_DropTable(i) || ScenarioNo;
   End Loop;

   -- Delete tables
   For i IN v_DeleteTable.First .. v_DeleteTable.Last Loop
      Execute Immediate 'DELETE FROM ' || v_DeleteTable(i) || ' WHERE SCENARIOID = ' || ScenarioNo;
   End Loop;
End;

Kind regards

Christian Balz

Tags: Database

Similar Questions

  • stored procedure to return the number of rows

    Hello. How can I create a stored procedure that returns a number of lines such as select count (*) of the emp. I only know how to return a result set, but how to a single value. Need help please.

    Easy:

    CREATE OR REPLACE PROCEDURE get_count (p_count OUT NUMBER) IS
    BEGIN
       SELECT COUNT(*)
       INTO   p_count
       FROM   a_table;
    END get_count;
    
  • It is possible to have two tables with the same name in Oracle!

    Oracle Version: 10 gr 2

    MS Access 2007, I had to use the 'Export' by which I copy a table (and its data) to an Oracle schema via an ODBC connection. Later, I realized that, during the copy of tables with a mix of lower and upper case names, the table does not copied (exported). But MS Access will give you the message that table obtained export successfully.

    MS-Access mess around Oracle data dictionary.

    When you issue
    SQL>select * from tab;
    
    TNAME                          TABTYPE  CLUSTERID
    ------------------------------ ------- ----------
    AMStates                       TABLE
    Version                        TABLE
    You will see the names of the tables. But when you try to DESCRIBE or SELECT this table, you will
    SQL>desc Version
    ERROR:
    ORA-04043: object Version does not exist
    You can even create another table with the same name in the schema
    SQL>create table VERSION (X NUMBER);
    
    Table created.
    Why this is happening and how can I bring these items 'non-existent '?

    Hello

    Use

    SQL > desc 'Version '.

    Or

    SQL > select * from 'Version '.

    Or

    SQL > drop table 'Version '.

    To overcome the problems of mixed-case.

  • LOV cascading if I don't have only one table with the customer name and the name of the product in the ADF.

    Hi Please help me how to use cascade, if I don't have only one table with the customer name and the name of the product in the ADF... I use Jdeveloper 11.1.

    For the client, I used customer VO with client list to fill but to populate the product that I use bind variable PrODUCT_NAME select distinct from TABLE where client_name =: bindCustomer

    so first of all, I need to set the variable of liaison on behalf of the selected customer.

    Can you please tell me how to set this variable binding in this case.

    After you set the LOV to your product attribute, correspondting VO in the LOV will appear under view accessors.

    Change the accessor of the view, you will see the variable binding. Set its value to the customer field of the parent object.

    Visit this link: https://www.youtube.com/watch?v=nXwL2_RP7AQ

    Kind regards

    Elias.

  • How to remove line before Panel table with databases?

    Hi friends,

    I created the table creation of database for the list of users. Which works very well. And I also recover data that is I've stored previously and I have displayed in table format on the front. Now, I want to delete a whole line, is not a wise order, for example, now, I have a table, there total 7 rows and 5 columns. Now, I want to delete the 3 rows using by selecting the line (i.e., click anywhere in this line and press the button) that day that the rank will be remove from the database. Then remaining will again store in the database.

    I want this way is it possible or not?

    Thanks

    Concerning

    Joel M

    India

    Note: I use the LabVIEW database connectivity toolkit

    Database: Ms access

    Sorry for my grammatical error

    arun575 wrote:

    Hi friends,

    [...] Now, I want to delete the 3 rows using by selecting the line (i.e., click anywhere in this line and press the button) that day that the rank will be remove from the database. Then remaining will again store in the database.

    Instead of storing data in the database, simply remove the record that you have removed from your FP indicator and recharge the light on the database.  (The first column in my database is named ID - autoindexed, the primary key)

    EDIT - only sub blue-vi is https://lavag.org/files/file/60-array-point-to-rowcol/

  • Remove a line of table with a button in Livecycle Designer SS3

    I have a table in Livecycle which includes 16 static lines. Several lines can be added or removed dynamically at the end of the table.

    I want the user to be able to remove one of the static lines if they want to however I can't get the script to work.

    I have a button at the end of the line with the script:

    driverTable._Row2.removeInstance (true);

    I tried various forms of this script such as do not use the abbreviation for 'instanceManager', leaving 'real' outside, etc. Where it says 'Row2' I would like to use this script for the following lines, Row3, etc. Row4.

    I tried with the initial counter value of 1 and tried to zero. The table is in a fluid subform.

    Can anyone help?

    Hello

    A line cannot be set to 0 cases, if you want to remove a line, you need to hide by using its property of presence...

    But if you use 1 table for 16 different ranks, why don't you set the table with dynamic lines and have an initial 16 meter, then you can delete the lines you want with the removeInstance method

  • Drop a large number of tables with the same prefix

    Hello

    can you help me to make a script to move all the tables with the same prefix = TEST_LINK_?

    Thank you very much.
    Crystal

    Hi crystal,

    Here's something to start. It does not all FK constraints on those tables and assumes that the executor is the owner.

    declare
      pstmt  constant varchar2(255) := 'drop table :t purge';
      vstmt varchar2(255);
    begin
    for rec in (select table_name
                  from user_tables
                 where table_name like 'TEST_LINK\_%' escape '\')
       loop
          vstmt := replace(pstmt, ':t', rec.table_name);
          dbms_output.put_line(vstmt || ';');
    --      execute immediate vstmt;
       end loop;
    end;
    /
    

    Concerning
    Peter

  • How to import a table with the renamed name

    If I want to import a table from a DMP on UNIX to my user where I already have a new version, but I don't want to give up this new version, because I only move files from one to the other, is an import option for importing the table with another name? I want to say I want to import it on the same user, where there is already the MYTABLE table, an older version of MYTABLE by impoting with the new name MYTABLE_OLD, if eventually I can update MYTABLE with some of the old files of the old version MYTABLE_OLD. Is this possible?

    You can't do it directly.

    You can import the Table into a different schema, and then rename the table.

    export and import in the required schema.

    Import DataPump: How to import Table data in a Table that has different name? [342314.1 ID]

    Concerning
    Rajesh

  • Bulck of variable form XMLType insert stored procedure and registry failed in another table

    Hi, I use: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64 bit Production and I'm trying to create a procedure to insert an XML save the registry defective inserts and return them.


    In the main procedure of , I analyze the XML and call the function to insert the line. If I get a FAKE, I want to do an insert into a table called InsertEmballagFailed:


    It is not parsing correctly I do not know why?


    CREATE OR REPLACE PROCESS INSERT_PALET_WITH_XML ( )

    v_Palet IN VARCHAR2,

    v_XML IN XMLType)

    IS 

    v_numemb varchar2 (9);

    v_typemb varchar2 (1);

    v_prefix varchar2 (2);

    v_anyo number 4;

    v_mes NUMBER (2);

    v_poidsbrut NUMBER (8);

    v_qte NUMBER (8);

    v_date_creation varchar2 (10);

    v_heure_creation varchar2 (8);

    v_numlot varchar2 (8);

    v_numord varchar2 (8);

    v_typenumct varchar2 (20);

    v_flagano NUMBER (5);

    v_cnuf varchar2 (8);

    v_resultinsert boolean;

    v_resultinsertStr varchar2 (5);

    START 

    FOR r IN

    SELECT ExtractValue (Value (p),' / ROW/NUMEMB / text () '() as v_numemb

    ExtractValue (Value (p),' / ROW/TYPEMB / text () '() as v_typemb

    ExtractValue (Value (p),' / ROW/PREFIX / text () '() as v_prefix

    TO_NUMBER (ExtractValue (Value (p),' / ROW/ANYO / text () ')) as v_anyo

    TO_NUMBER (ExtractValue (Value (p),' / ROW/MY/text () ')) as v_mes

    TO_NUMBER (ExtractValue (Value (p),' / ROW/POIDSBRUT / text () ')) as v_poidsbrut

    TO_NUMBER (ExtractValue (Value (p),' / ROW/QTY / text () ')) as v_qte

    ExtractValue (Value (p),' / ROW/DATE_CREATION / text () '() as v_date_creation

    ExtractValue (Value (p),' / ROW/HEURE_CREATION / text () '() as v_heure_creation

    ExtractValue (Value (p),' / ROW/NUMLOT / text () '() as v_numlot

    ExtractValue (Value (p),' / ROW/NUMORD / text () '() as v_numord

    ExtractValue (Value (p),' / ROW/TYPENUMCT / text () '() as v_typenumct

    TO_NUMBER (ExtractValue (Value (p),' / ROW/FLAGANO / text () ')) as v_flagano

    ExtractValue (Value (p),' / ROW/CNUF / text () '() as v_cnuf

    DE TABLE(XMLSequence (extract (v_XML,' / LINES/LINES '))) p

    ) LOOP

    v_resultinsert: = INSERT_ROW_IN_EMBALLAG)

    v_numemb, v_typemb, v_prefix, v_anyo, v_mes, v_poidsbrut, v_qte, v_date_creation,

    v_heure_creation, v_numlot, v_numord, v_typenumct, v_flagano, v_cnuf);

    v_resultinsertStr: = BOX

    WHEN v_resultinsert THEN 'True ' 

    WHEN Not v_resultinsert THEN 'False'

    END

    END LOOP; 

    ENGAGE

    EXCEPTION

    TypeNumCt Varchar2 (20).

    PRIMARY KEY (Palet_Id, NumEmb)); 

    WHEN Others THEN 

    ROLLBACK

    RAISE_APPLICATION_ERROR (-20001, 'an error occurred-'|) SQLCODE: "- ERROR -" || SQLERRM); 

    END INSERT_PALET_WITH_XML; /


    The secondary function called from the beginning. And give a 'false' if he can't. (This part is ok).


    CREATE OR REPLACE FUNCTION INSERT_ROW_IN_EMBALLAG ( )

    v_numemb IN VARCHAR2,

    v_typemb IN VARCHAR2,

    v_prefix IN VARCHAR2,

    v_anyo IN NUMBER,

    v_mes IN NUMBER,

    v_poidsbrut IN NUMBER,

    v_qte IN NUMBER,

    v_date_creation IN VARCHAR2,

    v_heure_creation IN VARCHAR2,

    v_numlot IN VARCHAR2,

    v_numord IN VARCHAR2,

    v_typenumct IN VARCHAR2,

    v_flagano IN NUMBER,

    v_cnuf IN VARCHAR2) RETURN Boolean

    IS 

    v_resp boolean;

    START 

    INSERT IN package ( )

    NumEmb, TypEmb, prefix, Anyo, my, PoidsBrut, ETA, Date_Creation, Heure_Creation,

    NumLot, NumOrd, TypeNumCt, FlagAno, CNUF)

    VALUES

    v_numemb, v_typemb, v_prefix, v_anyo, v_mes, v_poidsbrut, v_qte, v_date_creation,

    v_heure_creation, v_numlot, v_numord, v_typenumct, v_flagano, v_cnuf);

    ENGAGE

    RETURN TRUE

    EXCEPTION

    WHEN Others THEN 

    ROLLBACK

    RETURN FALSE

    END INSERT_ROW_IN_EMBALLAG; 

    /


    To try, I make this appeal:


    CALL INSERT_PALET_WITH_XML ('570002217', XMLType(' ))

    < Rowset > 

    < LINE > 

    < NUMEMB > 570002217 < / NUMEMB > 

    < TYPEMB > 1 </ TYPEMB > 

    < The PREFIX > 56 < / the PREFIX > 

    < ANYO > 2013 </ ANYO > 

    < MY > 4 </ MES > 

    < POIDSBRUT > 29120 < / POIDSBRUT > 

    < QTY. > 8 </ QTE > 

    < DATE_CREATION > 27/04/2013 </ DATE_CREATION > 

    < HEURE_CREATION > 09.58.17 < / HEURE_CREATION > 

    < NUMLOT > 55555 < / NUMLOT > 

    < NUMORD > 77777779 < / NUMORD > 

    < TYPENUMCT > 0 < / TYPENUMCT > 

    < FLAGANO > 0 </ FLAGANO > 

    < CNUF > 8411061 < / CNUF > 

    </ LINE > 

    </ Rowset > 

    '));


    Thanks for any help.

    Joel

    You're not (wrongly) referring to values of implicit cursor what records were not properly inserted. So I changed the code and given below. Please check and let me know in case of any problems.

    CREATE OR REPLACE PROCEDURE INSERT_PALET_WITH_XML)

    v_Palet IN VARCHAR2,

    v_XML IN XMLType)

    IS

    / * v_numemb varchar2 (9);

    v_typemb varchar2 (1);

    v_prefix varchar2 (2);

    v_anyo number 4;              -No need... Then removed-

    v_mes NUMBER (2);

    v_poidsbrut NUMBER (8);

    v_qte NUMBER (8);

    v_date_creation varchar2 (10);

    v_heure_creation varchar2 (8);

    v_numlot varchar2 (8);

    v_numord varchar2 (8);

    v_typenumct varchar2 (20);

    v_flagano NUMBER (5);

    v_cnuf varchar2 (8); */

    v_resultinsert boolean;

    v_resultinsertStr varchar2 (5);

    BEGIN

    FOR (IN) r

    SELECT ExtractValue (Value (p),'/ ROW/NUMEMB/text () ') as v_numemb

    , ExtractValue (Value (p),'/ ROW/TYPEMB/text () ') as v_typemb

    , ExtractValue (Value (p),'/ ROW/PREFIX/text () ') as v_prefix

    , TO_NUMBER (ExtractValue (Value (p),'/ ROW/ANYO/text () ')) as v_anyo

    , TO_NUMBER (ExtractValue (Value (p),'/ ROW/MY/text () ')) as v_mes

    , TO_NUMBER (ExtractValue (Value (p),'/ ROW/POIDSBRUT/text () ')) as v_poidsbrut

    , TO_NUMBER (ExtractValue (Value (p),'/ ROW/QTY/text () ')) as v_qte

    , ExtractValue (Value (p),'/ ROW/DATE_CREATION/text () ') as v_date_creation

    , ExtractValue (Value (p),'/ ROW/HEURE_CREATION/text () ') as v_heure_creation

    , ExtractValue (Value (p),'/ ROW/NUMLOT/text () ') as v_numlot

    , ExtractValue (Value (p),'/ ROW/NUMORD/text () ') as v_numord

    , ExtractValue (Value (p),'/ ROW/TYPENUMCT/text () ') as v_typenumct

    , TO_NUMBER (ExtractValue (Value (p),'/ ROW/FLAGANO/text () ')) as v_flagano

    , ExtractValue (Value (p),'/ ROW/CNUF/text () ') as v_cnuf

    TABLE (XMLSequence (Extract(v_XML,'/ROWSET/ROW'))) p

    )

    LOOP

    -Reference values such as r.v_numemb (r.columnname).

    v_resultinsert: = INSERT_ROW_IN_EMBALLAG)

    r.v_numemb, r.v_typemb, r.v_prefix, r.v_anyo, r.v_mes, r.v_poidsbrut, r.v_qte, r.v_date_creation,

    r.v_heure_creation, r.v_numlot, r.v_numord, r.v_typenumct, r.v_flagano, r.v_cnuf);

    v_resultinsertStr: = BOX

    WHEN v_resultinsert THEN 'True '.

    WHEN Not v_resultinsert THEN 'False. '

    END;

    END LOOP;

    COMMIT;

    EXCEPTION

    TypeNumCt - Varchar2 (20), - deleted... Something here-

    (--A KEY primary SCHOOL (Palet_Id, NumEmb));

    WHILE OTHERS THEN

    ROLLBACK;

    RAISE_APPLICATION_ERROR (-20001, 'an error occurred' - |) SQLCODE |' - ERROR - ' | SQLERRM);

    END INSERT_PALET_WITH_XML;

    /

    Post edited by: 000000

  • Removal of MSQL 2 tables with a single button

    As I was able to add data from two tables mysql with a single button, I guess I should be able to delete the two entries in a similar way, but I can't seem to get there. The code is written in large part by DW and I have only the level minimum idea of the meaning of the php, so please be patient in no explanation as to where I'm wrong!
    At the present time, to the chk_sixmonth of the table entry is removed, but at table cel_contents incorrect records are deleted.
    The corresponding code is, I think;
    If ((isset($_POST['ck_pk'])) & & ($_POST ['ck_pk']! = "") & & (isset($_POST['gone']))) {}
    $deleteSQL = sprintf ("DELETE FROM chk_sixmonth WHERE ck_pk is %s",
    GetSQLValueString ($_POST ['ck_pk'], "int"));

    @mysql_select_db ($database_tormented3, $tormented3);
    $Result1 = mysql_query ($deleteSQL, $tormented3) or die (mysql_error ());

    $deleteGoTo = "chk_insert.php";
    If (isset {}
    $deleteGoTo. = (strpos ($deleteGoTo, '?'))? « & » : « ? » ;
    $deleteGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $deleteGoTo));
    }

    If ((isset($_POST['cel_pk'])) & & ($_POST ['cel_pk']! = "") & & (isset($_POST['gone']))) {}
    $deleteSQL = sprintf ("DELETE FROM cel_contents WHERE cel_pk is %s",
    GetSQLValueString ($_POST ['cel_pk'], "int"));

    @mysql_select_db ($database_tormented3, $tormented3);
    $Result1 = mysql_query ($deleteSQL, $tormented3) or die (mysql_error ());

    $deleteGoTo = "chk_insert.php";
    If (isset {}
    $deleteGoTo. = (strpos ($deleteGoTo, '?'))? « & » : « ? » ;
    $deleteGoTo. = $_SERVER ['QUERY_STRING'];
    }
    header (sprintf ("location: %s", $deleteGoTo));
    }

    $colname_rstSix = "1";
    If (isset($_GET['scrap'])) {}
    $colname_rstSix = (get_magic_quotes_gpc())? $_GET ["scrap"]: addslashes($_GET['scrap']);
    }
    @mysql_select_db ($database_tormented3, $tormented3);
    $query_rstSix = sprintf ("SELECT * FROM chk_sixmonth WHERE ck_pk = %s", $colname_rstSix);
    $rstSix = mysql_query ($query_rstSix, $tormented3) or die (mysql_error ());
    $row_rstSix = mysql_fetch_assoc ($rstSix);
    $totalRows_rstSix = mysql_num_rows ($rstSix);

    $colname_rstCont = "1";
    If (isset($_GET['scrap2'])) {}
    $colname_rstCont = (get_magic_quotes_gpc())? $_GET ['scrap2']: addslashes($_GET['scrap2']);
    }
    @mysql_select_db ($database_tormented3, $tormented3);
    $query_rstCont = sprintf ("SELECT * FROM cel_contents WHERE cel_pk = %s", $colname_rstCont);
    $rstCont = mysql_query ($query_rstCont, $tormented3) or die (mysql_error ());
    $row_rstCont = mysql_fetch_assoc ($rstCont);
    $totalRows_rstCont = mysql_num_rows ($rstCont);
    ? >
    <! DOCTYPE etc...

    < form action = "" method = "post" name = "scrap" id = "scrap" > "
    < input name = "gone" type = "checkbox" id = "gone" value = "gone" / >
    < input type = "submit" name = "Submit" value = "Remove" / >

    < input name = "ck_pk" type = "hidden" id = "ck_pk" value = "<?" PHP echo $row_rstSix ["ck_pk"];? ">" / >
    < input name = "cel_pk" type = "hidden" id = "cel_pk" value = "<?" PHP echo $row_rstCont ["cel_pk"];? ">" / >
    < / make >
    Thanks for any help

    Problem has now well sorted.

  • Error in the call to a procedure that is packed on another schema with the alias name

    Hi all

    I call a packaged procedure that has the type as a parameter collection that resides in the remote database by using synonyms.for which I am creating a synonym in my current schema.

    Below the package in the remote database:
    CREATE or REPLACE PACKAGE test_hlr BODY
    AS
    PROCEDURE raj_test)
    pi_username IN VARCHAR2,
    pi_serial_no IN arr_numb, - type of user-defined collection
    po_error_code OUT NUMBER
    )
    AS
    BEGIN
    BECAUSE me IN pi_serial_no. FIRST... pi_serial_no. LAST
    LOOP
    INSERT INTO hlr_raj
    (user_name, serial_no
    )
    VALUES (pi_username, pi_serial_no (i)
    );
    END LOOP;
    END;
    END;



    I'm create synonym of package in my current database and call this package synonymous as shown below

    create synonym ram_test for ram_test@dblink

    CREATE or REPLACE PACKAGE test_bnr BODY
    AS

    PROCEDURE ram_test)
    pi_username1 IN VARCHAR2,
    pi_serial_no1 IN arr_numb, - type of user-defined collection
    po_error_code OUT NUMBER
    )
    AS

    BEGIN
    test_hlr.raj_test (pi_username = > pi_username1,)
    pi_serial_no = > pi_serial_no1,
    po_error_code = > po_error_code
    );
    END;
    END;

    When compiling above package am getting error below
    PLS-00306: wrong number or types of arguments in the call to ' RAJ_TEST


    If I remove the collection type and use types of primitive data and then do not get error.

    Please give suggestions, about the same.

    Kind regards
    Sri Ram.

    There is no need to declare the type arr_numb locally. In fact, two types with exact same statement and namesake are not the same type. Each type has a unique OID. You can specify own OID. Then you can create the types the and remote with same OID. But if the type is the type of PL/SQL it didn't need to. For example. ON remote DB:

    create or replace
      package pkg1
        as
          type arr_numb is table of number;
          procedure p1(
                       p_numb_arr IN arr_numb,
                       p_sum OUT number
                      );
    end;
    /
    create or replace
      package body pkg1
        as
          procedure p1(
                       p_numb_arr IN arr_numb,
                       p_sum OUT number
                      )
            is
            begin
                for i in 1..p_numb_arr.count loop
                  p_sum := nvl(p_sum,0) + p_numb_arr(i);
                end loop;
          end;
    end;
    /
    

    Now locally:

    set serveroutput on
    declare
        v_numb_arr pkg1.arr_numb@sol10;
        v_sum number;
    begin
        v_numb_arr := pkg1.arr_numb@sol10(1,2,3,4,5,6,7,8,9);
        pkg1.p1@sol10(v_numb_arr,v_sum);
        dbms_output.put_line(v_sum);
    end;
    /
    45
    
    PL/SQL procedure successfully completed.
    
    SQL> 
    

    SY.

  • I need help with the removal of "all records associated with my domain name.

    Hello

    I have some problemsthe same exact problem like Daren... set up my site to go live. Here's what I've done so far:

    (1) built the site and pushed it live

    2) updated the site

    (3) put in place a GoDaddy domain name

    (4) set up servers on GoDaddy

    (5) put in place the account information associated with British Colombia

    And then... nothing.

    I then removed from the area and tried to repeat the process, in case I missed something, but now I can not put in place a new area and get the error "field already exists. Please delete all the records associated with this area. What records? What does this even mean?

    Anyone can guide me please you through the steps to get this live site?

    Thank you!

    Alex

    The field works on my end.

    It just a delay which should get fixed in a few hours.

    Give it some time and check again.

    Thank you

    Sanjit

  • Get the sizes of tables with the same name but from different schemas

    There are two patterns in my database: HAND and ARCH.
    Each of these schemas contains a table named SPOITEMS. I would like to get the size of the table "SPOITEMS" of patterns one and another.
    I found this script:

    Select
    nom_segment table_name,
    Sum (bytes) /(1024*1024) table_size_meg
    Of
    user_extents
    where
    segment_type = 'TABLE '.
    and
    nom_segment = "SPOITEMS".
    Table_name group

    but it returns only a single element with the name of the table "SPOITEMS" (owner ARCH).

    Any ideas?

    Thanks in advance

    I assume that you run the query in the ARK? Use ALL_EXTENTS or DBA_EXTENTS instead of USER_EXTENTS

  • Tables created in a stored procedure cannot be used with dynamic SQL? The impact?

    There is a thread on the forum which explains how to create tables within a stored procedure (How to create a table in a stored procedure , however, it does create a table as such, but not how to use it (insert, select, update, etc.) the table in the stored procedure.) Looking around and in the light of the tests, it seems that you need to use dynamic SQL statements to execute ddl in a stored procedure in Oracle DB. In addition, it also seems that you cannot use dynamic SQL statements for reuse (insert, select, update, etc.) the table that was created in the stored procedure? Is this really the case?

    If this is the case, I am afraid that if tables cannot be 'created and used"in a stored procedure using the dynamic SQL, as is the case with most of the servers of DB dynamic SQL is not a part of the implementation plan and, therefore, is quite expensive (slow). This is the case with Oracle, and if yes what is the performance impact? (Apparently, with Informix, yield loss is about 3 - 4 times, MS SQL - 4 - 5 times and so on).

    In summary, tables created within a stored procedure cannot be 'used' with dynamic SQL, and if so, what is the impact of performance as such?

    Thank you and best regards,
    Amedeo.

    Published by: AGF on March 17, 2009 10:51

    AGF says:
    Hi, Frank.

    Thank you for your response. I understand that the dynamic SQL is required in this context.

    Unfortunately, I am yet to discover "that seeks to" using temporary tables inside stored procedures. I'm helping a migration from MySQL to Oracle DB, and this was one of the dilemmas encountered. I'll post what is the attempt, when more.

    In Oracle, we use [global temporary Tables | http://www.psoug.org/reference/OLD/gtt.html?PHPSESSID=67b3adaeaf970906c5e037b23ed380c2] aka TWG these tables need only be created once everything like a normal table, but they act differently when they are used. The data inserted in TWG will be visible at the session that inserted data, allowing you to use the table for their own temporary needs while not collide with them of all sessions. The data of the TWG will be automatically deleted (if not deleted programmatically) when a) a commit is issued or b) the session ends according to the parameter that is used during the creation of the TWG. There is no real need in Oracle to create tables dynamically in code.

    I noticed that many people say that the "Creation of the tables within a stored procedure" is not a good idea, but nobody seems necessarily explain why? Think you could elaborate a little bit? Would be appreciated.

    The main reason is that when you come to compile PL/SQL code on the database, all explicit references to tables in the code must correspond to an existing table, otherwise a djab error will occur. This is necessary so that Oracle can validate the columns that are referenced, the data types of those columns etc.. These compilation controls are an important element to ensure that the compiled code is as error free as possible (there is no accounting for the logic of programmers though ;)).

    If you start to create tables dynamically in your PL/SQL code, so any time you want to reference this table you must ensure that you write your SQL queries dynamically too. Once you start doing this, then Oracle will not be able to validate your SQL syntax, check the types of data or SQL logic. This makes your code more difficult to write and harder to debug, because inevitably it contains errors. It also means that for example if you want to write a simple query to get that one out in a variable value (which would take a single line of SQL with static tables), you end up writing a dynamic slider all for her. Very heavy and very messy. You also get the situation in which, if you create tables dynamically in the code, you are also likely to drop tables dynamically in code. If it is a fixed table name, then in an environment multi-user, you get in a mess well when different user sessions are trying to determine if the table exists already or is the last one to use so they can drop etc. What headache! If you create tables with table names, then variable Dynamics not only make you a lot end up creating (and falling) of objects on the database, which can cause an overload on the update of the data dictionary, but how can ensure you that you clean the tables, if your code has an exception any. Indeed, you'll find yourself with redundant tables lying around on your database, may contain sensitive data that should be removed.

    With the TWG, you have none of these issues.

    Also, what is the impact on the performance of the dynamic SQL statements in Oracle? I read some contrasting opinions, some indicating that it is not a lot of difference between static SQL and SQL dynamic in more recent versions of Oracle DB (Re: why dynamic sql is slower than static sql is this true?)

    When the query runs on the database, there will be no difference in performance because it is just a request for enforcement in the SQL engine. Performance problems may occur if your dynamic query is not binding variable in the query correctly (because this would cause difficult analysis of the query rather than sweet), and also the extra time, to dynamically write the query running.

    Another risk of dynamic query is SQL injection which may result in a security risk on the database.

    Good programming will have little need for the tables of dynamically created dynamically or SQL.

  • Error PLS-00306 with stored procedure

    I am trying to create a simple package and store the procedure to remove the date of treatment for Crystal Reports can read all data. I used an example on the web site for Crystal report as reference in SAP: link: [http://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/1084c536-711e-2b10-e48a-924a60745253;jsessionid= (J2EE3417200) ID0966300750DB00193623365600119940End]

    I ran the following and receive PLS-00306: wrong number or type of argument on the stored procedure. I am also pulling data with a databaselink to another data base given that our third-party vendor will not connect directly to the main database.

    I am new to PL/SQL, so I don't know what else to solve problems. Thank you for taking the time to review this.

    -1. Create a temporary table
    CREATE TEMPORARY TABLE global test_temp
    (processdate DATE NOT NULL);

    -2.Create package w / require REF CURSOR for Crystal reports
    CREATE or REPLACE PACKAGE test_package
    IN the TYPE processdate_TYPE IS REF CURSOR
    RETURN test_temp % ROWTYPE;
    END test_package;
    /

    -3. Stored procedure
    CREATE OR REPLACE PROCEDURE test_Procedure
    (processdate_cursor IN OUT test_Package.processdate_TYPE,
    processdate_parameter IN test_temp.processdate%TYPE)
    AS
    processdate DATE;
    BEGIN
    OPEN FOR Processdate_cursor
    SELECT processdate
    OF processlog@WEATEST
    WHERE processname = "F_ExecuteScheduleProcess" and processtype = ';
    END test_Procedure;
    /

    You say that you do not understand where there is a wrong number or type?

    This error occurs because there is an incorrect number of parameters passed. Your procedure
    Test_SP expects 3 parameters as defined by you as follows
    (p_ID in number,
    p_firstname OUT varchar2,
    p_lastname OUT varchar2)

    But when you run, you're not not p_id, has not managed to p_firstname, has failed to p_lastname. So there are number of parameters and that's what suggests the error.

    To run your test_sp
    Declare
    sFirstName Test_Table.FirstName%Type;
    sLastName Test_Table.Lastname%Type;
    Nest Test_Table.ID%Type: = 1;
    Begin
    Test_SP(1,sFirstName,sLastName);
    End;

    I hope this helps.

Maybe you are looking for