Home » Developer & Programmer » Forms » frm-40735:when-button-pressed ora:6503 (forms 6i,window xp2)
|
Re: frm-40735:when-button-pressed ora:6503 [message #483940 is a reply to message #483935] |
Thu, 25 November 2010 13:48 |
cookiemonster
Messages: 13938 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
ORA-06503: PL/SQL: Function returned without value
Cause: A call to PL/SQL function completed, but no RETURN statement was executed.
Action: Rewrite PL/SQL function, making sure that it always returns a value of a proper type.
A quick glance at the function you call reveals that if it doesn't return false it'll raise that error.
EDIT: tidied the formatting
[Updated on: Thu, 25 November 2010 13:49] Report message to a moderator
|
|
|
Re: frm-40735:when-button-pressed ora:6503 [message #484405 is a reply to message #483940] |
Tue, 30 November 2010 06:29 |
mehediu
Messages: 46 Registered: February 2010 Location: Dhaka
|
Member |
|
|
Dear Mr.
PACKAGE BODY V_C IS
function v_check(p_item_name varchar2)
return boolean is
begin
for i in 1..length(p_item_name)
loop
if substr(p_item_name,i,'1') in ('1','2','3','$','%','@','!','#') then
return false;
end if;
end loop;
end v_check;
END;
your not returning any value
if substr(p_item_name,i,'1') in ('1','2','3','$','%','@','!','#') then
if this condition failed
use this code may be it will work
PACKAGE BODY V_C IS
function v_check(p_item_name varchar2)
return boolean is
begin
for i in 1..length(p_item_name)
loop
if substr(p_item_name,i,'1') in ('1','2','3','$','%','@','!','#') then
return false;
else
return true;
end if;
end loop;
end v_check;
END;
Thanks
Md. Mehedi Hossain
|
|
|
|
Re: frm-40735:when-button-pressed ora:6503 [message #484428 is a reply to message #483935] |
Tue, 30 November 2010 08:53 |
mehediu
Messages: 46 Registered: February 2010 Location: Dhaka
|
Member |
|
|
Dear Sir,
as far i understant from his package body he want to prevent
1st character can not be ('1','2','3','$','%','@','!','#') of
his string.
if it is so , then i can guarantee my post will work successfully.
Thanks
|
|
|
|
Re: frm-40735:when-button-pressed ora:6503 [message #484452 is a reply to message #484433] |
Tue, 30 November 2010 12:25 |
|
Littlefoot
Messages: 21818 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
@Mehedi, why did you use SUBSTR as
substr(p_item_name, i, '1')"
Substring length is a NUMBER, not a CHARACTER.
OK, I modified your code a little bit (included some outputs and changed return type so that we'd see what's going on). It appears that it works OK (if OP's question was NOT to allow strings that contain any of the following characters: 1, 2, 3, $, %, @, !, #).
SQL> create or replace function v_check(p_item_name varchar2)
2 return char
3 is
4 l_invalids number := 0;
5 l_valids number := 0;
6 begin
7 dbms_output.put_line(p_item_name || ' --------------------');
8 for i in 1..length(p_item_name)
9 loop
10 if substr(p_item_name, i, 1) in ('1','2','3','$','%','@','!','#') then
11 dbms_output.put_line('INVALID - ' || substr(p_item_name, i, 1));
12 l_invalids := l_invalids + 1;
13 else
14 dbms_output.put_line('VALID - ' || substr(p_item_name, i, 1));
15 l_valids := l_valids + 1;
16 end if;
17 end loop;
18
19 if l_invalids > 0 then
20 return ('invalid'); -- actually, return FALSE (input string is invalid)
21 else
22 return ('valid'); -- actually, return TRUE (input string is valid)
23 end if;
24
25 end v_check;
26 /
Function created.
Testing:
SQL> -- invalid strings contain 1, 2, 3, $, %, @, !, #
SQL> select
2 'abcd$e#fg' input_str_1, v_check('abcd$e#fg') result_1,
3 '456xyz' input_str_2, v_check('456xyz') result_2,
4 '$' input_str_3, v_check('$') result_3,
5 ' ' input_str_4, v_check(' ') result_4
6 from dual;
INPUT_STR_ RESULT_1 INPUT_STR_ RESULT_2 INPUT_STR_ RESULT_3 INPUT_STR_ RESULT_4
---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
abcd$e#fg invalid 456xyz valid $ invalid valid
abcd$e#fg --------------------
VALID - a
VALID - b
VALID - c
VALID - d
INVALID - $
VALID - e
INVALID - #
VALID - f
VALID - g
456xyz --------------------
VALID - 4
VALID - 5
VALID - 6
VALID - x
VALID - y
VALID - z
$ --------------------
INVALID - $
--------------------
VALID -
SQL>
[Updated on: Tue, 30 November 2010 12:45] Report message to a moderator
|
|
|
|
Re: frm-40735:when-button-pressed ora:6503 [message #484519 is a reply to message #484471] |
Wed, 01 December 2010 04:22 |
cookiemonster
Messages: 13938 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
mehediu wrote on Wed, 01 December 2010 01:17
But Mr. Maddy(Original post) attach a .fmb file there . which is not running
and giving Error
ORA-06503: PL/SQL: Function returned without value
which not returning any value in some condition
i just sujest him returning vaule when if condition faild.
I pointed that out already. You went one further and suggested an alternative that swapped one problem for another.
Hint: If you've got a loop that'll always exit on the first iteration you're doing something wrong.
mehediu wrote on Wed, 01 December 2010 01:17
Yes ofcourse substring length is number parameter.
though 1 is both number and char.
thats why its not making any problem when he compiling / running
the .fmb file.
In this case it works, but implicit conversion is something you should get in the habit of avoiding.
|
|
|
Goto Forum:
Current Time: Thu Sep 19 18:15:23 CDT 2024
|