What is missing with Pl SQL code?

Hey guys,.

I'm learning to get out of this book and the guy has that little bit of Pl/sql...

It runs organist.

create table zed (z varchar2 (30);)

declare the procedure thisway1

(p_data in varchar2)

is

Start

immediate execution

"insert into zed (z) values(:z) '.

using p_data; end thisway1;

The code is correct?

Hello

XevBellringer wrote:

Hey guys,.

I'm learning to get out of this book and the guy has that little bit of Pl/sql...

It runs organist.

create table zed (z varchar2 (30);)

declare the procedure thisway1

(p_data in varchar2)

is

Start

immediate execution

"insert into zed (z) values(:z) '.

using p_data; end thisway1;

The code is correct?

No code is absolutely correct.  The code may be correct for a specific purpose, which means that it will be incorrect for other purposes.  If this code was copied from a book, the book probably explains the context and why the author chose to use EXECUTE IMMEDIATE when it is not needed.  (You must use dynamic SQL, such as EXECUTE IMMEDIATE, only when you really need to.  This is one of the most important things to know about dynamic SQL statements.  Perhaps the book uses this code to make this point.)

In itself, the PL/SQL code you have posted will get a compilation error.  The DECLARE statement must have matching BEGIN and END statements.  (The BEGIN and END statements above are for the thisway1 procedure, which is nested in the DECLARE section).  I suspect that you copied only part of the book pulled code.

The CREATE TABLE statement includes a mistake; "He has 2 left ' (of, but only 1 right ' ')'.  You must have an equal number of each...

Tags: Database

