Simple PL/SQL code error

Hi all

Below a simple PL/SQL code that is generate details on all PMCs on a particular and entry Department as dept_id.
create or replace procedure total_info_dept
   (id IN number)
  
    IS
    emp_name varchar2(30);
    dep varchar2(30);
    sal number;
  
    Begin
 for id in (select b.name,c.dept_name,a.salary into emp_name,dep,sal
   from salary a,emp b,dept c where b.emp_id=a.emp_id and b.dept_id=c.dept_id)
   LOOP
 DBMS_OUTPUT.PUT_LINE('The Dept id is '||id||' Salary ' || sal);
   END LOOP;
  END total_info_dept;
Compiler error is given below: -.

LINE/COL ERROR
-------- -----------------------------------------------------------------
24/6 PL/SQL: statement ignored
24/27 PLS-00306: wrong number or types of arguments in the call to ' |'

Help, please

Concerning
Adam

Hi Piku,

first for formatting your code you need not put the backslash on last {noformat}

{noformat} tag.

This is the correct way of formatting your code
i.e.:
{noformat}

{noformat}
SELECT...
{noformat}

{noformat}

You error is due to the fact that you are not using correctly the cursor.

Your code should be changed in this way:

CREATE OR REPLACE PROCEDURE total_info_dept (id number)
IS
-emp_name VARCHAR2 (30); -no need for a local variable
-dep VARCHAR2 (30);
-sal NUMBER;
BEGIN
FOR id IN (SELECT b.name, c.dept_name, a.salary
-IN emp_name, dep, sal - for cursor without having to copy it to the local variable
OF hsalary a, b of the emp, dept c
WHERE b.emp_id = a.emp_id AND b.dept_id = c.dept_id)
LOOP
Dbms_output.put_line ('The Dept id is' | id.dept_name |) "Salary". ID.salary);
END LOOP;
END total_info_dept;

Regards.
Al                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        

Tags: Database

