Home » SQL & PL/SQL » SQL & PL/SQL » Function declartation (oracle 10g)
Function declartation [message #638713] Fri, 19 June 2015 02:15 Go to next message
arun888
Messages: 100
Registered: June 2015
Location: INDIA
Senior Member
I am learning pl sql. I have created a function using PL SQL technology.

Using function I have tried to return the chain name. and I declared the datatype as number. But still the output is not generated.

set echo on
set serveroutput on 
create or replace function get_str (par_c_str in number) 
return character IS
c_sub store.subchain%type;
BEGIN
select chain into c_sub from store where store=par_c_str;
return c_sub;
end get_str


I have executed the above the function and received a below error. I need to change the data type. do u have any idea what data type I would neeed to change it.

ORA-06502: PL/SQL: numeric or value error: character string buffer too small
Re: Function declartation [message #638716 is a reply to message #638713] Fri, 19 June 2015 02:33 Go to previous messageGo to next message
Michel Cadot
Messages: 68776
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator

See:
c_sub store.subchain%type;
select chain


Re: Function declartation [message #638717 is a reply to message #638713] Fri, 19 June 2015 02:33 Go to previous messageGo to next message
Littlefoot
Messages: 21826
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If you are selecting STORE.CHAIN, why did you declare C_SUB variable as STORE.SUBCHAIN?
Re: Function declartation [message #638720 is a reply to message #638713] Fri, 19 June 2015 02:40 Go to previous message
arun888
Messages: 100
Registered: June 2015
Location: INDIA
Senior Member
thanks for identifying the root cause. its work now.

thanks for your help.
Previous Topic: dynamic input value passing
Next Topic: Cross tab SQL query
Goto Forum:
  


Current Time: Mon Aug 03 02:25:42 CDT 2026