How to include a message of output in a procedure

Hi guys,.

I have the procedure, where I need to include a query of exit message, please help me.

The procedure is:

create or replace procedure insert_data_employees (p_name in varchar2, p_acess_level in numbers) as

v_Name varchar2 (100);

number of v_uname;

Begin

If p_name is not null then

BEGIN

Select COUNT (1) in the v_uname of employees

where

Upper (p_name) = upper (name);

Exception

WHEN NO_DATA_FOUND THEN

v_uname: = 0;

END;

End if;

INSERT INTO employees

(name, rol_id, emp_number, creation_date) VALUES

(EMPLOYEES_DATA_SEQ,

regexp_replace(p_name,'(.*)@.*','\1'),

p_acess_level,

SYSDATE

);

COMMIT;

end insert_data_employees;

If I write the query in the form:

create or replace procedure insert_data_employees (p_name in varchar2, p_acess_level in numbers, some o_return_code number)

How to include under conditions in the procedure? How can I represent the successful and failed integration in a query?

a. If successful insertion, then o_return_code = 0

b. If insertion failed so o_return_code = - 1

Please help its urgent...

You can use the cursor SQL SQL and FOUND for this % NOTFOUND attribute.

create or replace procedure insert_data_employees(p_name in varchar2,p_acess_level in number) as
v_name varchar2(100);
v_uname number;
Begin
if p_name is not null then
BEGIN
select COUNT(1) into v_uname from employees
where
upper(p_name) = upper(name);
Exception
WHEN NO_DATA_FOUND THEN
v_uname:=0;
END;
End if;
INSERT INTO employees
(emp_number, name,  rol_id, creation_date) VALUES
( EMPLOYEES_DATA_SEQ,
  regexp_replace(p_name,'(.*)@.*','\1'),
  p_acess_level,
  SYSDATE
  );
  IF SQL%NOTFOUND THEN
  o_return_code := 1;
    dbms_output.put_line('Records inserted');
  ELSIF SQL%FOUND THEN
    o_return_code := 0;
    dbms_output.put_line('Nothing inserted.');
COMMIT;
end insert_data_employees;

I have not tested the code in my DB.

Tags: Database

