-
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:
-
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
-
Sorry for my remark of indenting,
I noticed, my indents are gone too
Regards
Ben de Boer
-
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.
-
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 */
-
Hi,
I any variabe declared in a block is not visible in its outer block.
Thanks
P. Soni
-
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|