Why we use Procedures?

Hi Friends,
I would like to know about procedures in using real life.I m confuse about the use of it.Please help me out.......
1.Why we use Procedures?
2.Where we use procedures in real life?
3.Can we insert 100 of records in a table through a procedures?
4.is it good to insert through procedures?

kindly refer below code but i sure if u google around u will find a lots of answer.
for me procedures is a small programs just like other programming language and your code will be more easy to manage and more faster in debugging process.
The syntax for a procedure is:
CREATE [OR REPLACE] PROCEDURE procedure_name
[ (parameter [,parameter]) ]
IS
[declaration_section]
BEGIN
executable_section
[EXCEPTION
exception_section]
END [procedure_name];
When you create a procedure or function, you may define parameters. There are three types of parameters that can be declared:
IN - The parameter can be referenced by the procedure or function. The value of the parameter can not be overwritten by the procedure or function.
OUT - The parameter can not be referenced by the procedure or function, but the value of the parameter can be overwritten by the procedure or function.
IN OUT - The parameter can be referenced by the procedure or function and the value of the parameter can be overwritten by the procedure or function.
The following is a simple example of a procedure:
CREATE OR REPLACE Procedure UpdateCourse
( name_in IN varchar2 )
IS
cnumber number;
cursor c1 is
select course_number
from courses_tbl
where course_name = name_in;
BEGIN
open c1;
fetch c1 into cnumber;
if c1%notfound then
cnumber := 9999;
end if;
insert into student_courses
( course_name,
course_number)
values ( name_in,
cnumber );
commit;
close c1;
EXCEPTION
WHEN OTHERS THEN
raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
END;
This procedure is called UpdateCourse. It has one parameter called name_in. The procedure will lookup the course_number based on course name. If it does not find a match, it defaults the course number to 99999. It then inserts a new record into the student_courses table.