Similar Questions

  • Error with PL/SQL code

    I get several errors trying to insert data into a table through the declaration of pl/sql
    Here are the errors:
    --Procedure to insert the values into section table(ex1.sql)
    declare
     v_section %type;
    begin
    v_section.SECTIONNO:=&no;
    v_section. DESCRIPTION:='&desc';
    v_section.SECTION_HEAD_EMPNO:=&empno
    insert into section values v_section;
    end;
    /
    When I execute the pl/sql program above I get errors:
    SQL> @ex1
    Enter value for no: 10
    old   4: v_section.SECTIONNO:=&no;
    new   4: v_section.SECTIONNO:=10;
    Enter value for desc: Sales
    old   5: v_section. DESCRIPTION:='&desc';
    new   5: v_section. DESCRIPTION:='Sales';
    Enter value for empno: 1005
    old   6: v_section.SECTION_HEAD_EMPNO:=&empno
    new   6: v_section.SECTION_HEAD_EMPNO:=1005
     v_section %type;
               *
    ERROR at line 2:
    ORA-06550: line 2, column 12:
    PLS-00103: Encountered the symbol "%" when expecting one of the following:
    constant exception <an identifier>
    <a double-quoted delimited-identifier> table LONG_ double ref
    char time timestamp interval date binary national character
    nchar
    The symbol "<an identifier>" was substituted for "%" to continue.
    ORA-06550: line 7, column 1:
    PLS-00103: Encountered the symbol "INSERT" when expecting one of the following:
    * & = - + ; < / > at in is mod remainder not rem
    <an exponent (**)> <> or != or ~= >= <= <> and or like
    between || multiset member SUBMULTISET_
    The s
    BTW, * section table is:
    SQL> desc section;
     Name                                                              Null?    Type
     ----------------------------------------------------------------- -------- -----------------------------------
    ---------
     SECTIONNO                                                         NOT NULL NUMBER(2)
     DESCRIPTION                                                                VARCHAR2(30)
     SECTION_HEAD_EMPNO                                                         NUMBER(4)
    Kindly, correct me where I am doing wrong

    Thanks in advance!

    I've updated my post above. Just follow and copy paste the code.

    You are missing the semicolon after

    v_section.DESCRIPTION :=&empno
    

    It should be

    v_section.DESCRIPTION :=&empno;
    

    This is what you need

    declare
     v_section  SECTION%ROWTYPE;
    begin
    v_section.SECTIONNO:=&no;
    v_section. DESCRIPTION:='&desc';
    v_section.SECTION_HEAD_EMPNO:=&empno;
    insert into SECTION values v_section;
    end;
    /
    

    G.

  • Need help with PL/SQL code

    Hi I am writing this code in pl/SQL:

    create or replace
    PROCEDURE 'TESTPRI '.
    (NUMBER pCYC_DT)
    AS
    vTGT_TABL VARCHAR2 (25);
    vSTG_TABL varchar2 (30);
    vsql varchar2 (200);
    BEGIN
    vTGT_TABL: = 'TESTTABL ';
    vSTG_TABL: = vTGT_TABL | » _'|| pCYC_DT;
    vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;
    EXECUTE IMMEDIATE vsql;
    RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;
    COMMIT;
    -IMMEDIATE 'TRUNCATE TABLE ' | vSTG_TABL;
    END TESTPRI;

    When executing this procedure it gives me following error:
    ORA-03290: Invalid command truncate - lack of key word TABLE or CLUSTER
    ORA-06512: at "DBR. TESTPRI', line 11
    ORA-06512: at line 6

    But I think that the TRUNCATE TABLE statement is correct. Is there a problem with the variable?

    Any help would be appreciated.
    Thank you.

    vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;

    You need space after the TABLE

    vsql:= 'TRUNCATE TABLE ' ||vTGT_TABL ; 
    

    EXECUTE IMMEDIATE vsql;
    RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;

    Sapce here after INTO, before SELECT and FROM

    EXECUTE IMMEDIATE 'INSERT INTO '|| vTGT_TABL||' SELECT * FROM '|| vSTG_TABL;
    
  • help with PL/SQL code

    Hello!

    I need help, I don't know why I get errors with my code:

    declare
    xMin number (3) NOT NULL: = 50;
    xMax number (3) NOT NULL: = 70;
    yMin number (3): = 0;
    yMax number (3): = 20;

    Start

    XMin CASE <-400 THEN
    xMin = - 400;
    ELSIF xMax > 400 THEN
    xMax = 400;
    ELSEIF yMin <-400 THEN
    yMin = - 400;
    ELSEIF yMax > 400 THEN
    yMax = 400;
    END IF;

    Select sum (population) populacija
    of naselje
    where x BETWEEN xMin xMax AND
    and is BETWEEN yMin AND yMax;
    end;

    error I get is:
    ORA-06550: line 10, column 15:
    PLS-00103: encountered the symbol "=" when expecting one of the following conditions:

    := . ( @ % ;
    The symbol ': = was inserted before '=' to continue. '
    ORA-06550: line 12, column 15:
    PLS-00103: encountered the symbol "=" when expecting one of the following conditions:

    := . ( @ % ;

    1 declare
    2 xMin number (3) NOT NULL: = 50;
    3 xMax number (3) NOT NULL: = 70;
    Thanks for your help!

    Kind regards
    Dragan

    First ELSEIF is incorrect, it must be ELSIF

    AH, Yes, '=' must be ': = '.

    Published by: Bob37 on May 16, 2012 12:10

  • What is the problem with this pl/sql code?

    What is the problem with this statement of the cursor? I am getting PLS-00341 error for her:
    CURSOR cur_rsource(p_sql_stmt IN VARCHAR2) IS
            SELECT plan_table_output FROM v$sql s, table(dbms_xplan.display_CURSOR(s.sql_id, s.child_number)) t WHERE sql_text LIKE '''%'||p_sql_stmt||'%''';
    How to solve this problem?

    Thank you

    Published by: PhoenixBai on December 14, 2009 14:05

    I don't have time right now to study exhaustively, but for me his vomit ORA-00942 table or view does not exist on this line:

        SELECT sql_id, child_number into tmp_sql_id, tmp_child_number
             from v$sql where sql_text like sql_statement||'%' and sql_text not like '%v$sql%';
    

    I am able to select from v$ sql in normal SQL as user I am compiling as, so don't know why it's complaing.

    Anyone know if there are certain restrictions on access to the views v$ through PL/SQL?

    EDIT: http://www.dbasupport.com/forums/showthread.php?t=22299

    Access to the views of $ v seems to be through a role - try giving explicit access to it.

    As SYS, you must grant select permissions on V_$ SQL (V$ SQL is synonymous with V_$ SQL) to your owner of the procedure. Just tested on my system and it allows him to compile.

    Published by: Cyn on December 14, 2009 10:30

  • Microsoft SQL Server 2005 Express Edition Service Pack 4 (KB2463332) failed to install several times with an error Code: 0xD59.

    I have a Dell Vostro 420 - Windows XP. Microsoft SQL Server 2005 Express Edition Service Pack 4 (KB2463332) failed to install several times with an error Code: 0xD59.  Please help me understand this and get this installed!

    Hello

    Your question of Windows is more complex than what is generally answered in the Microsoft Answers forums. It is better suited for SQL server support. Please post your question in the Sub forum.

    Link: http://social.msdn.microsoft.com/Forums/en/sqlsetupandupgrade/threads

    For reference: how to solve the packets missing MSI or MSP during SQL Server Service Packs, hotfixes or cumulative updates: http://support.microsoft.com/kb/2015100

  • What is with the source code of my area

    I have two questions on my page
    P80_From and P80_To.

    I want to get the report based on these two points

    Here is the code on the Regioin Source

    Select c1, c2, c3 table where createdon between to_date ("' |: P80_FROM |) (', "dd/mm/yyyy")
    and to_date ("' |: P80_TO |) (', "dd/mm/yyyy")

    However, I had
    Failed to parse the SQL query:
    ORA-00907: lack of right parenthesis

    What is wrong with my code?

    Thank you
    Jen

    Published by: Jen Hu October 12, 2011 10:29

    Jen Hu wrote:
    I have two questions on my page
    P80_From and P80_To.

    I want to get the report based on these two points

    Here is the code on the Regioin Source

    select c1, c2, c3 from table where createdon between to_date(''' || :P80_FROM || ''',''mm/dd/yyyy'')
    and to_date(''' || :P80_TO || ''',''mm/dd/yyyy'')
    

    However, I had
    Failed to parse the SQL query:
    ORA-00907: lack of right parenthesis

    What is wrong with my code?

    Too many citations, too concatenation, possibility of SQL injection.

    Correctly use the bind variable:

    select c1, c2, c3
    from table
    where createdon between to_date(:P80_FROM,'mm/dd/yyyy') and to_date(:P80_TO,'mm/dd/yyyy')
    

    Post all the code wrapped in ------...------wrapped in \

    ...\
    

    Tags to preserve formatting and stop interpreting HTML/CSS/JavaScript forum software.

  • What is the problem with my http code?

    I have a problem with the following code on the Bold 9700.  The code works on the Simulator and other devices, but some users have problems.  It seems that nothing is returned when getting the html page.

        static String get_page(String url)
        {
    
            StreamConnection s = null;
            InputStream input = null;
    
            try
            {
    
                s = (StreamConnection)Connector.open(url);
    
                input = s.openInputStream();
                byte[] data = new byte[4096];
                int len;
                StringBuffer raw = new StringBuffer();
                long startTime = System.currentTimeMillis();
    
                while ( -1 != (len = input.read(data)) )
                {
    
                    if (len > 0) {
                        raw.append(new String(data, 0, len));
                    }
    
                    // check for timeout waiting for server; or
                    // what if page never closes...
                    if (System.currentTimeMillis() - startTime >  30000)
                    {
                        s.close();
                        return("ERR2");
                    }
                }
                s.close();
    
                return(raw.toString());
            }
            catch (Exception e)
            {
                return("ERR3");
            }
    
            finally
            {
                try
                {
                    if (input != null)
                        input.close();
                }
                catch (Exception e)
                {
                }
            }
        }
    

    Y does it have that none of the Options application settings must be defined? for example: TCP/IP

    The Thread I pointed you to and the various "required reading" material, describes how the different network paths are selected by changing the suffix of the URL used connection.  The standard demo does not add a suffix, by default, choose BES connection, so will be.  Unless of course, the carrier has provided a different default value for a feature not BIS, for example, I understand that Vodafone UK will send it via WAP.

    According to the treatment of suffix / default connection, the request will be routed through a number of "gateways" like BES/MDS or the carrier's WAP gateway.  If any of them could give the 500.

    Assuming that it makes actually to your server (I assume this is a URL that you control), then the 500 from the treatment of your Web.  For example, this could be because your processing wait some headers in the http request which are not provided.  Or, that demand has been sent by a gateway changing the headers in a way that is not pregnant with your web server.

    With same URL work on the browser is unfortunately not much of a test as it can be routed through a method of communication that you do not use (for example, on Vodafone BIS devices I think the default browser will use BIS - B) and, in addition, it could provide some headers for the http connection that you do not provide.

    The point really is that there are many places that could break this code.  And there are number of variables, including what method of connection is used (and in the case of Vodafone, effectively forced to use), which carrier is used and which headers were provided.

    But I think the first thing we do is to know who is giving you the 500.  If you can follow the application to your own server, so much the better.  If you can not, in the headers that come back with 500, you should some server information.  The dump out., empty the suffix of connection you use and if possible, get the log records from at the time this was done (which confirms the method of connection actually used).

    I also search this forum for more information on issues people have had with the carriers.  I know that there is some information on Vodafone UK.  According to me, that there is still something at least another carrier.

    Sorry, comms on the BB is not as simple as that...

  • Need help with a PL/SQL code

    Hello

    I am trying to execute the following PL/SQL code, which translates errors, obviously I'm not doing things, but it gives you an idea what I'm trying to do:

    DECLARE

    INT var_count;

    SELECT COUNT (*) IN var_count

    FROM sys.all_tables WHERE OWNER = 'SAKILA' AND table_name = "ACTOR";

    If var_count > 0 then

    BEGIN

    DROP TABLE "ACTOR";

    END;

    /

    Erros:

    SELECT COUNT (*) IN var_count

    *

    ERROR at line 3:

    ORA-06550: line 3, column 1:

    PLS-00103: encountered the symbol "SELECT" at the expected in the following way:

    Start function < an ID > pragma procedure subtype type

    < between double quote delimited identifiers > delete the current cursor

    There is before

    The symbol 'start' has been substituted for "SELECT" to continue.

    ORA-06550: line 7, column 1:

    PLS-00103: encountered the symbol "DROP" when expecting one of the following conditions:

    (begin case declare exit for goto if loop mod null pragma

    raise return select update while < ID >

    < between double quote delimited identifiers of > < a variable binding > < <

    continue the narrow current delete fetch locking insert open rollback

    savepoint sql set run commit forall fusion pipe purge

    Your help to create it in a right way will be appreciated.

    Thank you very much.

    Tonya.

    Try the following:

    My = $ora $csr-> prepare (q {}

    DECLARE

    INT var_count;

    BEGIN

    SELECT COUNT (*) IN var_count

    FROM sys.all_tables WHERE OWNER = 'SAKILA' AND table_name =: ts;

    If var_count > 0 then

    RUN IMMEDIATELY 'DROP TABLE' |: ts | "CASCADE CONSTRAINTS;

    end if;

    END;

    });

  • I bought the DC of Adobe Acrobat pro and completed the info online, but when I use the cd with the product code key it will not take the code?  What do I do then?

    I bought the DC of Adobe Acrobat pro and completed the info online, but when I use the cd with the product code key it will not take the code?  What do I do then?

    Thanks Anubha Goel, final I got it to work... The serial number in the physical box that you buy in the store wasn't the number for the software.  It was the serial number in the cloud, very difficult to know when you see a serial number in the box with the Cd online.  But thanks for the reply to my post. I'll be in offline mode after clicking on answer...  Thank YOU Ana Maria

  • I download the demo version of Lightroom CC for Mac and it bugs with DW021 error code. What should I do?

    I download the demo version of Lightroom CC for Mac and it bugs with DW021 error code. What should I do?

    Hello

    Please visit:-Error 21 or DW021 when installing Photoshop CC 2015

    or

    I need help!

  • I want to uninstall my old CS5 Design Premium from my computer to reinstall it on another computer. What are the steps? Is there something special with the activation codes, etc.?

    I want to uninstall my old CS5 Design Premium from my computer to reinstall it on another computer. What are the steps? Is there something special with the activation codes, etc.?

    You are allowed to have two facilities enabled, so if you prefer you can keep ut on the current computer and just install it on the new as you did initially.  If you want to remove on the other machine, the first thing to do is to disable it by opening a program in the suite and by selecting help-> turn off in the top toolbar.  That's all you need to do to disable the software.  At this point if you prefer you can uninstall it if you want.

    As much as on the new nmachine, as I indicated just, just install it like you did the first time.

  • Named view criteria with no Assistant - I write the SQL code

    Using JDeveloper/ADF 11.1.2.3.
    Is there a way to create a view named with a SQL Select which is more complex than the wizard can write?

    I know that I can write the code to create a view of the criteria when running, but then I can't just drag and drop it as a class one.

    A use case:
    I have a table named FACILITIES, with a secondary table named FACILITY_SERVICES. I want a display criteria for FACILITIES which found all facilities with all the services required in a connection variable is a comma-delimited list.
    WHERE list.to_vc_array(:requiredServices) /* I wrote this function to translate a comma delimited list to my own vc_arraytype. */
       SUBMULTISET OF 
          CAST(MULTISET ( SELECT service
                            FROM facility_services
                           WHERE facilities.facility_id = facility_services.facility_id)
               AS vc_arraytype)
    With the wizard, I can't even write a simple IN the query (football match at least one of the required services), still less the more complex (correspond to ALL required services).

    My blog http://tompeez.wordpress.com/2011/08/21/extending-viewcriteria-to-use-sql-contains-4/ might give you a starting point. There are some hooks that you can use to implement this. Please also check Jobineshs blog (that I mention in my blog)!

    Timo

  • Subquery 'WITH SAWITH0 AS' OBIEE 11 g factoring clause contained in the generated sql code

    I have observed that OBIEE 11 g generates in physics request log query using the (subquery factoring) WITH clause to the generated sql code elegantly readable. It's great! Thanks for the developers. However I have a few questions about it.

    __Background__
    Oracle database ' default behavior is that if you have only a subquery in the section, it runs as a perspective in line and he not materialized before the main sql is running. If you have more than one default database engine materializes all the in the order of definition. In some cases, it can completely blow up the SGA and make a query without end. To divert this behavior, you can apply two tips that work both in inline views in subqueries as well: / * + MATERIALIZE * / and / * + INLINE * /, however Analytics 11 g does not seem to have capabilities of Board at the table level logical, only at the level of the physical table.

    If we go with the current default settings, the developers do not know this feature can fall on serious performance problems for the sake of a few sweets of syntax to the generated sql level, I'm afraid.

    __Questions__

    * It is possible to turn the Analytics Server to not use WITH but views inline instead?
    * Is it possible to sneak in a few boards that would the / * + INLINE * / allusion to the proper place in the subqueries generated if necessary
    * Is the Oracle database has any initialization parameter that can influence the behavior of this subquery factoring and divert by default?

    The WITH statement is not added to make the query more elegant, it is added for performance reasons. If your queries slow to run, then you can have a design problem. In a typical DWH DB SGA should be increased seriously given that ran queries are much larger and complex than on an OLTP DB. In all cases, you can disable the WITH statement in the administration tool by double clicking on your database on the physical layer from object in the features tab. The function is called WITH_CLAUSE_SUPPORTED.

  • Rounded corners code - what is wrong with my code?

    Hello

    I'm trying to use Win DW5 and CSS3 for rounded corners of the boxes (only at the top left and top right rounded - down should be square) in pure CSS3.

    Can someone tell me what is wrong with my code below?  (Top of page code makes 4 corners roudned and background code doesn't appear to upper right corner rounded - and not the left one.

    < div style = "padding: 10px;" Width: 445px; height: 370px; border-radius: 10px; -o-border-radius: 10px; -icab-border-radius: 10px; -khtml-border-radius: 10px; -moz-border-radius: 10px; -webkit-border-radius: 10px; background-color: #d1ddf7; border: 1px solid #000; ">

    < / div >

    < p > < / p >

    "< div style =" width: 445px; height: 370px;

    border-radius:

    -webkit-border-top-left-radius: 10px;

    -webkit-border-top-right-radius: 10px;

    -moz-border-radius-topleft: 10px;

    -moz-border-radius-topright: 10px;

    background-color: #d1ddf7; border: 1px solid #000; ">

    < / div >

    "Thx. for any help.

    Jane

    Take a look at this:

    http://www.CSS3.info/preview/rounded-border/

    Nancy O.
    ALT-Web Design & Publishing
    Web | Graphics | Print | Media specialists
    http://ALT-Web.com/
    http://Twitter.com/ALTWEB
    http://ALT-Web-design.blogspot.com/

Maybe you are looking for

  • iCloud unlock

    Apple Hello. Please help me. I have lock my icloud please help trying to open it.  I don't remember the e-mail address that was used and I don't remember my password. Please help me. I believe in you.

  • Building exe problem

    When you try to build an .exe, I got the following error... Error 6a held at AB_Source_VI.lvclass:Close_Reference.vi-> AB_Build.lvclass:Copy_Files.vi-> AB_Application.lvclass:Copy_Files.vi-> AB_EXE.lvclass:Copy_Files.vi-> AB_Build.lvclass:Build.vi->

  • Model Wifi of S2110 has GPS?

    Does anyone know if the model S2110 chip GPS wifi built in? It says on the site Web of Lenovo, this support of the model 3G AGPS. I suppose that the chip GPS is independent on 3G and GPS module should work with wifi, but is it true?  Thank you

  • 810-145qe want: How do in BIOS

    I have a brand new HP Envy Phoenix 810-145qe. How in the BIOS? There are no key indices, just an HP logo on the splash screen.

  • How to remove or cancel a message SENT through Windows Mail

    Is it possible to recover (delete) an email sent, sent via my Windows Mail account?  If so, how do you go? Thank youMaria