| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to execute an function from the commandline?
[Cc by mail]
Dirk Joosen <d.joosen_at_planetinternet.nl> wrote in message
news:3832B96B.3A996A55_at_REMOVETHIS.planetinternet.nl...
> Hello
>
> I don't no if it works but I have wrote an function and I want to test
> if it works can I run from the commandline?
>
> Here is an example (for me to check if it works) what doesn't run
> CREATE OR REPLACE FUNCTION TEST(a VARCHAR2) RETURN NUMBER IS
> i NUMBER;
> BEGIN
> SELECT COUNT(*) INTO i FROM SOA;
> RETURN i;
> END TEST;
> /
>
> I type from the command line EXEC TEST('Hello')
> It won't execute it give me an error
> begin test('hallo'); end;
>
> *
> ERROR at line 1:
> ORA-06550: line 1, column 7:
> PLS-00221: 'TEST' is not a procedure or is undefined
> ORA-06550: line 1, column 7:
> PL/SQL: Statement ignored
>
> Can some give me a helpful hint, regards Dirk
>
Yep Test is not a procedure but a function and return a value. So you have to bind a variable to the result returned by your function.
I see to way to proceed :
declare
ret number(38);
begin
ret := test('hello');
dbms_output.put_line('the result is :'||ret);
end;
or more simplier :
select test('hello') from dual;
:)
best regards
Aymeric Barantal (mric)
dba @ grolier interactive europe
Received on Mon Nov 22 1999 - 05:45:03 CST
![]() |
![]() |