Excellent. Now we are getting somewhere. In the SQL*PLUS example, you are calling this function inside a SELECT statement, which is, as I said, not allowed. You cannot call a function that alters the database inside a SELECT statement, hence the error.

As for the Java issue, you are also calling your function from inside a SELECT statement. Again, you cannot do this. Period. You need to find out how to call a procedure from Java, without a surrounding SELECT statement. Unfortunately, I do not know Java.

************************************
*** ANY JAVA CODERS OUT THERE????????
************************************

My best guess would be:

CREATE OR REPLACE PROCEDURE
addNews
(
l_headline IN VARCHAR2,
l_dt IN DATE ,
l_newid OUT NUMBER
)
BEGIN

l_newId := 1;
SELECT news_id_seq.NEXTVAL INTO l_newId FROM DUAL;

INSERT INTO news( id, headline, dt )
VALUES( l_newId, l_headline, l_dt );

END;


PreparedStatement l_prepStat = new PreparedStatement( "Execute addNews( ?, ?, ? ) " );
l_prepStat.setString( 1, "This is a headline" );
l_prepStat.setDate ( 2, l_somedate );
l_prepStat.setInt ( 3, l_newID );
ResultSet l_rs = con.executeQuery( l_prepStat, l_prepStat.toString() );

However, I would guess that con.executeQuery returns a result set, which you will not have. There is more likely a command called con.executeStatement or something similar that will simply execute your statement and not expect a result set. You must accept the fact that you *cannot* call this function inside a SELECT. Therefore, it does not need to be a function. It should be a proc. There *has* to be a way for java to be able to call a proc. There may be some special coding necessary to handle the OUT parameter (another param in l_prepStat.setInt or maybe a l_prepStat.setIntOut), but this is the direction you should investigate. Finally, depending on how the call is implemented in Java, you may or may not need the EXECUTE in front of AddNews().


************************************
AGAIN, ANY HELP FROM A JAVA CODERS OUT THERE WOULD BE APPRECIATED.
************************************

Hope this helps,

- Chris