Similar Messages

  • Why I Can't use procedure in select statement

    Why I Can't use procedure in select statement

    We can use function in select statement but we couldn't use procedure with one out parameters in select statement... You can use Function because they are designed for this but procedure are not. Functions can return value (without OUT parameter) which can be used in SELECT whereas procedures do not have such concept. As you can see in the above post you can not call even functions also if it has any out parameter.
    I have just trying to use procedure in select statement ..for this I require technical answer..The technical answer is because conceptually procedure is for doing set of operation, performning DMLs on the tables , whereas functions are for processing and producing a single result. Functions are basically for not using INSERT/UPDATE/DELETE in it. That is the reason they are allowed to be used in SELECT because conceptually they are not supposed to do any data changes.
    Regards,
    Avinash

  • Why we use Tables statement in case of using SELECT-OPTIONS:

    hi all,
    Why we use Tables statement in case of using the following coding in an ABAP program ...
    tables: vbak.
    SELECT-OPTIONS: s1 for vbak-vbeln.
    here if we dont provide the tables statement why it does not work ????
    pls answwer ....???

    Hi
    This statement is not allowed in classes and declares a data object table_wa as a table work area whose data type is adopted from the identically named structured data type table_wa from the ABAP Dictionary. table_wa must be defined as a flat structure in the ABAP Dictionary. You can specify database tables or Views for table_wa.
    Work table areas declared with TABLES are interface work areas and should only be declared in the global declaration section of a program for the following purpose:
    reward if usefull
    The statement TABLES is required for exchanging data between screen fields that were defined in a program screen when transferring from the ABAP Dictionary and the ABAP program. For the screen event PBO, the content of the table work area is transferred to identically named screen fields; for PAI, the system adopts the data from identically named screen fields.
    In executable programs, flat table work areas can be used for adopting data that were provided for the event GET table_wa from a linked logical database. TABLES is synonymous with the statement NODES for this purpose.
    Work table areas declared with TABLES behave like the data declared with the addition COMMON PART, meaning the data are used by the programs of a program group.
    Table work areas declared with TABLES can be declared in subroutines and
    function modules. However, this is not recommended. A table work area declared in a procedure is not local but belongs to the context of a framework program. The table work area can be viewed starting from the declaration in the framework program and lives as long as the framework program. In contrast to normal program-global data, the content of the table work areas declared in subroutines and function modules is stored temporarily when these subroutines and function modules are called. Value assignments that were made during runtime of the procedure are preserved until the procedure is completed. When exiting the procedure, the table work areas are filled with the contents that they contained when the procedure was called. Table work areas declared in procedures behave like global data to which the statement LOCAL is applied in the procedure.
    The form TABLES * is obsolete.

  • Why IPC uses CRM as database and not R/3 ?

    Hi ,
    can any one help me with an answer for the following question :
    <b>Why IPC uses CRM as database and not R/3 ?</b>
    Points will be rewarded for helpful answer
    thanks
    ritu

    Hi
    IPC have Sales Pricing Engine, Pricing Configuration engine and TTE which helps to maintain the similar R3 pricing settings. As you are aware pricing in R3 is determined by Sales area, Cupp, DPP, so IPC is capable of determining the Pricing using same R3 standard procedure. T
    This is not available in CRM, so CRM needs IPC to undertake the determine pricing/ calculate the pricing of the products.
    Regards
    Nagarj

  • Why nokia uses very cheap plastic for N79?

    I bought a Nokia N79 for 350 € one month ago. Although my ultimate care and even I used a special protecting case for the phone, there were little scratches all over the front plastic cover. I wonder why nokia used very cheap plastic on the front cover for a very expensive mobile phone?

    Volume increases in 10 steps and last step, from 90 to 100% is like someone that suddenly turn a 1000w speaker right in your ear. :-) This is not normal and it was so easy to fix before to sell this phone. Maybe no-one tryed the phone before to sell it.
    Album Art search is an automatic procedure from iTunes to Winamp. I don't have to use pcsuite, don't have to download from phone. Btw it doesn't appear, better than an error.
    Let me say, about the clock alarm. I'm a doctor. To have something complete to make quick photos to wounds, procedures and so on or make videos, I thought this could be a great phone. I used the phone alarm of this phone only two times and never use it again. I lost a morning appointment and to awake for the night turn. It sound funny now, but let's try to imagine my anger when for years I used a cheaper phone, never getting late. I don't sell nuts, with all of my respect for nuts seller.
    Why do I have to use another piece of software when the included one should function? It is like to harvest an arbor because it doesn't give you fruits without trying to think why and look for a solution. Did I give too much water? Is it infested by some bugs?
    Symbian UIQ, rest in piece, decided to use Opera Mini as defalt browser. That is a cure. If Symbian OS doen't want to use it has to solve its bugs quickly or send an advice through that stupid My Nokia service saying that browsing experience will not be so easy.
    You buy a phone because you don't want a Ferrari. You buy a phone for the specifications write on the box. In Florence, you can't try the phone before, sorry man. It would be really nice but you can't. You buy for radio and radio doesn't work, you buy for camera and shoot button doesn't do auto-focus, (now repaired), you buy for a simple mp3 player and you are going to lose audition, you buy for a phone and thanks God it works . You give every single cents hoping for a positive experience and you change manufactuer because this one gives you - now - what you are looking for. I'm not a SE, Motorola or Nokia fan. I read reviews and compare trying to have an idea. That's what we do, all of us.
    I respect your point of view about S60, I am excited about wonderful programs to watch divx - by the way tv-out is choppy, ugly and something to not try if you have an n79; I thought it could be wonderful for my presentation... let's forget it - to do sport and to buy some useful cheap, read the humour, map for Nokia Maps. No, really I know this is a great software, I love open source and hope that will arrive more and better apps when it will be open, but you buy a phone for what's on. Not for what it could do in future with bug fixes. Tomorrow I will sell it and maybe never see that bug fixed.
    An example: Apple. IMHO is getting worst that before. I'm not an Apple fan but I have to admit that it knows how to work with software and hardware. It prefeared not to put mms and other functions on its iphone because...
    ...who knows. The point is: less software to fix means better experience for end-user and quality of firmware releases. With three, or something similar, releases Apple covered many of what the users cryed for in less than two years. Remember, every basic function was at best. Nokia sold n79 and 5800 quite in the same time. Firmware release of n79 was ridicolous, 14 pages of fw after four months? What did you sell it for Nokia? Wait four months more. 5800 is an interesting phone, different from the iphone, full of great features and great bugs.
    At the end, I respect your idea of evolution of a phone and its getting better day by day, while I need that a phone is ready to go since first start even with some bug, because noone has no bug, but not ridicolous bugs. That's why Nokia pi22ed me off with this n79.

  • Why when using Adobe Bridge,  I apply a star rating,  the rating does not show up in Photoshop Elements? [tags]

    Why when using Adobe Bridge,  I apply a star rating,   the rating does not show up in Photoshop Elements.  I use Elements as my organizer and Bridge to view as it is much more user friendly.  Anyone any solutions??

    Most likely you have set the wrong file as the external editor. You don't want the obvious one; that's just a link to the welcome screen. Go back and choose this one, which is hidden away inside the folder Support Files:

  • I want to ask something about firefox. why firefox use very much memory? can you develop to reduce memory comsume? this problem is very distrub in my PC with low memory.

    I want to ask something about firefox.
    why firefox use very much memory?
    can you develop to reduce memory comsume?
    this problem is very distrub in my PC with low memory.
    == This happened ==
    Every time Firefox opened

    How much memory is Firefox using right now?
    # Press '''CTRL+SHIFT+ESC''' to load the Task Manager window
    # Click the Processes tab at the top. (Click once near the top of the window if you don't see tab
    # Find firefox.exe, and see how many kilobytes of memory it's using.
    Showing around 80MB when Firefox first starts is normal. Right now, I have 75 tabs open and it's using 500MB - this varies a lot depending on what you have in the tabs.
    Other than high memory usage, what other problems are you experiencing? (Examples include slowness, high CPU usage, and failure to load certain sites)
    Many of these issues, including high memory usage, can be caused by misbehaving add-ons. To see if this is the case, try the steps at [[Troubleshooting extensions and themes]]. Outdated plugins are another cause of this issue - you can check for this at http://www.mozilla.com/plugincheck

  • Execute Dynamic SQL statement using procedure builder

    i want to execute a dynamic SQL statment using procedure builder not using forms
    because my statement depending on a variable table name
    i know that i can do that from forms using
    FORMS_DDL('SQL_STAT');
    but i wanna to use the procedure builder
    which function i should use and how?
    please explain in example if you don't mind.
    thanks

    Hi,
    You can very well use DBMS_SQL Package supplied by Oracle for doing this.
    Search for DBMS_SQL in OTN. You will get all info regarding this.
    Regards.
    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by itslul:
    i want to execute a dynamic SQL statment using procedure builder not using forms
    because my statement depending on a variable table name
    i know that i can do that from forms using
    FORMS_DDL('SQL_STAT');
    but i wanna to use the procedure builder
    which function i should use and how?
    please explain in example if you don't mind.
    thanks<HR></BLOCKQUOTE>
    null

  • Why we use different clearing account for GR/IR and planned cost clearing a

    My client ask for using same account for GR/IR account and all planned cost clearing account.
    i try to convince it should be different accounts but he needs a logical answer.
    Why we use different clearing account for GR/IR and planned cost clearing accounts?

    Dear friend.
    u just tell him while doing GR it will debited n  while doing IR it should get credited.hence we  need to take diff G/L account or same account.
    regds
    nasir

  • HT201343 My MBP is Early 2011 but dunno why cant use mirroring with apple TV, the icon cannot be found

    My MBP is Early 2011 but dunno why cant use mirroring with apple TV, the icon cannot be found. So cannot use mirroring.
    I have follow trouble shooting , they recommend to go system preference -> display , thus can find out the mirroring icon if no mean it doesnt support. But according to the web, Early 2011 MBP should be able to use, dunno why.

    Just realise I havent updated my OS to mountain lion and this is the reason why I cannot use mirroring before ^^
    Thanks all

  • How to update the data in sqlserver table using procedure in biztalkserver

    Hi,
    Please can any one answer this below question
    how to update the data in sqlserver table using procedure in biztalkserver
    while am using executescalar,typedprocedure getting some warning
    Warning:The adapter failed to transmit message going to send port "SendtoSql1" with URL "mssql://nal126//MU_Stage2?". It will be retransmitted after the retry interval specified for this Send Port. Details
    Please send me asap....
    Thanks...

    Hi Messip,
    A detailed error would have helped us to answer you more appropriately but
    You can follow the post which has step by step instructions, to understand how to use Stored Procedure:
    http://tech-findings.blogspot.in/2013/07/insert-records-in-sql-server-using-wcf.html
    Maheshkumar
    S Tiwari|User
    Page|Blog|BizTalk
    2013: Inserting RawXML (Whole Incoming XML Message) in SQL database

  • What is the intelligent calc? Why we use that?

    If u loads data to parent level where data will be stored?
    What r the unary operators?
         How do u decide dense & Sparse?
         What is the header? Why we use header in the rule file?
    Please give me reply dont say read dabg
    Thank u.......

    OK,
    You have a database/application.
    1. You might have had run the calculation( ie calc script).
    2. after that , you might have loaded the data ,i.e you have infused new data and new data blocks.
    3. For these new data blocks ,you have not run the calculation so far
    4. so, now the intelligent calculation come into picture, with the help of the intelligent calculation concept, we can run the calculation on only the new data loaded or on only new data blocks,which you loaded
    Hope this helps you in understanding the intellligence calculation in short.
    One can enable and disable at his comfort ,and for that please refer to the following commands
    SET UPDATECALC
    SET CLEARUPDATESTATUS
    this is to answer you intelligent calc.
    1. when you load data into the parent level , it ll be stored at the parent level only.
    2. when you go to "Dimension"' tab of the database properties, you can get which one is dense or sparse
    3. in general ,you have a datafile ,and the upper most line is the one ,which has headers,so manipulate the same ,you use headers in the rule file.
    I have not told you to refer DBAG , :)
    But, you got to read DBAG or pick a bootcamp for you to understand further .
    Sandeep Reddy Enti
    HCC

  • Using Procedure in SQL statement

    Dear Sir,
    As you know, I can use any function in SQL statement. For example:
    SELECT systimestamp,
    Function_Name(variable1, variable2,...)
    FROM anytable;
    So the previous function could only retrieve one value -as functions concepts-. Anyhow, Can I, in someway, use Procedure that take multiple in parameters and return multiple out parameters in SQL statement.
    Thank you in advance.

    Sir,
    I got a way in order to use the benefit of procedure in function. It's trough your idea in using TYPE OBJECT as the following:
    ===================================================================
    create or replace type Missed_Txn_type AS OBJECT
    (Txn_Timestamp_obj timestamp,
    Txn_Type_Obj Number(12));
    ===================================================================
    Then I created function and used this type as returned value:
    FUNCTION Get_Shift_Missed_Txn_Obj(F_Date_In     Date,
                        F_Time_In Timestamp,
                        F_Employee_Id     number)
    RETURN Missed_Txn_type;
    The issue is: I want send the variables of the function through SELECT statement which they come from another table like:
    SELECT
    EMP.ID,
    sd.date_value,
    shf.Time_In,
    T.OBJ.Txn_Timestamp_obj,
    T.OBJ.Txn_Type_Obj
    FROM
    EMPLOYEE EMP,
    Stored_Date SD,
    Shifts shf,
    (select Get_Shift_Missed_Txn_Obj(sd.date_value,
    shf.time_in,
    EMP.Id) OBJ from dual) T
    WHERE
    [where clause]
    But the previous statement returned an error shows that it couldn't determine the (EMP.ID, shf.time_in, sd.date_value...)...
    And the same if I use it in the select list!
    So sir, there is any way in order to solve this issue?
    Thank you in advance.

  • Table name input. and output i need  all rows and columns  using procedures

    hi,
    question: table name input. and output i need all rows and columns by using procedures.
    thanks,
    To All

    An example of using DBMS_SQL package to execute dynamic SQL (in this case to generate CSV data in a file)...
    As sys user:
    CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
    GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
    /As myuser:
    CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
                                         ,p_dir IN VARCHAR2
                                         ,p_header_file IN VARCHAR2
                                         ,p_data_file IN VARCHAR2 := NULL) IS
      v_finaltxt  VARCHAR2(4000);
      v_v_val     VARCHAR2(4000);
      v_n_val     NUMBER;
      v_d_val     DATE;
      v_ret       NUMBER;
      c           NUMBER;
      d           NUMBER;
      col_cnt     INTEGER;
      f           BOOLEAN;
      rec_tab     DBMS_SQL.DESC_TAB;
      col_num     NUMBER;
      v_fh        UTL_FILE.FILE_TYPE;
      v_samefile  BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
    BEGIN
      c := DBMS_SQL.OPEN_CURSOR;
      DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
      d := DBMS_SQL.EXECUTE(c);
      DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
      FOR j in 1..col_cnt
      LOOP
        CASE rec_tab(j).col_type
          WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
          WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
          WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
        ELSE
          DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
        END CASE;
      END LOOP;
      -- This part outputs the HEADER
      v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
      FOR j in 1..col_cnt
      LOOP
        v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
      END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
      UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      IF NOT v_samefile THEN
        UTL_FILE.FCLOSE(v_fh);
      END IF;
      -- This part outputs the DATA
      IF NOT v_samefile THEN
        v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
      END IF;
      LOOP
        v_ret := DBMS_SQL.FETCH_ROWS(c);
        EXIT WHEN v_ret = 0;
        v_finaltxt := NULL;
        FOR j in 1..col_cnt
        LOOP
          CASE rec_tab(j).col_type
            WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
                        v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
            WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
                        v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
            WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
                        v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
          ELSE
            v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
          END CASE;
        END LOOP;
      --  DBMS_OUTPUT.PUT_LINE(v_finaltxt);
        UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
      END LOOP;
      UTL_FILE.FCLOSE(v_fh);
      DBMS_SQL.CLOSE_CURSOR(c);
    END;This allows for the header row and the data to be written to seperate files if required.
    e.g.
    SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
    PL/SQL procedure successfully completed.Output.txt file contains:
    empno,ename,job,mgr,hiredate,sal,comm,deptno
    7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
    7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
    7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
    7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
    7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
    7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
    7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
    7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
    7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
    7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
    7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
    7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
    7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
    7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
    Adapt to output different datatypes and styles are required.

  • Why to use B2B when we can go with ...

    why to use B2B when we can go with A2A with FTP services running in the source and target systems.
    why do we go for parties if the above one is possible.
    plz help out im into loads of confusion

    Hi
    A2A is application to application: when two applications in a company talk to each other we call it an A2A scenario and if its across Companies we call it B2B or buisness to buisness scenarios.
    All the following links will explain   the difference between A2A and B2B
    With scenario’s
    A2A   B2B Scenarios
    can anyone explain A2A & B2B  AND  BPM & ccBPM  with an example..
    Help for Scenario! B2B or A2A
    A2A Vs B2B
    A2A and B2B
    I hope this will answer your question
    regards
    --- prasad

