DBAsupport.com Forums - Powered by vBulletin
Results 1 to 7 of 7

Thread: pl/sql problem!!

  1. #1
    Join Date
    Nov 2000
    Posts
    43

    Question

    DECLARE
    2 v_weight NUMBER(3) := 600;
    3 v_message VARCHAR2(255) := 'Product 11002';
    4 BEGIN
    5 /* SUB-BLOCK */
    6 DECLARE
    7 v_weight NUMBER(3) := 1;
    8 v_message VARCHAR2(255) := 'Product 11001';
    9 v_new_locn VARCHAR2(50) := 'Europe';
    10 BEGIN
    11 v_weight := v_weight + 1;
    12 v_new_locn := 'Western ' || v_new_locn;
    13 END;
    14 v_weight := v_weight + 1;
    15 v_message := v_message || ' is in stock';
    16 v_new_locn := 'Western ' || v_new_locn;
    17* END;
    18 RA-06550: line 16, column 1:
    LS-00201: identifier 'V_NEW_LOCN' must be declared
    RA-06550: line 16, column 1:
    L/SQL: Statement ignored

    Does anybody can tell me what did I wrong?
    Thanks!
    :confused:

  2. #2
    Join Date
    Feb 2001
    Posts
    180
    Some indenting is always usefull to see what happened,
    I don't know the use of it, but declare :
    v_weight NUMBER(3) := 1;
    v_message VARCHAR2(255) := 'Product 11001';
    v_new_locn VARCHAR2(50) := 'Europe';
    on a higher level, or in this way:

    DECLARE
    v_weight NUMBER(3) := 600;
    v_message VARCHAR2(255) := 'Product 11002';
    BEGIN
    /* SUB-BLOCK */
    DECLARE
    v_weight NUMBER(3) := 1;
    v_message VARCHAR2(255) := 'Product 11001';
    v_new_locn VARCHAR2(50) := 'Europe';
    BEGIN
    BEGIN
    v_weight := v_weight + 1;
    v_new_locn := 'Western ' || v_new_locn;
    END;
    v_weight := v_weight + 1;
    v_message := v_message || ' is in stock';
    v_new_locn := 'Western ' || v_new_locn;
    END;
    END;
    /
    Regards
    Ben de Boer

  3. #3
    Join Date
    Feb 2001
    Posts
    180
    Sorry for my remark of indenting,
    I noticed, my indents are gone too
    Regards
    Ben de Boer

  4. #4
    Join Date
    Aug 2000
    Posts
    2
    Try to declare v_new_locn in the main block declare section. Sub block variables are not visible in main block. Hope I'm right.

  5. #5
    Join Date
    Dec 2000
    Posts
    126
    the scope of v_new_locn is visible INSIDE SUB-BLOCK, it won't be seen in MAIN BLOCK .

    u must declare in in main block


    /* MAIN BLOCK */


    DECLARE
    1 v_new_locn VARCHAR2(50) := 'Europe'; /* <<< MOVE FROM LINE 9 <<< */
    2 v_weight NUMBER(3) := 600;
    3 v_message VARCHAR2(255) := 'Product 11002';
    4 BEGIN
    5 ---/* SUB-BLOCK */
    6 ---DECLARE
    7 -----v_weight NUMBER(3) := 1;
    8 -----v_message VARCHAR2(255) := 'Product 11001';
    9 ----- /* v_new_locn VARCHAR2(50) := 'Europe'; >>> MOVE TO LINE 1 <<< */
    10 -----BEGIN
    11 --------v_weight := v_weight + 1;
    12 --------v_new_locn := 'Western ' || v_new_locn;
    13 -----END; /* SUB-BLOCK */
    14 ---v_weight := v_weight + 1;
    15 ---v_message := v_message || ' is in stock';
    16 ---v_new_locn := 'Western ' || v_new_locn;
    17* END; /* MAIN BLOCK */

  6. #6
    Join Date
    Feb 2001
    Posts
    125
    Hi,

    I any variabe declared in a block is not visible in its outer block.



    Thanks

    P. Soni

  7. #7
    Join Date
    Mar 2001
    Location
    Cologne, Germany
    Posts
    24
    Originally posted by Baili
    Try to declare v_new_locn in the main block declare section. Sub block variables are not visible in main block. Hope I'm right.
    You are. Since the inner block in which the variable is declared is closed in line 13, there is no such variable defined in line 16.

    Commit;
    6502

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width