Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Oracle function or procedure

Re: Oracle function or procedure

From: Dante <dnotari_at_my-dejanews.com>
Date: Fri, 14 May 1999 09:19:20 GMT
Message-ID: <7hgpqo$qda$1@nnrp1.deja.com>


Svein,
  you have to issues here.

  If you create a function/procedure which   you should specify the PRAGMA RESTRICT clause.

  This is a sort of telling the server what your   procedure/function will do or not.

  With 8.1 the INSERT clause has a RETURNING clause.   This will return eg. your JOB_ID which was used.

Regards
Dante

In article <373BC8F2.1BA8407B_at_petrodata.no>,   svein <sveinf_at_petrodata.no> wrote:
> Hello!
>
> I tried to make a function insert a new record in one of my
> tables and return the NEXTVAL value of the sequence on
> the index of the table.
> The server responded "Function does not guarantee not to
> update the database".
> Does this mean I have to use a procedure to insert new
> records? I tried with a procedure:
>
> CREATE OR REPLACE PROCEDURE ADD_JOB(
> TYPE IN VARCHAR2,
> DISK IN VARCHAR2,
> NAME IN VARCHAR2,
> DATE IN VARCHAR2,
> CLIENT IN VARCHAR2,
> TEST IN VARCHAR2,
> TEST_S IN VARCHAR2,
> STATE IN VARCHAR2,
> CREATOR IN VARCHAR2)
> as
> BEGIN
> select SEQ.NEXTVAL into JOB_ID from dual;
> insert into JOB values
> (JOB_ID, TYPE, DISK, NAME, DATE, CLIENT, TEST, TEST_S, STATE,
CREATOR);
> END;
> /
>
> But the server responds
> "Procedure created with compilation errors", and I can't see
> where I do my mistakes... How can I return the true
> NEXTVAL value if I must use a procedure to insert records?
> Returning CURRVAL is not enough...
>
> I'd be greatful if someone could help me
>
> Regards,
> Svein
>

--== Sent via Deja.com http://www.deja.com/ ==-- ---Share what you know. Learn what you don't.--- Received on Fri May 14 1999 - 04:19:20 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US