Similar Questions

  • Question about how to include the virtual machine output

    Currently, using this command:

    Get - vm | Get-networkadapter | ForEach-Object {Write-Host $_.} The name', ' {$_.macaddress} '.

    Gives me this result:

    NIC 1, 00:50:56:bc:00:1 c

    NIC 1, 00:50:56:bc:00:28

    I'm interested also in writing the name of real virtual machine as well.

    name of the virtual machine 1, NIC 1, 00:50:56:bc:00:1 c
    name of the virtual machine 1, NIC 1, 00:50:56:bc:00:28

    Don't know how to work out of virtual machine name as 'Name' asks also the network card information.

    Try it like this

    $report = foreach($vm in (Get-VM | where {$_.PowerState -eq "PoweredOn" -and $_.Version -eq "v7"})){
        Get-NetworkAdapter -VM $vm  | `    Select @{N="VMname";E={$vm.Name}},
             @{N="MAC address";E={$_.MacAddress}}
    }
    
    $report | Export-Csv ".\test.csv" -NoTypeInformation -UseCulture
    
  • How to format the message in the response

    Hi all

    Please let me know how to format the message in the response.
    Sorry this is not the case associated with sql, plsql. I went in the way of asking questions in the forums oracle instructions. But I did not find. Help, please...

    I know this: when I write my thread I use
    .. to format  the code ,but while replying how to include post with formatted text. 
    
    
    Thanks,
    P prakash                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                

    >

    Thanks for the reply, I would like to know how you included the message formatted in your answer.
    Please let me know this...

    Hi again Prakash,

    Easy - just put ">"at the beginning lines you want to quote. "

    That is higher and space - when you answer, hit the double quotes in the bar
    at the top of the post - last symbol to the right and it will be automatically
    the post to which you want to reply.

    HTH,

    Paul...

  • How to remove the message "not using current Version" boring?

    For months, my Firefox home page included a note that I do not have the latest version and provides a link to update. When I use the link I said "Congratulations, you are using the latest version." Adding insult to injury, there are not 20 minutes, I downloaded 27, and the message is still there. Almost the end of the world, but at this point, it is very annoying. How to remove the message?

    The old page of Google-Firefox has not changed since Firefox 4 is released, please disregard the information updated on this page.

  • How do I save messages in iCloud on iPhone

    How do I save messages in iCloud on iPhone

    Messages are included in the iPhone backup, so back up your phone.

  • How to activate the message window to run from published resources

    HI -.

    Can someone tell me how to activate the message window, or something similar, to executing the script trace published resources.

    While I can use the message of the Director IDE window, what I want to do is use it when I execute scripts in time real (published resources).

    So my question is confused or upset the terminology, I apologize.

    I am very new to the use of Director (11.5).

    Thank you very much.

    Bob

    You can consult the help file of the Director for more details (minimum). You will see output in the message window when your code runs a statement 'put' (or 'trace'). However, you can use it as you would the application Message window by execute arbitrary code when you press ENTER at the end of a statement (without comment).

    Your whole project works like a projector or in Shockwave (in a browser)?

  • How to transfer your messages to the iPhone 6 for macbook

    GGetting a new iPhone would like to keep the messages from the old iPhone 6 on my MacBook. How do you download messages from the iPhone to MacBook.

    You do not have.

    The messages are only "moved" via a backup and restore. You cannot back up a phone and restore it on a Macbook.

    The 'sync' messages in the future, is to connect to Messages on the macbook with the same Apple ID on your phone. Now all messages will be received by the phone and Macbook.

    For your old messages, you will need to copy and paste into emails or Notes and sync them to your Macbook.

  • I, a, mini, 2, pad, apple, my question is, how, do, I, delete, messages, on, messengers?

    I have an ipad Apple Mini 2 & I need to know how to remove the messages that I have received from others on messenger... can't find a deletion or anywhere to get rid of the communications. Can someone help me on this problem?

    Thank you

    In the list of messages in the right sidebar, select the message yo want to delete and right-click and select remove this conversation. Note that the entire conversation is deleted

  • How to prevent (text) messages to display on my tv using my iPhone to the apple tv airplay?

    How to prevent (text) messages to display on my tv using my iPhone to the apple tv airplay?

    If you use, you can not, since that's what mirroring is mirroring, it reflects your screen. If the content you watch support it try to turn the mirror off the coast and just use airplay to base.

  • How to recover deleted messages, I really need to have access to thank you legal purposes

    How to recover deleted messages, I really need to have access to thank you legal purposes

    Messages which means mail?

    Restore from an iCloud or iTunes backup...

  • How can I delete messages in my Inbox. What is the profile folder

    Messages in my Inbox had a large red cross on them when I delete all of them, but it does not actually delete the message. In the instructions on how to fix this he begins by saying open a profile folder or something. WELL... If I know what they're talking about!
    Please explain how to simply delete messages in my Inbox > please, do not assume I know nothing so please do the simple instructions.
    Thank you. Terry Craig

    It must be something IMAP because there is no option under settings server settings for the account on my pop accounts

    Happy that you guessed it sorted.

  • How to forward a message to a list?

    Send a message to a list only works if you start with the address book window. In this case, you select the list in the left panel, which causes all of the individual addresses in the list appear in the right panel. Then you select the individual addresses in the right panel, right-click on it and select "write". This puts all the individual addresses in ' to the ' fields in a message of the Virgin. But what about when you have a message you want to move or change as New? In this case, you do not go with the address book window, you have access to the Contacts Panel in the window of writing. If you select the list in the Contacts Panel and add in the field 'To', it only adds the name of the list, Thunderbird notifies you is not a valid email address. How to forward a message to a list?

    is the name of the list has a space? Remove it to work around a bug in Version 31

  • "How to stop this message"do you want to install the plugin required to view media on this page.

    How to stop this message "do you want to install the plugin required to view media on this page.

    I don't need the plugin to play the video ok

    If it comes from the Flash plugin you can switch pref plugins.notifyMissingFlash false on the topic: config page.

    You can open the topic: config page via the bar of address and you can accept the warning and click "I'll be careful" to continue.

  • How to print all messages in a forum url?

    How to print all messages in a forum url?

    Firefox is not a built-in feature to open all the links on a page or to print the pages automatically. However, there could be some add-ons that would help you to do so. You could search the Web, or try the site of modules:

    https://addons.Mozilla.org/Firefox/

    Alternatively, you can find a separate program to do, has its own integrated browser or using the connectivity features built into Windows.

  • How do we uninstall 'messages '?

    How do we uninstall 'messages '?

    Then, I want to be able to use ichat

    Messages replaced iChat back in OS X Mountain Lion.

    It's pretty much has most of the features that had iChat, so you might as well use Messages.

Maybe you are looking for