dbTalk Databases Forums  

Function 'myfunc' may not be used in SQL

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Function 'myfunc' may not be used in SQL in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Kevin S
 
Posts: n/a

Default Function 'myfunc' may not be used in SQL - 10-07-2008 , 10:29 AM






Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?

Reply With Quote
  #2  
Old   
Aya the Vampire Slayer
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:19 AM






Kevin S <SearleK (AT) googlemail (DOT) com> wa:
Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Use "decode" instead of "myfnc".


--
"Care must be exorcised when handring Opiticar System as it is apts to
be sticked by dusts and hand-fat." --Japanese Translators

"Keep your fingers off the lens." --Elton Byington, English Translator


Reply With Quote
  #3  
Old   
Aya the Vampire Slayer
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:19 AM



Kevin S <SearleK (AT) googlemail (DOT) com> wa:
Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Use "decode" instead of "myfnc".


--
"Care must be exorcised when handring Opiticar System as it is apts to
be sticked by dusts and hand-fat." --Japanese Translators

"Keep your fingers off the lens." --Elton Byington, English Translator


Reply With Quote
  #4  
Old   
Aya the Vampire Slayer
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:19 AM



Kevin S <SearleK (AT) googlemail (DOT) com> wa:
Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Use "decode" instead of "myfnc".


--
"Care must be exorcised when handring Opiticar System as it is apts to
be sticked by dusts and hand-fat." --Japanese Translators

"Keep your fingers off the lens." --Elton Byington, English Translator


Reply With Quote
  #5  
Old   
Aya the Vampire Slayer
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:19 AM



Kevin S <SearleK (AT) googlemail (DOT) com> wa:
Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Use "decode" instead of "myfnc".


--
"Care must be exorcised when handring Opiticar System as it is apts to
be sticked by dusts and hand-fat." --Japanese Translators

"Keep your fingers off the lens." --Elton Byington, English Translator


Reply With Quote
  #6  
Old   
sybrandb@hccnet.nl
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:26 AM



On Tue, 7 Oct 2008 08:29:58 -0700 (PDT), Kevin S
<SearleK (AT) googlemail (DOT) com> wrote:

Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Suggestion 1:
ALWAYS post your 4 digit version number. Most answers are version
dependent.
If you don't want to include a version, consider the people responding
are volunteers and won't keep track of you and your version.
In that case, consider getting (paid) support from Metalink.

Suggestion 2:
ALWAYS post an exactt error message, and ALWAYS look this error up on
http://tahiti.oracle.com PRIOR to posting.

Suggestion 3:
pragma restrict_references is obsolete since 9i. You need to use the
DETERMINISTIC keyword now.

However, suggestion 4:
Why don't you just use built-ins like CASE and DECODE?

--
Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #7  
Old   
sybrandb@hccnet.nl
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:26 AM



On Tue, 7 Oct 2008 08:29:58 -0700 (PDT), Kevin S
<SearleK (AT) googlemail (DOT) com> wrote:

Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Suggestion 1:
ALWAYS post your 4 digit version number. Most answers are version
dependent.
If you don't want to include a version, consider the people responding
are volunteers and won't keep track of you and your version.
In that case, consider getting (paid) support from Metalink.

Suggestion 2:
ALWAYS post an exactt error message, and ALWAYS look this error up on
http://tahiti.oracle.com PRIOR to posting.

Suggestion 3:
pragma restrict_references is obsolete since 9i. You need to use the
DETERMINISTIC keyword now.

However, suggestion 4:
Why don't you just use built-ins like CASE and DECODE?

--
Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #8  
Old   
sybrandb@hccnet.nl
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:26 AM



On Tue, 7 Oct 2008 08:29:58 -0700 (PDT), Kevin S
<SearleK (AT) googlemail (DOT) com> wrote:

Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Suggestion 1:
ALWAYS post your 4 digit version number. Most answers are version
dependent.
If you don't want to include a version, consider the people responding
are volunteers and won't keep track of you and your version.
In that case, consider getting (paid) support from Metalink.

Suggestion 2:
ALWAYS post an exactt error message, and ALWAYS look this error up on
http://tahiti.oracle.com PRIOR to posting.

Suggestion 3:
pragma restrict_references is obsolete since 9i. You need to use the
DETERMINISTIC keyword now.

However, suggestion 4:
Why don't you just use built-ins like CASE and DECODE?

--
Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #9  
Old   
sybrandb@hccnet.nl
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 11:26 AM



On Tue, 7 Oct 2008 08:29:58 -0700 (PDT), Kevin S
<SearleK (AT) googlemail (DOT) com> wrote:

Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
Suggestion 1:
ALWAYS post your 4 digit version number. Most answers are version
dependent.
If you don't want to include a version, consider the people responding
are volunteers and won't keep track of you and your version.
In that case, consider getting (paid) support from Metalink.

Suggestion 2:
ALWAYS post an exactt error message, and ALWAYS look this error up on
http://tahiti.oracle.com PRIOR to posting.

Suggestion 3:
pragma restrict_references is obsolete since 9i. You need to use the
DETERMINISTIC keyword now.

However, suggestion 4:
Why don't you just use built-ins like CASE and DECODE?

--
Sybrand Bakker
Senior Oracle DBA


Reply With Quote
  #10  
Old   
DA Morgan
 
Posts: n/a

Default Re: Function 'myfunc' may not be used in SQL - 10-07-2008 , 03:26 PM



Kevin S wrote:
Quote:
Hello,

I have created a simple function for use in an update statement. The
fuction is

FUNCTION myfnc(p1 IN t1.c1%TYPE)
RETURN VARCHAR2
IS
BEGIN
IF p1 = 3 THEN
RETURN 'A';
ELSE
RETURN 'B';
END IF;
END myfnc;

I use it in a procedure which exists in the same package as the
function as follows

Update t1
set c1 = myfnc(c2);

I am getting Function 'myfunc' may not be used in SQL.

There is no db manipulation going on and I have tried using
PRAGMA RESTRICT_REFERENCES (myfnc, WNDS, WNPS, RNDS, RNPS);
but to no avail.

Any suggestions?
If the function is in a package then there is no function named myfnc.
Try package_name.function_name.
--
Daniel A. Morgan
Oracle Ace Director & Instructor
University of Washington
damorgan@x.washington.edu (replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.