Opt for the PROCEDURE or FUNCTION


Hi all

I wonder if someone tell me that when will I go to the PROCEDURE orFUNCTION?.. I did research and I think if we have to perform some sequence of statements then we use procedure and if we need to perform some calculation then we create function. In addition, When we need to assign function return value into variable. Appreciate you valuable suggestion... Many Thanks

Hello

An important distinction is that only functions can be called from SQL statements.

SOM restrictions apply.  If a function is called by a SQL statement, this function does not perform any DML (for example, INSERT), or call any other function or procedure that does it.  If a function is called by a SQL statement, you should not have any OUT or IN OUT arguments.

How do you intend to use the procedure or function?  Give specific examples of things you can do in PL/SQL, and then people can give you accurate answers.

Tags: Database

Similar Questions

  • By clicking on the icon of debugging for a procedure or function survey error ORA-00904

    Hi all

    By clicking on the icon of debugging for a procedure or function throws the error ORA-00904.

    Developer SQL 4.1.0.19.07

    Java 1.8.0_40

    OS: Linux Mint 17.1

    Developer SQL 4.1.0.18.37 on the same machine works very well.

    Clues?

    Thank you!

    degger error.png

    It is indeed regressed as RDBMS to 10g have object_id all_procedures notice. Buggy.

  • By opting for the local account affects the current files and other documents are store in the pc.

    I have windows 8 is installed in my desktop pc

    I want to move my account to GO to THE LOCAL because of user setting I m tried to synchronize my app Mail for new emails and other stuff his watch still unavailable then, opting for the account local affect current files and other documents are stored in the pc at this moment before I spend.

    Hello

    Passage of the account Microsoft local account will not affect your personal documents saved on the computer.

    Reference: http://support.microsoft.com/kb/2782145

    It would be useful that you could provide more information on the problem faced with synchronization.

    -What is the exact error you get when synchronization Mail app and other apps?

    -Do you use all parameters of proxy to access the internet?

    -Remember to make changes before the show?

    -What anti-virus software is installed on the computer?

    If you encounter the problem of synchronization with all applications, then I ran the http://download.microsoft.com/download/F/2/4/F24D0C03-4181-4E5B-A23B-5C3A6B5974E3/apps.diagcab Apps store

    Navigate through the steps mentioned in http://windows.microsoft.com/en-us/windows-8/what-troubleshoot-problems-app

    Check if you have any proxy enabled. If so, then delete it.

    a. open Internet Explorer.

    b. click on tools and select Internet Options.

    c. click on connections.

    d. click on LAN settings.

    e. remove the check mark next to proxy server.

    f. click OK and check if you are able to synchronize emails.

    If none of the steps work, try to remove the account from the messaging application and add it again and check.

    Go through http://windows.microsoft.com/en-IN/windows-8/mail-app-faq

    Hope this information is useful. Let us know if you have any questions.

  • How to assign values to the nested table and passes as a parameter for the procedure?

    How to assign values to the nested table and passes as a parameter for the procedure?

    Here are the object and its type

    create or replace type test_object1 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type1 is table of the test_object1;


    create or replace type test_object2 as an object
    (
    val1 varchar2 (50).
    val2 varchar2 (50).
    VARCHAR2 (50) val3
    );


    create or replace type test_type2 is table of the test_object2;


    GRANT ALL ON test_object1 to PUBLIC;


    GRANT ALL ON test_type1 to PUBLIC;


    GRANT ALL ON test_object2 to PUBLIC;


    GRANT ALL ON test_type2 to PUBLIC;

    Here is the table object type:

    create the table test_object_tpe
    (
    sl_num NUMBER,
    Description VARCHAR2 (100),
    main_val1 test_type1,
    main_val2 test_type2
    )


    NESTED TABLE main_val1 STORE AS tot1
    NESTED TABLE main_val2 STORE AS earlier2;


    -----------------------------------------------------------------------------------------------------------

    Here is the procedure that inserts values into the nested table:

    PROCEDURE INSERT_TEST_DATA (sl_num in NUMBER,
    Description in VARCHAR2,
    p_main_val1 IN test_type1,
    p_main_val2 IN test_type2
    )
    IS
    BEGIN

    FOR rec in p_main_val1.first... p_main_val1. Last
    LOOP

    INSERT INTO xxdl.test_object_tpe
    (
    sl_num,
    Description,
    main_val1,
    main_val2
    )
    VALUES
    (
    sl_num
    description
    test_type1 (test_object1)
    p_main_val1 .val1 (CRE),
    p_main_val1 .val2 (CRE),
    p_main_val1 .val3 (rec)
    )
    )
    test_type2 (test_object2 (p_main_val2 .val1 (CRE),
    p_main_val2 .val2 (CRE),
    p_main_val2 .val3 (rec)
    )
    )

    );

    END LOOP;

    commit;

    END INSERT_TEST_DATA;

    -------------------------------------------------------------------------------------------

    Here are the block anonymoys what values attributed to the object type and pass values in the procedure:

    Set serveroutput on;

    declare

    p_sl_num NUMBER: = 1001;
    p_description VARCHAR2 (50): = 'Test Val1;

    inval1 test_type1: = test_type1();
    inval2 test_type2: = test_type2();

    Start


    inval1 (1) .val1: = "testx1";
    inval1 (1) .val2: = "testx2";
    inval1 (1) .val3: = "testx3";

    inval2 (1) .val1: = "testy1";
    inval2 (1) .val2: = "testy2";
    inval2 (1) .val3: = "testy3";

    CSI_PKG. INSERT_TEST_DATA (sl_num = > p_sl_num,)
    Description = > p_description,
    p_main_val1 = > inval1,
    p_main_val2 = > inval2
    );

    end;
    /
    Someone can correct me.

    Thank you
    Lavan

    Thanks for posting the DOF and the sample code but whenever you post provide your Oracle version 4-digit (result of SELECT * FROM V$ VERSION).
    >
    How to assign values to the nested table and passes as a parameter for the procedure?
    >
    Well you do almost everything bad that could be hurt.

    Here is the code that works to insert data into your table (the procedure is not even necessary).

    declare
    p_sl_num NUMBER := 1001;
    p_description VARCHAR2(50) := 'Testing Val1';
    inval1 test_type1 := test_type1();
    inval2 test_type2 := test_type2();
    begin
    inval1.extend();
    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    inval2.extend();
    inval2(1) := test_object2('testy1', 'testy2', 'testy3');
    
    INSERT INTO test_object_tpe
    (
    sl_num,
    description,
    main_val1,
    main_val2
    )
    VALUES
    (p_sl_num, p_description, inval1, inval2);
    commit;
    end;
    /
    

    See example 5-15 making reference to an element of nested Table Chapter 5 using PL/SQL collections and records in the PL/SQL doc
    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/Collections.htm#CJABEBEA

    1. you don't even have the procedure because it is a simple INSERTION in the table you can do directly (see my above code)

    inval1(1).val1 := 'testx1';
    

    Since you have not yet created all the elements, there is no element 1 "inval1". You need EXTEND the collection to add an element

    inval1.extend();
    

    And then, there is an empty element, but "inval1" is a container for objects of type 'test_object1' not for scalars as "val1", "val2", and "val3".
    If you can not do

    inval1(1).val1 := 'testx1';
    

    You must create an instance of 'test_object1 '.

    inval1(1) := test_object1('testx1', 'testx2', 'testx3');
    

    And so on for the other collection

    You don't need the procedure (as my code example shows), but once you fill in the variables correctly it will work.

  • differences between the procedures and functions.

    a little confusing... differences between procedures and functions...

    1. a function returns only the unique value? can't return us multiple values?

    2. can we use clause of 'back' and 'out' parameter at the same time in the same function

    Thank you

    Hello

    Simply create a TYPE for strong cursors, returning the specified columns. For genereic, or the low sliders, there is a TYPE integrated, namely SYS_REFCURSOR.

    Try this:

    CREATE OR REPLACE function test_f(p_DEPTNO  in emp.DEPTNO%type)
      return SYS_REFCURSOR
      as
         REF_C     SYS_REFCURSOR;
    BEGIN
         OPEN  REF_C  FOR   SELECT  *
                             FROM    EMP
                      WHERE   DEPTNO = P_DEPTNO;
         RETURN REF_C;
    END;
    

    You don't want to close the cursor service.

    Always format your code.

  • How do I opt for the e-mail notification when someone responds

    How do I opt for email notification when someone answers one of my questions?

    I see now that the email notice enter my btinternet spam box. You can see that they go to my Inbox. Thank you.

  • Difficult to see the details for the traditional DAQ functions

    I'm migrating a Tradtional DAQ to DAQmx applications and manage to LV 8.6 to see 'details' for traditional data acquisition functions.  I looked to the traditional manual online user DAQ & a few other pubs and impossible to find a good explanation, parameters of entry and exit to functions.  Can someone help me?

    Thank you... PacMan

    In talking with Kent Lau, an applications engineer at NOR, told me I was missing the file nidaq.chm for a reason any.  Even after trying it from reinstalling drivers traditional DAQ of Q4, 2008 software distribution, it is still missing.  So, I installed an older version of the driver on a computer that has never had LabVIEW, then copied the file nidaq.chm in the folder 8.6\Help of LabVIEW & was able to then see the traditional DAQ work details.  Thanks Kent!

  • Need to model for the XR-2206 function generator chip

    I'm designing a training tool for the operation of the basic oscilloscope and decided to use a function generator based on chip XR-2206. Is there a template for this? I know its old but...

    Hi jwaters,.

    Unfortunately, we do not have anything; However, perhaps it will be useful.

  • NI LabVIEW driver for the SRS DS345 function generator generates error "(Hex 0xBFFF0011) insufficient location information or the device or resource is not present in the system."

    Hello

    We have a generator function SRS DS345.

    I just downloaded the driver NOR for the instrument on http://sine.ni.com/apps/utf8/niid_web_display.download_page?p_id_guid=E3B19B3E9149659CE034080020E748....

    After installation, the DS345 appears in MAX, and I can well communicate with him.

    However, if I run the srds345 to Started.vi, I get an error "location information insufficient (Hex 0xBFFF0011) or the device or resource is not present in the system" from initialize it with Options.vi srds345 sub - vi.

    The only change I did Exchange address GPIB 14 to 19, which is our function generator GPIB address. In addition, the

    Functions of SRS DS345 generator of function palette is empty, even after you restart LabVIEW (see attachment). I'm using LabVIEW 8.5.1.

    Your help in resolving this issue is appreciated. Thank you.

    Best regards

    Peter

    Have you installed the driver from LabVIEW or copied directly from inst.lib?

    The first is easier, and you don't have to restart LV more...

    Error in a not filled gpib address points. I have not checked if this driver has a resource name visa or a string of gpib address old but in the first case, try the little triangle on the right at the slect address instead of by hand.

  • For the ArcSoft keyboard function keys

    There is no documentation on the function keys on this keyboard for Windows 7.  What does each of the function keys?

    Hello

    By "function keys" do you mean the F1 through F12 keys along the top? Those that are designed to work within each application, with some generally accepted standards. For example, F1 usually means the 'Help' function in applications that support a help function. Similarly, F5 usually means 'Refresh', as it does in Internet Explorer and Windows Explorer.

    But although there are standards, they are not always respected. For example, my file manager 3rd - party (which replaces Windows Explorer) use Ctrl (control) + 'R' to mean 'Refresh '. If the answer to your question boils down to, 'he (usually) depends on the application.

    It is also the answer to the same question when asked for the special function keys along the second row of keys. Last point, you can find what keys do what are the functions in the menu at the top of almost all the applications bar. Where a function button is enabled for a function in the menu bar, that will be visible key in the location hot key along the right edge of a menu. Thus, for example, 'Refresh' is shown in the View Menu of Internet Explorer, opposite the word on the right edge F5 is displayed.

    I would like to know if that answers your question, or ask any more questions if you have.

    Kind regards

    BearPup

  • How to change the automatic generated wsdl for the procedure

    I configured xdb and as far as I know, for each procedure that I expose as a web service, oracle automatically creates a wsdl.

    I would like to change this wsdl, but I don't know where I do.

    For example:
    It is a part of the wsdl file I want to edit:

    From:

    < types >

    "< xsd: Schema targetNamespace=""" elementFormDefault= "qualified">
    "< xsd: Element name="TESTE_AUXInput">"
    < xsd: complexType >
    < xsd: SEQUENCE >
    "< xsd: Element name="P_VAR-VARCHAR2-IN"" type= "xsd: String"/ >

    TO:

    < types >

    "< xsd: Schema targetNamespace=""" elementFormDefault= "qualified">
    "< xsd: Element name="TESTE_AUXInput">"
    < xsd: complexType >
    < xsd: SEQUENCE >
    "" < xsd: Element name= "P_VAR-VARCHAR2-IN" " minOccurs="0" maxOccurs="1"oraxdb:propNumber = '4608' oraxdb: global ="false"oraxdb:SQLName ="VAR VARCHAR2 IN"oraxdb:SQLType ="VARCHAR2"oraxdb:memType ="1"oraxdb:MemInline ="true"oraxdb:SQLInline ="true"oraxdb:JavaInline ="true"' type="xsd: String"/ >




    I tried to create a "TESTE_AUXInput" type, but it changed nothing.

    I heard it has to do with the XML schemas, but I tried to create an xml schema that contains:

    "" < xsd: Element name= "P_VAR-VARCHAR2-IN" " minOccurs="0" maxOccurs="1"oraxdb:propNumber = '4608' oraxdb: global ="false"oraxdb:SQLName ="VAR VARCHAR2 IN"oraxdb:SQLType ="VARCHAR2"oraxdb:memType ="1"oraxdb:MemInline ="true"oraxdb:SQLInline ="true"oraxdb:JavaInline ="true"' type="xsd: String"/ >

    < xsd:simpleType >

    < xsd:restriction base = "XSD: String" >

    < xsd:minLength value = "1" / >

    < xsd:maxLength value = "100" / >

    < / xsd:restriction >

    < / xsd:simpleType >

    < / xsd: element >


    But I don't know how to do the procedure to use wsdl.
    How can I do?

    INFO:
    Oracle 11.2.0.4 standard edition
    Oracle linux 5

    If you need any other information, let me know.

    Thanks in advance.

    And the answer is always no, the wsdl file cannot be changed.

  • Variable binding in the procedure and function

    Hello

    I started reading ORACLE 11 g R2 PL/SQL programming doc and I'm stuck to bind the variable. I just copied the example in the books and found error-

    First of all, I wrote the procedure below and compiled with - success
    CREATE OR REPLACE PROCEDURE FORMAT_STRING ( string_in IN OUT VARCHAR2) AS
    BEGIN
     string_in := '[' || string_in || ']';
    END FORMAT_STRING;
    Then I wrote below function and also compiled successfully-
    create or replace function join_strings  (str1 varchar2, str2 varchar2)
    return varchar2 is
    begin
      return str1||' '||str2||'.';
    end;
    Later, I wrote the code below in the SQL Editor and found the ORA-00900 error. Please help me to understand.
    variable session_var varchar2(200)
    call join_strings ('I Love','you') into :session_var;
    call format_string(:session_var);
    Maoulida

    Later, I wrote the code below in the SQL Editor and found the ORA-00900 error. Please help me to understand.

    variable session_var varchar2(200)
    call join_strings ('I Love','you') into :session_var;
    call format_string(:session_var);
    

    If you want to do it in PL/SQL, you can use an anonymous PL/SQL block like that.

    set serveroutput on
    declare
      session_var varchar2(200);
    begin
      session_var := join_strings ('I Love','you');
      format_string(session_var);
      dbms_output.put_line(session_var);
    end;
    /
    

    If you want to run directly in SQL Plus you can do

    var session_var varchar2
    
    exec :session_var := join_strings ('I Love','you')
    
    exec format_string(:session_var)
    
    print session_var
    
  • Location of the source code for the procedure of ODI

    Let say I have a SQL code located in the ODI process (well, I know it's a bad habit, sorry).
    How can I find if I don't remember the name of procedure?
    The code must be located somewhere in the repository of the work, right?
    But what is the name of table?
    As I can SELECT * FROM odiw.xxxx, WHERE xxxx like '% text_i_am_looking_for %';
    Or maybe there is a better way to do it?

    All the information KM and ODI procedure are stored in SNP_TRT and then link to SNP_LINE_TRT where all the steps in the procedure are stored.
    then bind to SNP_LINE_TRT. DEF_I_TXT for control of target and SNP_LINE_TRT technology. COL_I_TXT the order of the source technology and properly link to SNP_TXT. Order I_TXT of TXT_ORD and SNP_TXT. TXT is where you will be able to find the syntax or SQL code.

  • General question about the procedures and functions

    Hello!

    I know, I can define and use a function within a procedure. But can I set up and use a procedure inside a procedure?

    Thank you!

    Hello

    But can I define and use a procedure inside a procedure?
    

    HMMM... was it so difficult to test this?

    CREATE OR REPLACE PROCEDURE xy_main
    AS
    PROCEDURE xy_sub IS
    BEGIN
    NULL;
    END;
    BEGIN
    xy_sub;
    END;
    

    Or you actually meant the procedure inside a function
    It's also not difficult :)

    CREATE OR REPLACE FUNCTION func_xy_main RETURN NUMBER
    IS
    PROCEDURE xy_sub IS
    BEGIN
    NULL;
    END;
    BEGIN
    xy_sub;
    RETURN(1);
    END;
    

    See you soon!
    Bobin

  • Satellite R630-13U - driver need for the WLAN/BT function key

    Dear Sirs,

    I have problem with my Toshiba Satellite R630-13U

    I have not found any driver for the wireless hot key windows 7 pro 32-bit to be able to turn on/off the wireless or Bluetooth.

    Thank you

    Ayman

    You need to install additional package from Toshiba. Several different tools, this package, and one of them is utility of Flash cards.

    Please install, test and post comments.

Maybe you are looking for

  • Satellite A300D and possible overheating

    OK, so I have this A300D for 4 years. Recently, I have this problem when it stops after a few minutes.Not enough for execution of diagnostic tests or anything like that. If it is started under Windows secure start frezees with a blurred image. If I s

  • T420s stuck pixel

    I just got my built custom T420s... and I have a stuck pixel He's stuck red on white and black background on most of the other funds color. On a black background, it is not noticeable. I was wandering what should I do now I looking for a screen flick

  • Disorder of Smartphones blackBerry 8220 with sync windows calendar

    I'm trying to synchronize my 8220 with windows (running Vista) calendar. I managed to sync contacts from windows without problem. Any suggestions? Thank you Lulu34 EDIT:-after more research, is my problem that I'm trying to use windows calendar and I

  • Problems of improved synchronization of calendar by using plug-in Gmail blackBerry Smartphones

    After contacting the blackberry support via twitter to @BlackBerryHelp and using the items they suggested: http://www.BlackBerry.com/BTSC/microsites/search.do?cmd=displayKC&docType=kc&externalId=KB02189&SLIC... and http://www.BlackBerry.com/BTSC/micr

  • App Indesign CS6

    Where can I find the application Indesign CS6 (I had already CC2014 but now I need to have a monthly plan or yealy for CS6)?