Doubts basic PL/SQL

Hello Experts / gurus or friends;

Hi all!

I have fundamental doubts in PL? SQL. However I'll finish FUNTIONS.

so I want to clarify some fundamental things. I google... but NOT clear

> > MY QUESTIONS ARE > >

During the creation of function or procedure.

a few times I use 'IS' and so many times that I use 'AS' - Confused?

> > I wrote the procedures following the methods > >



create or replace procedure emp_details IS

DECLARE the PROCEDURE HELLO AS

Create procedure my_proc AS

PROCEDURE HELLO AS

BEGIN

....

....

so my confusion, when I go with 'As' or 'IS'?

-Is my question?

I'll post my question once I clearly understand!

Thanks in advance...

Yes, you can think of each unit of PL/SQL created and compiled through CREATE (or REPLACE)... Statement to be stored in the database.

"A stored subprogram is a subprogram that is stored in the database. Because they are stored in the database, the stored programs can be used as building blocks for many different database applications. (A subprogram that is declared in another subprogramme or in an anonymous block, is called a nested subroutine or local routine. It can be invoked from outside the subroutine or block in which it is declared. An anonymous block is a block that is not stored in the database.) »

From: develop stored subprograms and packages

Tags: Database

Similar Questions

  • Doubt in pl/sql.

    Hi friends,

    I have a doubt in pl/sql, I wanted to write a small program for integration of values in a table. the code I used is

    declare
    i the number: = 1;
    Start
    loop
    If I have! = 6 or i! = 8 then
    Insert into values sample2 (i);
    i: = i + 1;
    on the other
    i: = i + 1;
    end if;
    exit when I = 11;
    end loop;
    end;


    the logic I want is when I reached the value of 6 or 8, that it should not insert into the table, but the code always inserts the values into the table. I don't know where I was wrong any ideas would really help me. I am currently using ISQL * more Publisher with oracle 10g R2.

    Kind regards
    Maury

    You seem to have a bug in your Boolean logic.

    If i is 6, for example

    I have! = 6 is false
    I have! = 8 is true (6! = 8 after all)

    If your IF statement

    IF (i != 6 or i != 8)
    

    becomes

    IF (false or true)

    property to true. If you have used one AND rather than GOLD, the IF statement will evaluate false if a condition is FALSE.

    Justin

  • doubt on the sql worksheet

    Hi people,

    I had a sql query. How can I find the cost of a query and the time taken.

    Thank you

    It's hard to say. Dependss running SQL on several factors such as the index, workload, and many others.

    You can run the query with "Explain plan" (F10) but the cost that you see in the last column of the table does not tell you the total cost of the query. There is a long, long discussion on that to asktom.oracle.com , who give a lot of inside this issue.

    Timo

  • Doubts basic creation/modification of a Module

    Hello

    I'm a newbie at ATG, and I'm trying to understand how ATG (I work with ATG for just one week). I have some conclusions on ATG and I just want to confirm that I have just do.

    Configurations:
    Application server: WLS (Weblogic Server 11g)
    Version of the ATG: 10.0.3
    Database: Mysql
    Official database: Oracle
    IDE: Eclipse
    Develop the operating system: Windows 7 (yes I know linux isn't it better... but...)
    Official OS: Oracle Linux

    Conclusions and action I got:
    1. While ATG is a module
    2. do I need to create a new module to create a new store, or I have to work more crs?
    2.1. I have both, a new module and ReferenceStore under Eclipse IDE with all the taglibs and packages to work, I'm able to generate a constituent of any
    2.2. with this war, I'm able to run runAssembler.bat - pack xxx.ear m XXXECommerce Module and it generates a .ear
    2.3. with this .ear I'm capable of doing a deployment to WLS. (It runs without error to WLS but page index.jsp and all other open white and one occurs NullPointer interpretation tag dsp)

    Doubts:
    1 are. these conclusions correct?
    2. with my customizations in a .war do I do if erros happens running runAssembler and deployment?
    3 does anyone have a tutorial on how to create a new ecommercer site or how to use a crs as reference to build a store?

    Thank you!!

    Published by: onhate on December 20, 2011 10:06

    Published by: onhate on December 20, 2011 10:07

    You must run runAssembler as many times have you create ear files.

    In general, intermediaries, and Production will be same file ear with only a difference for data source files.
    These data source files, you can put in the localconfigs of specific server.

    The publication, you must create a new module and add the list of modules required in his MANIFESTO. MF file.

    Peace
    Shaik

  • doubt in PL/SQL table

    If I said PL/SQL table and populated with 10 values.

    If I want to find a perticular values are in the list populated how can I find.say I have values from 1 to 10.
    and I want to find if 9 is in the list.
    I tried with loop. Is there another way. I use 10g.

    declare
    tr_nm number_array;
    i the number;
    Start
    I'm in 1.10
    loop
    tr_nm.extend;
    tr_nm (i): = i;
    end loop;
    for j from 1... tr_nm. Count
    loop
    If tr_nm (j) = 9 then
    i: = i + 1;
    end if;
    end loop;
    If i > 0 then
    null;
    end if;
    end;

    Please try this code
    Note: this code runs from 10 g.

    DECLARE
    type num_type is table of NUMBER;
    v_num_arr num_type;
    v_num number;
    v_var number :=9;
    BEGIN
    select level
    bulk collect into v_num_arr
    from dual connect by level <=10;
    
    dbms_output.put_line('Count - '||v_num_arr.count);
    
    if v_var member of v_num_arr then
     dbms_output.put_line('Found ');
    end if;
    
    END;
    
  • Doubt basic to GroupBy

    I need to write a query that displays the name, salary and service employees who receive the maximum salary in their respective departments, assuming that there are two employees of different tables and Department.

    Expected results:

    Name Department salary
    Allen 22000 operations
    Barry HR 19000
    Astrid Admin 9000

    One way... Try this query.

      1  select e.deptno, e.ename, e.sal from emp e
      2  where (deptno, sal) in (
      3      select e1.deptno, max(e1.sal) from emp e1
      4     group by e1.deptno
      5  )
      6* order by e.deptno
    sql> /
    
        DEPTNO ENAME             SAL
    ---------- ---------- ----------
            10 KING             5000
            20 FORD             3000
            20 SCOTT            3000
            30 BLAKE            2850
    

    Query internal void gets question of departments and maximum salaries and the outer query shows employees with this number depertment and salary details.

    The data used are the default emp tabe in the scott schema.

  • DOUBT OF PL/SQL

    HOW TO FIND THE TYPE OF RETURN DATA OF THE FOLLOWING:

    SELECT NVL(A,B) FROM DUAL;

    HERE 'A' HAS A CHARACTER DATA AND A "B" NUMBER DATA TYPE?

    Help, please

    Hello

    The return type is always varchar support for this.

    Thank you
    SUN

  • Need help with basic sql

    Hello

    I use oracle 10g and having some small doubts associated with sql, goes here of the situation

    I have a Transaction table, which contains the records/operation made by an employee under a code of pattern on different dates, see below examples of data
    EMP_CODE          REASON_CODE     DATE
    
    A001           B1                            1st Jan 2009
    A001          B1          3rd Jan 2009
    A001          B1          6rd Jan 2009
    A001          C2          9th Jan 2009
    
    A002          D4          1st Jan 2009
    A002          D4          3rd Jan 2009
    A002          D5          6rd Jan 2009
    
    A003          E6          6rd Jan 2009
    A003          E6          7rd Jan 2009
    Actually I want to have the final result as follows (p. ex. some how hide A003, see below for reason)
    A001          B1
    A001          C2
    A002          D4
    A002          D5
    So basically, print employee ID and reason code only if the employee has made the transaction under more than 1 code of reason, since the employee "A003" completed transaction code Minus 1 SINGLE code ONLY reason *, I don't want his record in printed.*

    the current query I wrote is as follows:
    select      emp_cd, reas_cd
    from      employee_trans_table
    where     reas_cd <> '   '
    group by emp_cd, reas_cd
    order by emp_cd, reas_cd
    but this impression of results as
    A001          B1
    A001          C2
    A002          D4
    A002          D5
    *A003          E6*
    How to avoid printing A003/E6 since she had only 1 reason code attached to it...


    I hope that I am able to clearly state the doubt that I am, let me know if you need any other info/clarrification on it.

    Concerning

    Learner

    Published by: learner1 on October 26, 2009 13:33

    Published by: learner1 on October 26, 2009 13:34

    Published by: learner1 on October 26, 2009 13:36

    Published by: learner1 on October 26, 2009 13:36 (added code tag)

    A possible solution.

    with data as
    (
      select 'A001' as col1, 'B1' as col2 from dual union all
      select 'A001' as col1, 'B1' as col2 from dual union all
      select 'A001' as col1, 'B1' as col2 from dual union all
      select 'A001' as col1, 'C2' as col2 from dual union all
      select 'A002' as col1, 'D4' as col2 from dual union all
      select 'A002' as col1, 'D4' as col2 from dual union all
      select 'A002' as col1, 'D5' as col2 from dual union all
      select 'A003' as col1, 'E6' as col2 from dual union all
      select 'A003' as col1, 'E6' as col2 from dual
    )
    select distinct col1, col2
    from
    (
      select col1, col2, count(distinct col2) over (partition by col1) as distinct_count
      from data
    )
    where distinct_count != 1
    
  • I want to improve my skills in sql and plsql

    Hello friends,

    I finished the course SQL and PLSQL a few weeks back. Since then I've been hunting for a relevant work for SQL / PLSQL developer.

    However I really want to improve my writing of the subprogrammes, build effective SQL queries to become a skilled oracle developer.

    My current work is not linked to this use so all my free time to improve my knowledge in this area.

    I know the basics of SQL and PLSQL concepts and can write queries simple, subprogrammes, but to become employable, according to me, that I need to learn a lot more.

    Please suggest me some good sources be it no books / sites Web, etc. anything that would really help me become a good developer.

    I'm desperate to make a career out of Oracle SQL / PLSQL!

    Thanks in advance.

    Do what most of the experts do... start at the bottom.

    Find a job in a junior role (and yes it will be low wages initially) where the company may see your potential and enthusiasm to learn and will give training and let you learn on the job.  If you have the skills to do it, then you will learn quickly and prove you are competent and deserve to be promoted to better roles.

    When I started (in the same after having a university degree in it), I always had to start at the bottom, in a junior role, on a 3 month temporary contract.  Who got so extended that they identified some new work roles that were needed, and then I had to get one of these new jobs, where I got a permanent role.  Within 18 months, they had sent me on the training, and I was promoted to a role of DBA/programmer, working alongside other programmers and hardware team to manage database servers... everything just because I had shown the ability, willingness to learn and the professional approach to my work.

    Don't think you can just get some training or the qualities of the review, but have no experience and just get into some senior roles or an expert, as most of the companies are wise to such things... they want to know what you have for the roles of the experience.

  • Need your help for sql tuning


    Hi gurus

    I really want to learn a few basics against SQL tuning, can you please guide me how will I achieve my goal? Thanks in advance.

    Concerning

    Shu

    I am professional tuner and this for 20 years. Firstly, I think that the best way is always a course with instructor. In other words, you can't ask for books. You have no need to read tuning guide in this case, the instructor he will tell you. If the time and the budget does not allow you a course, you can go online or material and DVD tutorial. As a next steop I would recommend Cary Milsap's "Optimizing Oracle Perforamance". I'll be your right mind game. Jonathan and Chris books you must have if you do practical work. You don't need to read all the chapters in detail from the beginning, but you should check out them if you have any questions when you work on a tuning tasks. If you want to go more advanced subjects discover Wolfgang Breitlings presentation on http://www.centrexcc.com/. Very valuable are also Throw away method of Martin Berg and the SQL Diagraming of Daniel Tow technique.

  • SQL Code Analyzer

    Hi all

    My requirement is analysis a query and find out what are the tables and the columns involved.

    We have columns Source and the only table names in a query.

    Query can be any format as sub, with clause query...

    There are 1000's of queries that analysis must...

    Is there a simple way... ???

    Thank you

    Elayaperumal S

    Yes.

    The following approach can be used (does any syntax, but does the basics):

    SQL> create or replace function XmlParse( dynamicSQL varchar2 ) return XmlType is
      2          c       clob;
      3          xml     XmlType;
      4  begin
      5          dbms_lob.CreateTemporary( c, true );
      6          sys.utl_xml.ParseQuery(
      7                  user,
      8                  dynamicSQL,
      9                  c
     10          );
     11
     12          xml := new XmlType(c);
     13          dbms_lob.FreeTemporary(c);
     14          return( xml );
     15  end;
     16  /
    
    SQL>
    SQL> with xml_parse( xml ) as(
      2          select XmlParse( 'select sysdate as day, e.*, d.* from emp e, dept d where e.deptno = d.deptno and empno = :1' ) from dual
      3  )
      4  select
      5          t.*
      6  from       xml_parse p,
      7          XmlTable( '/QUERY/SELECT/SELECT_LIST/SELECT_LIST_ITEM/COLUMN_REF'
      8                  passing p.xml
      9                  columns
     10                          table_name varchar2(30) path 'TABLE',
     11                          column_name varchar2(30) path 'COLUMN'
     12          ) t
     13  /
    
    TABLE_NAME                     COLUMN_NAME
    ------------------------------ ------------------------------
    EMP                            EMPNO
    EMP                            ENAME
    EMP                            JOB
    EMP                            MGR
    EMP                            HIREDATE
    EMP                            SAL
    EMP                            COMM
    EMP                            DEPTNO
    DEPT                           DEPTNO
    DEPT                           DNAME
    DEPT                           LOC
    
    11 rows selected.
    
    SQL>
    
  • VCenter on MS SQL 2008 R2 installation

    Hello

    I can't install vCenter (4.1 Update 1).

    I installed a basic MS SQL Server R2 on a Windows Server 2008 R2.

    Installing vCenter I block at the choice of the database level.

    He therefore asks me if I want to use a 2005 Express version or a database of existing support. So I choose the second option, but it offers me nothing in the drop-down list (DSN).

    When I enter the name of the previously created DSN (via the control panel > administrative tools > Data Source (ODBC)), I have an error message "the DSN"xxx"does not exist or is not a 64-bit system DSN. vCenter Server requires a 64-bit system DSN. »

    1 - remember to install the client SQL 2008 R2 on the vCenter

    2 good create a "System DSN" and not UN "user DSN".

    3. to install at least a vCenter 4.1 (en 4.0 go looking for ODBC administration in SysWOW64)

    Eric

  • How to capture hardparsed Sqls.

    Hi I'm using Oracle 10.2.0.4.0.

    I want to get the list of those who are hardpared several times (maybe 100 times more) SQL and do not bind variable, increasing therefore shared burden of pool. So is there an easy way to capture these sqls, only using "Select" statements (that I did not create the object of rights in prod)?.

    Hello

    you are right about that there is two different cases: several cursors of the child (because of the incompatibility of the bind variables size, settings of optimizer etc.) and several sliders parent (due to the use of literals). Given that in your original post you were talking about is not using bind variables, I don't mention one, since it is has nothing to do with the not not using bindings. But if you want to look at the issue as well, perhaps the best reference is MOS 296377.1 and notes referenced that are there. I doubt that V$ SQL.parse_calls will be of no use here because analysis calls include soft parsed and interested probably only parsed hard.

    You're not quite right about "different sql_id for the same text" - the text will be different due to different values of literals, and this is exactly the reason for different sql id

    Best regards
    Nikolai

  • Failed to 150 000 lines extracted from "xlsx" SQL query results

    Environment:

    SQL * Developer 3.1.07.42 on Windows XP SP3
    Oracle 11.2.0.3 EE on Solaris 10.5

    I ran a query in a spreadsheet window and the first page of results came back in 10 seconds, whoo hooo!

    I right click on the first column of the first row and selected 'Rows Count' and back 527 563 after thinking a bit.

    I clicked 'Export', selected a box for "Query worksheet name" "xlsx", uncontrolled size and traveled to specify the output file directory (my local C: drive) and the name of the file. I clicked on "Next" and then on "Finish".

    I watch the meter of the line at the bottom right of the window and it went very quickly until he hit about 150 000 lines and then it started to slow down. It got slower and slower and slower and slower, and you get the picture, and finally, I killed the process when it took more than 15 seconds from 156 to 156 250 245.

    Why would it be?

    Additional information:

    I have the same exact query is represented and exported the same lines 527 563 using the "xls" instead of "xlsx" format and the process has proceeded all the way to the end very quickly and successfully completed in just a few minutes. The worksheet resulting contained 8 eight worksheets since it could only put 65536 lines on each worksheet. This was acceptable to the user who just merged the data manually.

    There are some issues with the help of "xlsx" format of output as opposed to simply use it as input format?

    Is SQL * Developer trying to create a spreadsheet with the same number of rows as the data up to the max in Excel 2010 (over 527 563)?

    Thanks a lot for all shed light on this issue. If I omitted no details important please let me know and I'll try to include them.

    -gary

    Hi gary,.

    You may have seen one or more threads as follows on the question of fees increased memory overhead for the formats of Excel:
    Re: Developer Sql 3.1 - export a set of results in xls generates and empty the file

    Basically, Developer SQL uses a third-party provider API to read and write these Excel formats. There are separate readers and trainers for each of the forms xls and xlsx.

    There is a new version of the API that supports streaming of xlsx workbooks. Basically, he made a much lower footprint bearing in mind that the lines which are in a sliding window, while that older, without flow version gives access to all lines in the document. The programmer can define the size of this window. In my view, that the most recent version of the API was not available or is not stable during our cycle 3.1 development. Perhaps a future version of SQL Developer can use it.

    Kind regards
    Gary
    SQL development team

  • Doubt with an Insert query!

    Hi friends I have a doubt with a SQL here is the following code.
    INSERT INTO
                         (SELECT employee_id, last_name,
                                      email, hire_date, job_id, salary,
                                      department_id
                           FROM employees
                          WHERE department_id = 50)
               VALUES (99999, 'Taylor', 'DTAYLOR',
                            TO_DATE('07-JUN-99', 'DD-MON-RR'),
                             'ST_CLERK', 5000, 50);
    The same insert statement can be performed with
    INSERT INTO EMPLOYEES (employee_id, last_name,
                                      email, hire_date, job_id, salary,
                                      department_id)
                        VALUES (99999, 'Taylor', 'DTAYLOR',
                            TO_DATE('07-JUN-99', 'DD-MON-RR'),
                             'ST_CLERK', 5000, 50);
    What advantage the first request has on the other.

    Thanks in advance to everyone.

    Kind regards
    Maury

    These two statements are the same.

    However, it would be different:

    INSERT INTO
      (SELECT employee_id, last_name,
            email, hire_date, job_id, salary,
            department_id
       FROM employees
       WHERE department_id = 50
       with check option )
    VALUES (99999, 'Taylor', 'DTAYLOR', TO_DATE('07-JUN-99', 'DD-MON-RR'), 'ST_CLERK', 5000, 50);
    

    "WITH CHECK OPTION" would ensure that only employees for Department 50 are inserted.

    See also:
    http://download.Oracle.com/docs/CD/E11882_01/server.112/e17118/statements_10002.htm#i2066598

    Published by: Sven w. March 17, 2011 19:22 - typo correction

Maybe you are looking for

  • Try buying a find with iPhoto

    I am buying another end up with iPhoto But every time when I click on finish and buy the book, comes the message

  • Full reinstall or virus removal

    Two questions: (1) how can I get rid of this virus (tr/dlbr.tracur.b.43(2) or that I need to do a complete FN4000 reinstall, but I do not have the disk, Model A75

  • Someone please Help! Windows error! Help someone

    OK, I turn on my computer dismorning and after about 10 seconds, I get a screen saying Windows resume Loader, my keyboard does not work here on so I can't click any of the two options "continue with system RESUME & ' Delete restoration data and proce

  • You can recover a deleted file?

    Hi I have unfortunately deleted my last years tax file... is there anyway I can get it back?

  • Explorer Windows constantly crashing everything while browsing

    For several months now the windows Explorer has been constantly crashing just by browsing through the folders, usually prices upwards or downwards at two levels (so it can happen every two minutes if I keep trying to get into my files once it stops a