Similar Questions

  • simple PL/SQL block error

    Hi all


    Here is the code snippet... .i was trying to experiment to build my proc
         
          declare 
             in_dt date  := '1-feb-2010' ;
             
    begin 
    
      select e.* from table_xyz e where e.start_dt  = in_dt;
       
    end;
    
      
    Do you know what I'm doing?


    Thank you!!!
    declare
             in_dt date  := '1-feb-2010' ;
     col1 ...;
     col2 ...;
     col3 ...;
    begin 
    
      select e.*
      into col1,
            col2,
            col3
      from table_xyz e
      where e.start_dt  = in_dt;
    
    end;
    /
    

    -------------
    Sybrand Bakker
    Senior Oracle DBA

  • Do not install the update for SQL Server 2005 Service Pack 3 (KB970892) security code error C0000005

    Do not install the update for SQL Server 2005 Service Pack 3 (KB970892) security code error C0000005

    This update didn't install when I used Vista and is still unable to install now, I updated to Windows 7.

    Have searched for a solution for months with no result. Reason why I updated.

    Any help much appreciated.

    DOUGY,

    Microsoft SQL Server 2005 Express Edition Service Pack

    Post here for assistance:

    http://social.msdn.Microsoft.com/forums/en-us/sqlsetupandupgrade/threads/

    --

  • Process apex Pl/SQL error: ORA-06502: PL/SQL: digital error or value: specified incorrect LOB Locator

    Apex 4.2

    I searched through the forums of the research about this error, but I do not understand what to do from here. I am writing a process that sends an e-mail when a value of the claim is made (or on a button click). Procedure is as follows:

    DECLARE
       l_body        clob;
       l_body_html   clob;
       l_subject    varchar2(100);
    
    BEGIN
      
    l_body := empty_clob();
    l_body_html := empty_clob();
    
    
    IF V('REQUEST') in ('SAVE_ME') AND :P32_PARENT_UPDATED_FL IS NOT NULL THEN
       l_subject :=  'Survey Job Request Updated'||utl_tcp.crlf||utl_tcp.crlf;
       l_body := 'Update'||utl_tcp.crlf;
    
       l_body_html := '<html>
          <head>
             <style type = "text/css">
                 /* Can add style attributes later */
             </style>
          </head>
          <body>'||utl_tcp.crlf;
       l_body_html := l_body_html ||'Survey Job Request has been updated.<br /><br />'||utl_tcp.crlf;
       l_body_html := l_body_html ||'Title: '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_TITLE||utl_tcp.crlf;
       l_body_html := l_body_html ||'<br />Request Category : '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_REQUEST_CATEGORY||utl_tcp.crlf;
       l_body_html := l_body_html ||'<br />Update Date: '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_UPDATE_DATE||utl_tcp.crlf;
       l_body_html := l_body_html ||'<br />Updated By: '||utl_tcp.crlf;
       l_body_html := l_body_html ||:P32_LAST_EDITED_BY_USERID||utl_tcp.crlf;
       l_body_html := l_body_html ||'</body></html>';
    
    
    
    
    
    END IF;
    
    :P32_CANCELLATION_REASON := l_body_html;
    
    apex_mail.send(
       p_to             =>  '[email protected]',
       p_from           =>  '[email protected]',
       p_body           =>  l_body_html,
       p_body_html      =>  l_body_html,
       p_subj           =>  l_subject);
    
    END;
    
    
    
    
    
    
    
    
    
    

    I added two lines to the code (lines 08 and 09) and when I run my program, I now get the error:

    • ORA-21560: 3 argument is null, invalid or out of range

    Without these two lines, I received the error:

    ORA-06502: PL/SQL: digital error or value: specified incorrect LOB Locator

    I'm not quite sure what is wrong or what I can change. There seems to be right, and in fact, it worked before. I have no idea why this error keeps popping up. Any help on that would be great. Thanks in advance.

    Hello

    NewApexCoder wrote:

    Hmmm... good point. I think that apex_mail.send must be called inside the IF block. But in the future, I added several conditional statements, won't I need to include the apex_mail.send function in each IF block? But at the same time, there is the case that if no conditional instructions are met? Tests, when none of the conditions are true (when I had a second IF block in the code), an email would not be defined, which is correct. Could that be causing a problem however. If the IF block is not filled could he always try to send an email about anything or the l_body_html and l_subject fields have in them the garbage that causing ORA error?

    If the call to the procedure of sending (it is a procedure, and not a function) many times is necessary or useful depends on exactly what you're trying to do.

    For example, you can write to Santa for

    • Submit a wish list
    • Change of address
    • Contradiction with your boss, who can you tell Santa you were mean

    or any combination of these grounds.  If you want to send a simple email whenever any of the conditions are met (and not send a when none are met), then you could do something like this:

    DECLARE

    need_to_send BOOLEAN: = FALSE;

    ...

    BEGIN

    ...

    IF wish_list IS NOT NULL

    THEN

    l_body: = l_body | ...

    need_to_send: = TRUE;

    END IF;

    IF old_addresss <> new_address

    THEN

    l_body: = l_body | ...

    need_to_send: = TRUE;

    END IF;

    IF boss_is_a_big_fat_liar

    THEN

    l_body: = l_body | ...

    need_to_send: = TRUE;

    END IF;

    IF need_to_send

    SO - It's the only call to send

    apex_mail. Send...

    In any case, the error message ' ORA-21560: argument 3 sucks...» "is pretty clear: If you have not given a value to everything you're passing as p_body, then you'd better call the procedure.

  • frmcmp cannot compile the modules containing SQL code that connected to the database

    Hello

    I checked several hundred messages of the forum on the net without finding a solution.

    I have a Linux server with 11.1 WebLogics (11 GR 1 material) and FormsRuntime installed.

    I am logged in as root.

    I put all the environment variables based on the values in default.env.

    In addition, I updated TERM and ORACLE_TERM vt220. And TNS_ADMIN to the location of the sqlnet.ora and tnsnames.ora.

    I compiled a simple .pll containing only the following code:

    IS test PROCEDURE

    an INTEGER: = 0;

    BEGIN

    a: = 1;

    END;

    command:

    frmcmp_batch module = TESTLIBPLAIN.pll userid=myuser/mypassword@mydb module_type = LIBRARY output_file = TESTLIBPLAIN.plx compile_all = Yes = Yes = No. batch connection

    result: successful compilation. generated .plx.

    now, I'm trying to compile an another .pll containing just the following code:

    IS test PROCEDURE

    an INTEGER: = 0;

    BEGIN

    Select 1 in the doubles.

    END;

    command:

    frmcmp_batch module = TESTLIBSQL.pll userid=myuser/mypassword@mydb module_type = LIBRARY output_file = TESTLIBSQL.plx compile_all = Yes = Yes = No. batch connection

    result: error:

    "

    11 forms (form of the compiler) Version 11.1.1.3.0 (Production)

    Copyright (c) 1982, 2010, Oracle and/or its affiliates.  All rights reserved.

    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production

    With partitioning, OLAP and Data Mining options

    PL/SQL Version 11.1.0.7.0 (Production)

    Oracle V11.1.1.3.0 - Production procedure generator

    Oracle virtual graphics system Version 11.1.1.3.0 (Production)

    Oracle Multimedia Version 11.1.1.3.0 (Production)

    Oracle tools integration Version 11.1.1.2.0 (Production)

    Common tools Oracle area Version 11.1.1.3.0

    Oracle CORE Production 11.1.0.7.0

    Compile the library TESTLIB.

    Invalidate the body TEST procedure...

    Compilation of body TEST procedure...

    ERROR on line 5, column 1 0

    Ignored SQL statement

    Library TESTLIB closing...

    Errors on TEST:

    PL/SQL ERROR on line 5, column 1 0

    Ignored SQL statement

    Could not generate the library.

    FRM-30312: unable to compile the library.

    "

    the two libraries differ by having used SQl commands or not.

    I tried to compile some more complex .pll and .fmb containg the SQL code. I get similar error messages. The messages that I receive for each module are the same, I would get when compiling the module with FormBuilder 9i (Windows) without being connected to the database.

    So my first thought was, this frmcmp_batch is unable to connect to the database.

    BUT:

    From frmcmp_batch with an invalid user, password, or database name not existing (resp. not in tnsnames.ora), results in appropriate error messages (not found TNS, refusal to sign etc.).

    With myuser/mypassword@mydb I don' t get this kind of messages.

    sqlplus myuser/mypassword@mydb works.

    myuser can access all objects in the database mydb.

    mydb tnsping works.

    When I check v$ session on mydb while (!) frmcmp_batch is running, I see that it is in fact a db session, created from myuser: DB-User = myuser, terminal = myappsever, osuser = root, remote process = frmcmp_batch.  And State of the current session of the db is ACTIVE.

    As a result, frmcmp_batch fails with error messages that I expect that when there is no connection to the base, if it is connected!

    Any ideas what could be wrong with my setup?

    Help appreciated.

    Jean

    I found the solution. Seems, fmrcmp 11g can connect to, but compiles not on the 9i database. With the help of a Database 11 g resolves the problem :-)

  • want to understand the stages of executing pl/sql code

    Hello all;

    I want to know the logic of programming for the pl/sql code, what I have written;

    because I was late yesterday to resolve the simple error.

    > > It's link https://forums.Oracle.com/thread/2565867

    OK now that I have written my code same lineup, but few changes:

    now it's working.  as I said above, I want to know the programming logic "flow of execution steps" of pl/sql code

    1 DECLARE

    2 a number: = 10;

    3 number of b: = 20;

    Number 4 c;

    5 procedure findmin (x IN number, are there in numbers, number of Z OUT) IS

    6 BEGIN

    7 < < BLOCK1 > >

    8 x if you can

    9 z: = x;

    10 other

    11 z: = y;

    12 end if;

    13 END;

    BEGIN 14

    15 < < BLOCK2 > >

    16 findmin(a, b, c);

    17 DBMS_OUTPUT. Put_line (c);

    18 * END;

    19.

    10

    PL/SQL procedure successfully completed.

    > > Is this process flow?  > >

    1. the declaration part.

    2 during playback findmin online no 5 then control passes to the line not 16.

    3. after receving input values, control passes back to 5

    4. then compiler executes the code accordingly.

    Question: how many compiler Oracle will execute code written?

    8f953842-815B-4D8C-833d-f2a3dd51e602 wrote:

    1. the declaration part.

    2 during playback findmin online no 5 then control passes to the line not 16.

    3. after receving input values, control passes back to 5

    4. then compiler executes the code accordingly.

    Question: how many compiler Oracle will execute code written?

    1. any declaration section is processed in order to declare and allocate the space/memory etc.  Including declaring the procedure in scope in memory (the procedure is not executed)

    2 execution block to get the code begins with the first statement after BEGIN

    3. the procedure is called in memory with the parameters passed to it.

    4. when the procedure completes execution returns to the statement in the main execution block, after the procedure call.

    Note:

    The compiler is not executing code, it compiles just in memory or stored in the database (depending on whether it is an anonymous block or the stored procedure / package etc..)

    The code isn't really jump 'line by line', because at the time when it is run, it is compiled down to a pcode (or native code if this is allowed), and which may contain several intermediate statements to run the underlying process.  The compiled code however keep track of line numbers of source code of error for the purposes of statement internally.

  • BUG: Wrong Getting sql code when generating types in jDeveloper 1.1.1.3.0

    I am getting fake SQL code when generating types in JDevelper 11.1.1.3.0.

    Process:

    1. create a new application: Test
    2. create a new project: Project1
    3. create the database offline: ECIS
    4. create a contact schema
    5 create a type:
    CREATE OR REPLACE TYPE HAS_REASON_OF_CETYPE AS OBJECT
    (
    has_reason_of varchar2 (36)
    )

    6 create a table based on the previous type type:
    CREATE OR REPLACE TYPE HAS_REASON_OF_CETYPE_LIST
    AS THE contact.has_reason_of_cetype TABLE;

    7. generate SQL script. Results:

    CREATE THE HAS_REASON_OF_CETYPE_LIST TYPE
    AS_REASON_OF_CETYPE_LIST <-this is the wrong code
    AS THE contact.has_reason_of_cetype TABLE;
    /

    CREATE THE HAS_REASON_OF_CETYPE TYPE
    AS_REASON_OF_CETYPE AS OBJECT <-fact here too
    (
    has_reason_of varchar2 (36)
    )
    /

    I have not seen this error with type names in our project, or this error in the previous version. Someone has seen this before and knows a way around it?

    Published by: user13324293 on July 20, 2010 11:48

    It's a regression in the PS2 (11.1.1.3.0) during our generation of DDL has been rewritten. The problem, in a nutshell, is that while determining if the generated DDL must precede the name of the object with a differnet scheme, there are some erroneous (simpler) made of string manipulation. So if the name (or schema.name) in the source contains the token of what follows (ie the ACE or IS) has the problem. This problem is fixed in 11.1.2.0.0 and 11.1.1.4.0 streams.

    There are two possible solutions.

    You can use instead OF as in the above case (in the STATE does not appear in the name) or simply change the case of ACE so that it is not the same as in the name - that is to say use "beneath", 'As' or 'Sub '.

    I hope this helps.

    Pete - team JDeveloper DB

  • my computer turns off, no code error, no blue screen

    my computer restarts auto no code error, no blue screen, it might be the drivers that I have installed or?  What can I do to solve this problem or found out how to solve this problem

    Hello Shelly,

    Drivers could easily be the cause - or it could be quite a few other things.

    I recommend a restore of the system to a restore point before you did what you did (when it was working fine).  If you use Windows 7, seehttp://www.sevenforums.com/tutorials/700-system-restore.html. If you are using Vista, seehttp://www.howtogeek.com/howto/windows-vista/using-windows-vista-system-restore/. If you are using XP, seehttp://support.microsoft.com/kb/306084. Sometimes this simple process made the rounds and sometimes that doesn't help - but it is easy and worth if she has recently begun.

    Good luck!

    Kosh

  • Result passage of PL/SQL code for the page element

    Hello

    I have created a process in after the header to fill data to the page of the form elements.  The pl/sql code is like bellows.  Then I got the error message:

    ORA-06502: PL/SQL: digital or value error: character number conversion

    My question is that I do not see the difference in format between the page element and block pl/sql variables (e.g. : P31_STUDY_ID vs v_P31_STUDY_ID), they are either numeric or text field (in fact I have hidden field, but don't see conversion back to the digital field solved the problem).  And don't see needs to set the format mask.  Is there another way to detect the column that causes the problem, or if there is a syntax error with my assignment (from the variable element on the page)?  Thank you very much!

    ============================

    Declare

    number of v_P31_STUDY_ID;

    number of v_P31_STUDY_SITE_ID;

    v_P31_STUDY_SITE_NAME VARCHAR2 (255);

    v_P31_STUDY_SITE_NUM varchar2 (10);

    number of v_P31_STUDY_SITE_NAME_NUM_ID;

    number of v_P31_STUDY_SITE_OPEN_STATUS;

    v_p31_comments VARCHAR2 (255);

    Start

    Select

    tbl_study_site.study_id,

    tbl_study_site.study_site_id,

    study_site_name,

    study_site_num,

    STUDY_SITE_NAME_NUM_ID,

    STUDY_SITE_OPEN_STATUS,

    Comments

    in

    v_P31_STUDY_ID,

    v_P31_STUDY_SITE_ID,

    v_P31_STUDY_SITE_NAME,

    v_P31_STUDY_SITE_NUM,

    v_P31_STUDY_SITE_NAME_NUM_ID,

    v_P31_STUDY_SITE_OPEN_STATUS,

    v_p31_comments

    of tbl_study_site, tbl_study_site_attrib

    where tbl_study_site.study_id =: p30_study_name

    and tbl_study_site.study_site_id = tbl_study_site_attrib. STUDY_SITE_ID

    and tbl_study_site_attrib. STUDY_SITE_ATTRIB_ID =: P31_STUDY_SITE_ATTRIB_ID;

    : P31_STUDY_ID: = v_P31_STUDY_ID;

    : P31_STUDY_SITE_ID: = v_P31_STUDY_SITE_ID;

    : P31_STUDY_SITE_NAME: = v_P31_STUDY_SITE_NAME;

    : P31_STUDY_SITE_NUM: = v_P31_STUDY_SITE_NUM;

    : P31_STUDY_SITE_NAME_NUM_ID: = v_P31_STUDY_SITE_NAME_NUM_ID;

    : P31_STUDY_SITE_OPEN_STATUS: = v_P31_STUDY_SITE_OPEN_STATUS;

    : P31_COMMENTS: = v_p31_comments;

    end;

    =============================

    Identify the root cause. He's always on the format of the column, there is an error.  Thanks for your help.

  • "Your PC needs to be repaired - no code error or anything"

    Hello

    I rebooted my laptop today and got your PC needs to be repaired message but that is everything that appears on the screen, no code error or something else, literally that sentence. I have the windows CD that allows me to solve problems etc, but I have no idea where to start as a result of not having an error code. I was wondering if anyone has had or seen something similar and might help or might suggest that what I have to do in the first place.

    Thank you

    Hi Sam,

    There are several factors behind this concern. Let's see if we can address this in a few simple troubleshooting steps:

    -Press the Windows key + r.

    -Type cmd , and then press enter.

    -Type sfc/scannow , and then press enter

    -Let him finish and restart.

    Sfc/scannow command say your Windows search and replace corrupted system files.

    If this does not work for do you a System Restore. Looking to restore your PC to an earlier point in time.  (last resort)

    Feel free to update us if you need further assistance.

    Best regards.

  • While the BLOB conversion of type CLOB error - ORA-06502: PL/SQL: digital error or value

    Passing data from attachment of DB (Blob data Type) after the CLOB data type conversion, giving the error "ORA-06502: PL/SQL: digital error or value" in the PL/SQL package. If the BLOB size 32K > it will give another error works great my procedure.

    For example, I enclose my code here.

    function get_base64 (p_blob_in in blob) return clob is

    CLOB v_clob;

    CLOB v_result;

    whole v_offset;

    v_chunk_size PLS_INTEGER: = 12288;

    v_buffer_varchar varchar2 (32767).

    v_buffer_raw raw (32767).

    Start

    fnd_file.put_line (fnd_file.log, 'here');

    If p_blob_in is null then

    Returns a null value.

    end if;

    DBMS_LOB.CREATETEMPORARY (v_clob, true);

    fnd_file.put_line (fnd_file.log, 'here1');

    v_offset: = 1;

    fnd_file.put_line (fnd_file.log, 'Loop value'-| ceil (DBMS_LOB.) GetLength (p_blob_in) / v_chunk_size));

    because me in 1... ceil (DBMS_LOB. GetLength (p_blob_in) / v_chunk_size) loop

    DBMS_LOB. Read (p_blob_in, v_chunk_size, v_offset, v_buffer_raw);

    v_buffer_raw: = utl_encode.base64_encode (v_buffer_raw);

    v_buffer_varchar: = utl_raw.cast_to_varchar2 (v_buffer_raw);

    DBMS_LOB. WriteAppend (v_clob, length (v_buffer_varchar), v_buffer_varchar);

    v_offset: = v_offset + v_chunk_size;

    end loop;

    fnd_file.put_line (fnd_file.log, 'Out of the loop');

    v_result: = v_clob;

    fnd_file.put_line (fnd_file.log, 'V_result length' - |) DBMS_LOB. GetLength (v_result));

    fnd_file.put_line (fnd_file.log, 'V_result' - | v_result);

    DBMS_LOB.freeTemporary (v_clob);

    Return v_result;

    exception

    while others then

    fnd_file.put_line (fnd_file.log, 'Error based on the encode_base64' - |) SQLERRM);

    Returns a null value.

    end;

    In my main program I call this function as below:

    Main proceedings...

    l_return_clob CLOB.

    Begin

    ....

    l_return_clob: = get_base64 (p_blob_in);

    -In returning it gives error - ORA-06502: PL/SQL: digital error or value

    end;

    Then, please mark the thread ANSWERED.

  • ORA-06502: PL/SQL: digital error or the value in the conversion for a long TIME on the CLOB type

    Hello

    I have an EA of RDBMS Oracle 11.2.0.4.

    I ger the following error when I try to convert a data type LONG to type CLOB data thanks to a PL/SQL procedure:

    declare
    v_prefix varchar2 (20): = null;
    v_text_view_clob clob: = null;
    long v_text_view_long: = null;

    cursor c_v
    is
    Select
    a.view_name as view_name
    Of
    USER_VIEWS one;

    Start
    for r_v in c_v
    loop
    Start
    v_text_view_clob: = null;
    v_text_view_long: = null;

    -Do the SQL code of the view
    Select
    a.Text text
    in
    v_text_view_long
    Of
    USER_VIEWS one
    where
    a.view_name = r_v.view_name;

    v_text_view_clob: = v_text_view_long;

    update of ohibo_views one
    set
    a.view_text = v_text_view_clob
    where
    a.view_name = r_v.view_name;
    exception
    while others then
    dbms_output.put_line ('View =' | r_v.view_name |) "kan niet worden geconverteerd!");
    dbms_output.put_line (substr (sqlerrm, 1, 60));
    end;
    end loop;
    -commit;
    exception
    while others then
    lift;
    end;
    /

    I get the error a specific record:

    View = VER_POLISMUTATIES_VW kan niet worden geconverteerd!

    ORA-06502: PL/SQL: digital error or value

    At looked the origina; Value of type LONG and it is indeed a "long" piece of text.

    However, CLOB has a restriction about 4G * db_block_size and LONG 2 G - 1 according to the documentation.

    I should be able with the method above to convert a LONG in CLOB.

    Anyone had a similar situation?

    Thanks in advance for advice how to solve.

    Kind regards

    PS: my apologies, I didn't know which group to post this discussion: database or PL/SQL.

    Good indeed, a link with the right explanation.

    I didn't know that there was such a function.

    Thank you!

    Kind regards

  • 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;

    });

  • ORA-06502: PL/SQL: digital error or value

    Hello

    We have a package with a cursor that returns the session information:

    create or replace 
    PACKAGE BODY             "LOGIN_AUDIT" 
    ...
    ...
      CURSOR session_cur IS
        SELECT * FROM v$session WHERE audsid=USERENV('sessionid');
    
     session_rec session_cur%ROWTYPE;
    
    ...
    
    FUNCTION get_osuser
        RETURN VARCHAR2
      IS
      BEGIN
        RETURN session_rec.osuser;
      END;
    
    FUNCTION get_dbuser
        RETURN VARCHAR2
      IS
      BEGIN
        RETURN NVL(session_rec.username, 'ORACLE_SYS');
      END;
    
    ...
    

    The package compiled successfully and works ok out for a function that is the get_osuser. When you launch sqlplus, we get the following error:

    Select double LOGIN_audit.get_osuser;

    *

    ERROR on line 1:

    ORA-06502: PL/SQL: digital error or value

    ORA-06512: at "APPUSR. LOGIN_AUDIT', line 94

    ORA-06512: at "APPUSR. LOGIN_AUDIT', line 102

    The APPUSR has select priv on V$ SESSION and a select * from v$ session returns the session information. We can perform any other function since the package without any problem, for example:

    APPUSR@APPD > select double login_audit.get_dbuser;

    GET_DBUSER

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

    APPUSR

    Can someone help us work on what happens please.

    PS Oracle: 11.2.0.3, OS Windows 2008 server.

    Thank you

    Really I have not aside, this and raise the question?

    Why you write all this code?

    wouldn't the following very good enough?

    1. FUNCTION get_osuser RETURN VARCHAR2;                    Use sys_context ('USERENV', 'OS_USER')
    2. FUNCTION get_dbuser RETURN VARCHAR2;                    Use sys_context ('USERENV', 'SESSION_USER')
    3. FUNCTION get_client_info RETURN VARCHAR2;                   Use sys_context ('USERENV', 'CLIENT_INFO')
    4. FUNCTION get_module_info RETURN VARCHAR2;               Use sys_context ('USERENV', 'MODULE')
    5. FUNCTION get_action_info RETURN VARCHAR2;                  Use sys_context ('USERENV', 'ACTION')

    Just do not know, I see the advantage of messing around with this slider and have to fight with the updating of information and others.

    This would totally work around the error you get and probably accelerate - and make it easier to maintain.

    ??

    Unless there is some additional requirements, that I'm missing

  • 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...

Maybe you are looking for