Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rating: Thread Rating: 3 votes, 2.67 average. Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old February 6th, 2006, 06:12 AM
daz4805 daz4805 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 11 daz4805 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 30 m 36 sec
Reputation Power: 0
Executing a Function in Oracle

Hi,

I have created a Package Body and Package Spec for a function to select a username and a password from a table and return the username.

The code i have created is this:-
CREATE OR REPLACE PACKAGE BODY USER_LOGIN
AS

FUNCTION user_select (USERNAME_IN VARCHAR2,
PASSWORD_IN VARCHAR2)
RETURN VARCHAR2 IS
USERNAME_OUT VARCHAR2(12);
BEGIN
SELECT USERNAME
INTO USERNAME_OUT
FROM USERS
WHERE USERNAME = USERNAME_IN
AND PASSWORD = PASSWORD_IN;
RETURN USERNAME_OUT;
END user_select;

END USER_LOGIN;
/

The package body and spec compiles successfully but i am having trouble when i execute this function. I am trying to do this :-

VARIABLE RETVAL VARCHAR2(12)

EXEC User_login.user_select('HELLO','HELLO',:RETVAL );

but i am getting the following error

ERROR at line 1:
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'USER_SELECT'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

Can anyone please help me?

Reply With Quote
  #2  
Old February 6th, 2006, 07:30 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 8,527 pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 1 Day 3 h 19 m 49 sec
Reputation Power: 537
Yours is a function, not a procedure, so call it as:
oracle8 Code:
Original - oracle8 Code
  1. SELECT USER_LOGIN.user_select('PIPPO', 'PLUTO') FROM dual;

Reply With Quote
  #3  
Old February 6th, 2006, 07:37 AM
daz4805 daz4805 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2006
Posts: 11 daz4805 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 30 m 36 sec
Reputation Power: 0
Do i not need to worry about the return parameter when using the
SELECT USER_LOGIN.user_select('PIPPO', 'PLUTO') FROM dual; statement?

Also is the same code to be used in Oracle 10G?

Thanks!

Reply With Quote
  #4  
Old February 6th, 2006, 07:46 AM
pabloj's Avatar
pabloj pabloj is offline
Modding: Oracle MsSQL Firebird
Dev Shed God 8th Plane (8500 - 8999 posts)
 
Join Date: Jun 2001
Location: Outside US
Posts: 8,527 pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level)pabloj User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 3 Months 1 Week 1 Day 3 h 19 m 49 sec
Reputation Power: 537
I've tested in in 10g Express Edition , about the parameter ... say with me: this is a function, not a stored procedure.

Reply With Quote
  #5  
Old October 4th, 2012, 03:07 PM
suryakantipanda suryakantipanda is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 suryakantipanda Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 27 m 23 sec
Reputation Power: 0
declare
result varchar2(10);
BEGIN
result:= USER_LOGIN.user_select('hello','hello1:'); DBMS_OUTPUT.PUT_LINE(result);
END;
/

Reply With Quote
  #6  
Old October 6th, 2012, 01:03 PM
suryakantipanda suryakantipanda is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 2 suryakantipanda Negative: is most likely a SPAMMER and a traitor to the cause. 
Time spent in forums: 27 m 23 sec
Reputation Power: 0
declare
result varchar2(10);
BEGIN
result:= USER_LOGIN.user_select('hello','hello1:'); DBMS_OUTPUT.PUT_LINE(result);
END;
/

or

VARIABLE result varchar2(10)
EXEC :result := USER_LOGIN.user_select('hello','hello1:');

print result
Comments on this post
debasisdas disagrees: This thread was started long before you have ever heard of Oracle. Please do not dig dead threads.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Executing a Function in Oracle

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap