Procedures package

Hello

When I run my packege it inserts records form Employees table to the new_emp table. And if I pass the parcel second time it inserts the same records that were inserted. So I get duplicate records.

How to avoid duplication of discs?

create or replace

package emp_pac as

procedure ins_emp (employee_id number);

end emp_pac;

create or replace

package body emp_pac as

procedure ins_emp (employee_id number, sal_id number) as

Start

insert into new_emp (employe_id, FIRST_NAME, LAST_NAME, EMAIL,

PHONE_NUMBER HIRE_DATE, JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID)

SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME, EMAIL,

PHONE_NUMBER HIRE_DATE, JOB_ID, SALARY, COMMISSION_PCT, MANAGER_ID, DEPARTMENT_ID

Employees;

ins_emp end;

end emp_pac;

Hello

-all employees to new_emp load line

INSERT INTO new_emp

...

Employees WHERE NOT EXISTS)

SELECT null FROM new_emp WHERE employe_id = employees.employee_id

)

-If you add condition while the lines are candidates for the copy (if not copied already copies)

AND employee_id = p_employee_id

Note that I added the prefix p_ your parameter for clarity!

Tags: Database

Similar Questions

  • I can compile new procedures/packages on my instant watch?

    Hello

    I can compile new procedures/packages on my watch to the snapshot ?
    I need to test the new version of the application, which include some changes to the current packages

    Thank you

    Yes, that's the purpose of the eve of the snapshot
    You can test your application with real data
    When you are finished, all changes will be devulcanization (flashback), and the standby database will follow the new primary side

  • Identify the name of the schema in a procedure/package

    My google-fu is totally miss you on this one and I have a method for doing this already, but there is an insidious sense that there is a better way to do it there.

    Basically I have two schemas that have the same procedures, packages, etc. in them (separate for reasons of risk; leaves do not enter the problem of duplication of code to maintain...!) and in a few, there are references to the schema to which belongs the package/proc/function (for example for analysis of tables). In order to avoid the schema name and the nightmare of maintaining different publication for different schemas, hard coding scripts I want to code in order to determine which schema it runs under.

    I can't use 'USER' as which shows the user connected, and I want the name of the owner of the code being run.

    I came with:
    select username from user_users;
    but as I said, I can't help but feel that there is a better way.

    Is there, and if there is, what is it please?

    This?

    sys_context (' USERENV', 'CURRENT_SCHEMA' ")

  • Difference of procedure package Vs

    In addition to an overload and private subprogrammes, what is the advantage of the procedure/function created within a packet on Stand Alone procedures in terms of performance.

    What will be the difference in the behavior of stand-alone procedure/function and procedure/function inside the package if both are called by 100 different user one by one. Will the charge procedure 100 times for each call or not?

    Can someone give me more clearity on these points:

    Best performance - packages can be compiled and are loaded into memory in full and not piecemeal as other methods. This advantage if at all there is minimal compared to other services.

    Invalidation reduced - change a package body does not invalidate the dependencies to change a function or procedure.

    Hello

    Kimmy says:

    Thanks for the links that I read the post before and then I posted this discussion for more clearity...

    Any code that is executed is loaded into the Cache of the bookstores and remain in the library Cache until it is aged by the LRU algorithm. So if there are a 100 calls to a stand alone procedures be there in the Cache/memory?

    If not why not?

    If Yes... So how this behavior differs from the behavior of charge of the public procedure within a package?

    There is nothing special about 100 calls.  A procedure (or package) might be aged after 1 call or after 100 calls, or it can remain in cache after 1 call or after 100 calls.

    The difference between stand-alone procedures and packages in this regard is that all remains in the cache, or gets old, together.  So if you have requested that a procedure in the package, as this package is cached, then the 1st time you call another procedure in this package it will already be in memory.

    Other differences between packages and stand-alone procedures:

    A package can have variables and types defined in package specifications and so can be used by other users.  (With the help of ouutside of package variables to the package, instead of using functions, maybe not a good idea, however.)

    Change a package body is invisible to dependent objects.  If you change just the package body, no other packages or views will be become disabled or need to be recompiled.

  • dbAdapter fails during the call to procedure package oracle object type in the parameter out

    JDeveloper 1.1.1.6

    Oracle 11g

    Existing package procedure is defined with the table of objects in input parameters and.

    Package myPackage

    procedure processRecon (numero_projet VARCHAR2,

    INST_ID select NUMBER,

    recon_type VARCHAR2,

    gis_design_stock GMPVT. GMPVT_GIS_DESIGN_STOCK_T,

    stock_uop GMPVT. GMPVT_STOCK_CODES_T,

    x_status OUT VARCHAR2,

    x_escalation OUT VARCHAR2,

    x_recon_error ON GMPVT. GMPVT_GIS_RECON_ERR_T) IS

    GMPVT. GMPVT_GIS_RECON_ERR_T is an array of GMPVT objects. GMPVT_GIS_RECON_ERR, who has 12 fields including the new I added it.

    I have added a new field to the GMPVT object. GMPVT_GIS_DESIGN_STOCK, where GMPVT. GMPVT_GIS_DESIGN_STOCK_T is a table of GMPVT. GMPVT_GIS_DESIGN_STOCK, no problems encountered during the test.

    Next, I added a new field for the object of type GMPVT. GMPVT_GIS_RECON_ERR, the following error below occurs when the DBAdapter is called

    < Summary > Exception occurred when the link was invoked. Exception occurred during invocation of the JCA binding: "JCA binding run operation 'processStockRecon' failed due to the reference: Interaction processing error." Error in the processing of applications from running. GMP_SOA_RECON_PKG. Interaction of the PROCESSRECON API. An error occurred during the processing of the interaction to invoke APPS. GMP_SOA_RECON_PKG. PROCESSRECON API. Cause: java.lang.ArrayIndexOutOfBoundsException: 12 check to make sure that the XML file containing the data of the parameter matches the parameter definition in the XSD. This exception is considered non reproducible, probably due to an error of modeling. ". The called JCA adapter threw an exception of resource. Please review the error message above carefully to determine a resolution. < / Summary >

    I confirmed that the XSD for the stored procedure has in fact change, which has been generated by JDeveloper as I refreshed the database adapter.

    The statement "Cause: java.lang.ArrayIndexOutOfBoundsException: 12" I can't that assume somehow SOA has 12 parameters but the 12 setting was not saved.

    Any thoughts on what I might be missing. I can provide more information if necessary.

    Hello

    This problem has been resolved. Not deployed SOA composite and then deployed to the server of the SOA. For some reason, SOA has been either you see does not changes in the file XSD (cached?) or the XSD was not get updated.

    Thank you

  • Cannot call procedure/package wwv_flow_load_data.create_csv_collection

    Hello

    I have a pl/sql code in a process page that calls a procedure in a package. He worked at point 3.1, but does not work in 4.0.1.00.03.
    declare
      l_first_row_is_col_name boolean := true;
      l_file_id               number := 0;
    begin
      select id
        into l_file_id
        from apex_application_files
       where name = :P50_FILE;
    
      :P50_FILE_ID := l_file_id;
    
     wwv_flow_load_data.create_csv_collection (
      p_file_id                => l_file_id,
      p_separator              => ',',
      p_enclosed_by            => '"',
      p_first_row_is_col_name  => l_first_row_is_col_name,
      p_currency               => '$',
      p_numeric_chars          => '.,',
      p_charset                => 'utf-8'
      );
    end;
    {code}
    
    here is the error:
    
    ORA-06550: line 12, column 2:
    PLS-00201: identifier 'WWV_FLOW_LOAD_DATA.CREATE_CSV_COLLECTION' must be declared
    ORA-06550: line 12, column 2:
    PL/SQL: Statement ignored
    
    1. declare
    2.   l_first_row_is_col_name boolean := true;
    3.   l_file_id               number := 0;
    
    
    It seems that the package/procedure is not valid so it is being interpreted as a variable, but it is valid in the schema APEX_040000.
    
    Any suggestions are appreciated.
    
    Thanks
    Matt                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            

    Hello

    I think that there is no synonym public wwv_flow_load_data.
    You must create an and control the privileges for the apex_040000.wwv_flow_load_data package.

    That is obviously not recommended because wwv_flow_load_data is the package without papers.

    Kind regards
    Jari

  • Security procedures/packages. Hide source code?

    Hello.

    I was wondering if it is possible to hide the source code of a procedure for a user or to avoid him to recreate it, but leave it to run it.

    Im doing a procedure of Lac sand which modify and run an external task. It works fine, but I see a lot of security holes. If any DB user who can execute this procedure can change too, they could run any command shell by modifying the attributes of external work. I could use the credentials (11.2.0.2) and somehow limit the use of the system to specific orders, but I want to fix the security hole by limiting the user DB limiting rather the user of the system.

    It is the external work
    BEGIN
    DBMS_SCHEDULER.CREATE_JOB(
    job_name => 'test',
    job_type => 'EXECUTABLE',
    job_action => '/bin/sh',
    number_of_arguments => 2
    );
    
    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
    job_name => 'test',
    argument_position => 1,
    argument_value => '-c'
    );
    
    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
    job_name => 'test',
    argument_position => 2,
    argument_value => '/bin/date>>/tmp/date.log'
    );
    END;
    / 
    And then the procedure.
    CREATE OR REPLACE PROCEDURE TEST_DATE_FILE ( new_file IN varchar2 )
    IS BEGIN
    DBMS_SCHEDULER.SET_JOB_ARGUMENT_VALUE (
    job_name => 'test',
    argument_position => 2,
    argument_value => '/bin/date>>/tmp/' || new_file
    );
    
    DBMS_SCHEDULER.RUN_JOB(
                                    job_name =>             'test',
                                    use_current_session =>  TRUE
                                    );
    END;
    /
    --
    SQL > conn scott/tiger
    Conectado.
    SQL > exec TEST_DATE_FILE('newfile.log');

    Procedure-PL/SQL terminado correctamente.

    SQL > CREATE OR REPLACE PROCEDURE SYS. TEST_DATE_FILE (new_file IN varchar2)
    2. IS BEGIN
    3 DBMS_SCHEDULER. () SET_JOB_ARGUMENT_VALUE
    job_name 4 = > 'test ',.
    5 argument_position = > 2,
    argument_value 6 = > "rm - rf/bin / / tmp / *'"
    (7);
    8
    9 DBMS_SCHEDULER. () RUN_JOB
    job_name 10 = > 'test ',.
    11 use_current_session = > TRUE
    (12);
    13 END;
    14.

    Created procedure.

    SQL > exec TEST_DATE_FILE (' ');

    Procedure-PL/SQL terminado correctamente.

    --

    It is possible to hide the source code of the procedure that edits and run the external procedure?
    There is no work around or any idea how I can avoid this?

    Concerning

    Published by: elvegaa_esp on 17-may-2012 02:41

    Published by: elvegaa_esp on 17-may-2012 02:43

    [email protected] > host wrap iname = test.sql oname = test_wrap.sql

    PL/SQL Wrapper: Release 8.1.7.2.0 - Production on Mon Jan 07 12:44:21 2002
    Copyright (c) 1993 Oracle Corporation, 2000. All rights reserved.
    Test.sql to test_wrap.sql treatment

    [email protected] > @test_wrap.sql
    [email protected] > create or replace procedure wrapped p
    2 0
    3 abcd
    4 abcd
    5-abcd
    6 abcd
    7 abcd
    8 abcd
    9 abcd
    10 abcd
    11-abcd
    12 abcd
    13 abcd
    14 abcd
    ABCD 15
    ABCD 16
    17 abcd
    18 3
    19 7
    20 8106000
    21 1
    22 4
    23 0
    24 4
    25 2: e:
    26 1 P:
    27 1DBMS_OUTPUT:
    28 1PUT_LINE:
    29 1Hello world:
    30 0
    31
    ...
    86.

    Created procedure.

    and now you do not have

    [email protected] > select text from user_source where name = 'P ';

    TEXT
    ----------------------------------------------------------------------------------------------------
    -------------------------------
    procedure wrapped p
    0
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    ABCD
    3
    7
    8106000
    1
    4
    0
    4
    2: e:
    1 P:
    1DBMS_OUTPUT:
    1PUT_LINE:
    1Hello world:
    0
    ...

    [email protected] >

    Published by: human Chen on May 29, 2012 11:26

  • Backup Tables, triggers and packages/procedures

    Oracle 11.2 and Developer SQL 3.2.

    For the backup of the data, I use OEM/Rman to schedule a backup.  My understanding, these are usually data only (physical backup).

    Now, I want to make the backup of the logic for the tables, packages/procedures and triggers.  I currently use Oracle SQL Developer to export as separate SQL files.

    I wonder if there are any other options to save the tables, procedures and triggers?

    Currently I am guard three types of backups:

    (1) creation of user scripts, role and grant the user privileges.

    (2) tables, packages/procedures and triggers saved via Oracle SQL Developer

    (3) data ora saved through OEM

    Total crash of DB, I'll run the script to create users, role, and grant privileges.  Then log in as an authorized user and run the sql scripts to create the tables, procedures, packages, and triggers; Finally, to recover the data via RMAN.

    Is this a good practice for backup/recovery, or there are ways to do better?

    Thank you.

    Scott

    scottjhn wrote:

    Oracle 11.2 and Developer SQL 3.2.

    For the backup of the data, I use OEM/Rman to schedule a backup.

    Additional OEM backup.

    The backup operation is made by rman.

    My understanding, these are usually data only (physical backup).

    RMAN backup of the physical database.  Technically, it makes copies of data blocks in the data files.  He does not know, nor she cares, that contains a given block.  And this data block "term" is wider than you can imagine.  Consider this: the entire database - tables, indexes, the data dictionary (which itself is nothing more than a collection of tables), stored the DDL, code compiled... everything fits in these data files and data files are all made up of blocks of 'data '.

    Now, I want to make the backup of the logic for the tables, packages/procedures and triggers.  I currently use Oracle SQL Developer to export as separate SQL files.

    I wonder if there are any other options to save the tables, procedures and triggers?

    That's what rman.  backup of tables, procedures, triggers,... everything.

    Currently I am guard three types of backups:

    (1) creation of user scripts, role and grant the user privileges.

    (2) tables, packages/procedures and triggers saved via Oracle SQL Developer

    (3) data ora saved through OEM

    Total crash of DB, I'll run the script to create users, role, and grant privileges.

    DB crash, you want to have a database to run these scripts.  You will FIRST need to restore/recovery database... backups rman.

    Then log in as an authorized user and run the sql scripts to create the tables, procedures, packages and triggers.

    ; You don't have to run all the scripts, because all the tables, procedures/packckages, and triggers will have already been restored by rman when he corrected/restored the database.

    Finally, retrieve the data via RMAN.

    And, precisely, what do you think this means at this point?

    Is this a good practice for backup/recovery, or there are ways to do better?

    There are much better ways.  Especially what you describe will not work.

    You have a serious misunderstanding on what rman is and does.  You need to spend some serious time, read the rman users guide, at https://docs.oracle.com/cd/E11882_01/backup.112/e10642/toc.htm

    And, FWIW, I would NOT recommend depending on the OEM manufacturer to plan backups or perform a recovery.

  • n packages practical procedures

    Hello
    I am a beginner as s/n...

    I want to learn more about procedures/packages...

    y at - it online to practice?

    Salvation;

    Please use google, you can find a lot of good site. Try this

    Search

    Respect of
    HELIOS

  • Call objects (packages-Pl/SQL procedures) DB of the ADF

    Hello

    1. How can we call DB procedures/Packages using ADF?

    2 are there scenarios describing when to use what Layout? & Also any introduction of layouts in the ADF.

    Thank you.

    Hello

    You can expose your PL/SQL package in the form of web services as well and use it on your layout. Check this blog entry on the call of PL/SQL of the ADF, it may be useful
    http://baigsorcl.blogspot.com/2010/05/calling-PLSQL-procedure-and-function-in.html

    This presentation would help understand layouts http://blogs.oracle.com/shay/2010/05/adf_faces_layouts_demo_-ahid.html
    also, you can refer to the guide of the web user interface.

  • Record Type in need help package tests

    Hello

    Please can you help me in the record Type of tests that I defined as:

    I said record Type in the package TEST_PART_PKG

    CREATE OR REPLACE PACKAGE TEST_PART_PKG AS

    TYPE req_line_rec_type () IS RENDERING

    PART_NUMBER VARCHAR2 (100),

    part_line_num NUMBER,

    part_name VARCHAR2 (100),

    part_po_number VARCHAR2 (100),

    un_number NUMBER,

    part_class VARCHAR2 (20).

    part_org_name VARCHAR2 (50));

    TYPE req_line_tbl IS TABLE OF THE req_line_rec_type

    INDEX OF DIRECTORY;

    PROCEDURE update_part_line)

    IN OUT NOCOPY p_req_line_tbl req_line_tbl,

    p_init_msg IN VARCHAR2,

    p_req_line_tbl_out OUT NOCOPY req_line_tbl,

    p_req_line_err_tbl OUT NOCOPY req_line_tbl,

    p_submit_approval IN VARCHAR2,

    x_return_status OUT NOCOPY VARCHAR2,

    x_error_msg OUT NOCOPY VARCHAR2,

    p_commit IN VARCHAR2);

    END;

    I want to test the procedure in the package passing variables but how to approach to it?

    I want to call the procedure packaged using:

    DECLARE

    BEGIN

    TEST_PART_PKG. update_part_line

    END;

    v_req_line_out and v_req_line_err are the parameters, so they do not need initialization, just definition what is the procedure to put something that is.

    We can only guess the purpose of these two parameters. Maybe you need to separate the records updated the destination of those that out wrong for further treatment table and that you are able to present a table of rows to update the destination table, the two parameters must be tables of rows as in general, more a single record can be the source of updated and more than one record can mistake.

    Concerning

    Etbin

  • Run the package to a different schema

    Hi all

    I have a very strange (at least for me) problem with a package to run in the production environment.

    The package has been installed in the application schema and in the same schema for all tables that are in the same table.

    The customer reported a slowdown in the performance of it, but if I test it in my PR env and:

    -If I run the application outside of the package, it run very fast

    -If I install the package in my personal schema and run it, it run very fast

    -If I run the package, installed on the application's schema, is very slow!

    What is the difference between these three methods?

    Thank you in advance,

    Diego

    91ca5e2c-8db6-4563-9e70-c98e10acf2ad wrote:

    OK, to start my procedure I used Notepad anonym in plsqldeveloper:

    Start

    Appuser.pkgapp.prcursors (vcode =>: vcode, pcursor =>: pcursor);

    end;

    when I try to get the cursor, with plsqldeveloper, I have different response time for:

    -package in my user-> very fast

    -package to the user of the application-> very slow

    OK - but that the above code does not recover. All this shows is a call to the procedure who, do you think, does that open the cursor.

    Once a cursor is opened the procedure who opened it has NO control over it. Only the session making the recovery is involved as is an Oracle process on the backend. But the procedure/package is NOT involved.

    If the location of the package does NOT affect actual recovery, but it can affect the execution plan used when the cursor is opened first.

    New - when you say "run the code" you tell fetch data? Or are you talking about just open the cursor as the example above shows?

    Display actual execution plan - get it from a trace file, if you need to.

    other things to say is that the number of lines to get out are some ten years.

    The question is always this THAT IS SLOW? It is the RECOVERY of these lines "a few ten at most? Or is it just open the cursor so that you can begin to pick up?

    You need to SHOW US (just tell us):

    1. WHAT you do

    2. HOW you do

    3. WHAT results you get

    4. WHAT results you expect to get

  • How to find recently created procedures in the current schema?

    Hi all

    in which oracle table I find recently created procedures with data timestemp as well?

    Thank you.

    Kind regards

    Robert

    Hi Robert,.

    Watch dba_objects or all_/user_objects.

    Something like that for the last day:

    select *
      from dba_objects
     where LAST_DDL_TIME > sysdate -1
       and OBJECT_TYPE in ('PROCEDURE','PACKAGE','PACKAGE BODY','FUNCTION')
       and owner = '';
    

    concerning

    Kay

  • Reg: DDL within a procedure.

    Dear Experts,

    Can we have a DDL inside a procedure/package. Here is the sample code for reuse by the members of the team if any change should be done.

    Could you please clarify for me / guide me, it is the right approach or would there be effects or is - this cool by oracle or not.

    CREATE OR REPLACE

    PROCEDURE ALTPRC)

    TNOM IN VARCHAR2,

    NAME OF COLUMN IN VARCHAR2,

    DTYPE IN VARCHAR2)

    IS

    VSQL VARCHAR2 (100);

    BEGIN

    VSQL: = 'alter table ' | TNOM | 'Add'. COLNAME | » '|| DTYPE;

    DBMS_OUTPUT. Put_line ('Alter Stmt: ' |) VSQL);

    RUN IMMEDIATELY VSQL;

    END;

    ALTPRC EXEC ('emp1', 'testcol', 'number');

    Thank you

    Can do us, YES. Should do us, (there are always exceptions) most of the time no..

    Issue DDL COMMIT before and after the statement. So, it cannot be part of a transaction. A good DB design will not data structure allow to change on the FLY. A good application handles changes to dictionary in a version control system.

    So can you share with us what kind of benefits you are searching by an alter as statement

    ALTPRC EXEC ('emp1', 'testcol', 'number');

    to the course to do as

    ALTER TABLE EMP1 ADD COLUMN TESTCOL NUMBER;

    One of the reasons could connect. But I can't find satisfactory as a reason to do it this way.

  • debugging on the procedure to grant

    I've been looking for a way to allow a user to view the package body in another scheme that was not SELECT ANY DICTIONARY for awhile now and I happened to find it by chance today. I looked more into this private, but it doesn't seem to be more explanation on WHAT debug allows actually.

    Apart from allowing another user to see a package or procedure body, anyone sees any problems with granting of DEBUG on a procedure/package?

    Thanks in advance!

    Jeremy

    PRIVILEGES OF OBJECT TYPE

    The following object type privileges allow operations on a database object type.

    DEBUG

    Access, via a debugger variables public and non public, methods and types defined on the object type.

    Place a breakpoint or stop at a line boundary or statement in the body of the type.

    Is your database & you can use (ab), it doesn't matter what way you consider appropriate

