Home » SQL & PL/SQL » SQL & PL/SQL » How to solve this syntax error in function (resolved) (Toad 9.0 for Oracle 9i)
icon5.gif  How to solve this syntax error in function (resolved) [message #503677] Tue, 19 April 2011 00:40 Go to next message
tommy1910
Messages: 4
Registered: April 2011
Junior Member

Hi Friends,

I am new to oracle and I was required to convert my T-SQL function which created by me into Oracle function.

I have tried many samples and still fail to run this function on my TOAD 9.0:

Please any kind heart there guide me through:

Following is my Function which I have attempted in oracle:
CREATE OR REPLACE FUNCTION BASS_FNGETAccessList
( var_Id VARCHAR2(15),var_uType CHAR(1))

  RETURN VARCHAR2(1000) 

IS

var_ItemList  VARCHAR2(1000);
var_acsFlag   INT;

BEGIN




IF var_uType = 'R' THEN
 SELECT ACCESSFLAG INTO var_acsFlag   from BASSCOMMON.BASS_SEC_ROLE_GRANT 
where ROLEID = var_Id and ACCESSRIGHTID = 'VESSEL' aND ELEMENTID = 'MY_VESSELS';
ELSIF var_uType = 'U' THEN
 SELECT ACCESSFLAG INTO var_acsFlag  from BASSCOMMON.BASS_SEC_USER_GRANT 
where USERID = var_Id and ACCESSRIGHTID = 'VESSEL' aND ELEMENTID = 'MY_VESSELS';
END IF;


IF var_acsFlag = 2 THEN
 var_ItemList := 'ALL';
 
ELSIF var_uType = 'R' THEN
 
  SELECT RTRIM(XMLAGG(XMLELEMENT(e,ITEM || ',')).EXTRACT('//text()'),',') INTO var_ItemList 
from BASSCOMMON.BASS_SEC_ROLE_GRANT_ITEM 
  WHERE ROLEID = var_Id and REC_DELETED = 0;

ELSIF var_uType = 'U' THEN

SELECT RTRIM(XMLAGG(XMLELEMENT(e,ITEM || ',')).EXTRACT('//text()'),',') INTO var_ItemList
 FROM(
   SELECT ITEM  from BASSCOMMON.BASS_SEC_USER_GRANT_ITEM 
  where USERID = var_Id and REC_DELETED = 0
  UNION
   SELECT ITEM  FROM BASS_SEC_ROLE_GRANT_ITEM 
  where ROLEID = var_Id and REC_DELETED = 0
)tmp;
  
END IF;


   return var_ItemList;

END;



[mod-edit: code tags added by bb; next time please add them yourself. And MC to limit the size of lines to 80 characters width; next time do it yourself.]

[Updated on: Tue, 19 April 2011 13:20] by Moderator

Report message to a moderator

Re: How to solve this syntax error in function [message #503678 is a reply to message #503677] Tue, 19 April 2011 00:44 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
What error is it? Where exactly?
Re: How to solve this syntax error in function [message #503685 is a reply to message #503678] Tue, 19 April 2011 00:54 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
In addition, do not use TOAD to test your code, use SQL*Plus because:
1/ you can copy and paste the result here in text mode (and formatted see read OraFAQ Forum Guide, "How to format your post?" section)
2/ you avoid TOAD bugs and so we are sure this is a SQL or PL/SQL one.

Regards
Michel
Re: How to solve this syntax error in function [message #503687 is a reply to message #503685] Tue, 19 April 2011 00:59 Go to previous messageGo to next message
Barbara Boehmer
Messages: 9090
Registered: November 2002
Location: California, USA
Senior Member
Oracle does not allow sizes for input parameters or return types, so your function should begin:

CREATE OR REPLACE FUNCTION BASS_FNGETAccessList
  (var_Id       VARCHAR2,
   var_uType    CHAR)
  RETURN        VARCHAR2
IS
...

icon14.gif  Re: How to solve this syntax error in function [message #503709 is a reply to message #503687] Tue, 19 April 2011 01:53 Go to previous messageGo to next message
tommy1910
Messages: 4
Registered: April 2011
Junior Member

Thanks lot , Barbara Boehmer.

After I made the changes like you have advised then it is managed to executed. I am trying to test the function which I have created like this :-

select FNGETAccessList('DY','R') from dual;

Unfortunately, I am getting error like :

ORA-00904: "FNGETAccessList": invalid identifier.

Do you have any idea what could be the wrong?
Re: How to solve this syntax error in function [message #503711 is a reply to message #503709] Tue, 19 April 2011 01:56 Go to previous messageGo to next message
Michel Cadot
Messages: 68645
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
BASS_FNGETAccessList <> FNGETAccessList

Regards
Michel
Re: How to solve this syntax error in function [message #503715 is a reply to message #503711] Tue, 19 April 2011 02:06 Go to previous messageGo to next message
tommy1910
Messages: 4
Registered: April 2011
Junior Member

Thanks Michel, working fine now Laughing
Re: How to solve this syntax error in function [message #503718 is a reply to message #503715] Tue, 19 April 2011 02:09 Go to previous messageGo to next message
tommy1910
Messages: 4
Registered: April 2011
Junior Member

Now I am not sure how to close this topic with Resolved mark Razz
Re: How to solve this syntax error in function [message #503726 is a reply to message #503718] Tue, 19 April 2011 02:28 Go to previous message
ramoradba
Messages: 2456
Registered: January 2009
Location: AndhraPradesh,Hyderabad,I...
Senior Member
No need!
No such options in this forum.

Sriram

[Updated on: Tue, 19 April 2011 02:29]

Report message to a moderator

Previous Topic: retrieve IP address for client who do the transaction
Next Topic: How to implement inner view query
Goto Forum:
  


Current Time: Wed Apr 24 23:49:46 CDT 2024