Maybe you are looking for

  • Why is Mail  creating multiple trashes of an email while I'm composing it? +++++

    Hi Guys:   Mail has been doing weird stuff since I upgraded to Maverick.  Today was a new one.     I was composing and email to a friend and went to find an old related one. In doing a serch for it. I discoverd that the e:mail I was now composing was

  • Installation of Adobe Acrobat 5.0 in Windows 7

    I tried to install Acrobat 5.0 to my Windows 7 without sucess

  • SAPGUI JAVA 7.10 rev 3 (OSX 10.5.2): ALV reports freeze

    Dear All, I've tried to use rev 3 of sapgui for java for mac osx. I have serious issues with ALV reports that makes it unusable (rev 2 is ok so far). With big lists ALV freezes after showing about half of the first screen lines. Is anyone experiencin

  • Splitting PDF files for iPhone

    Is there any way to split large, protected pdf files to work with Quickoffice on the iPhone? Quickoffice has no "go to" page function making it very difficult to read a large document. I don't want to change anything in the file, just put the file in

  • REGARDING BOM ITEMS

    Dear PP Experts, Can anyone tell me, what is the use of 'INSERT' function in the BOM - EDIT menu. When i used it the system inserting the many lines in the item screen. I want to insert the only one line below the line which i selected. Thanks, Regar