Maybe you are looking for

  • How to make iTunes automatically recognize the location of my iTunes library?

    I have my iTunes library on an external hard drive (all files).  Works fine when the drive is connected to the MacBook.  Recently, I decided that instead of having hung the MacBook hard drive all the time, I could connect it permanently to the networ

  • Make the bottom of boarder indicator less and transparent (invisible)

    Happy new year to all. Y at - it an easy way to get the feature in the image below: I want zeros "BOLD" to terminals on the diagram I can update.  Don't you think by saying that the top of the page game seems better than the bottom? Kind regards Lewi

  • What are the error messages you see in the window "run/eventvwr"?

    I received the phone call from "Microsoft Service Center" (guess it's scam) but when they took me to run eventvwr/I had several mistakes - this is significant.  Their website has been ammyy.com.  Someone at - he heard of this?

  • Windows 7 on 3000 N200 0687?

    Hi all I have a Lenovo 3000 N200 0687 - computer A11 laptop, and I am wandering if anyone has installed Windows Se7en on your laptop like mine, and I would like your comments how it works and if there is no problem? I'll install dualboot - with XP. T

  • Creating connectable common user to database is closed

    HelloIn Oracle 12.1.0.2 on Windows 7, I have a tablespace TEST in my CBD and my PDB is currently closed while I create a common C ##TEST user in my CBD with tablespace default TEST. According to the literature, APB to synchronize with the CBD when I