Home » Developer & Programmer » Forms » Call a procedure
Call a procedure [message #310177] Mon, 31 March 2008 08:29 Go to next message
bluerratiq
Messages: 22
Registered: March 2008
Location: Bucharest
Junior Member
Hello,
I am trying to create an application something like a library administration.
I have some difficulties when I am trying to insert some records. I've created a procedure which inserts only distinct author names (for the books) and I am trying to call the procedure when a button is pressed. Also I want to use substitution variables.
While running it from Toad, works fine, but in Forms I can figure it out why it doesn't work .. the plsql code doesnt compile.

This is the procedure:

PROCEDURE InsertAutor IS
POET VARCHAR2(50);
ESTE NUMBER;
BEGIN
SELECT COUNT(*)
INTO ESTE
FROM AUTOR WHERE NUME_AUTOR=POET;
IF ESTE=0 THEN INSERT INTO AUTOR(NUME_AUTOR) VALUES(POET);
COMMIT;
END IF;
EXCEPTION
WHEN OTHERS THEN ROLLBACK;

END;

In Toad I used to: call InsertAutor('&Nume_Autor') and works.
What code should I put behind a WHEN-BUTTON-PRESSED trigger to call this procedure?
Thanks for your advices and remember that I am new within the Oracle environment Very Happy and also here.
Thanks again.
Re: Call a procedure [message #310301 is a reply to message #310177] Mon, 31 March 2008 20:10 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
You need to pass the contents of the author item into the procedure as a parameter.

I would suggest NOT doing a commit in your procedure.

David
Re: Call a procedure [message #310403 is a reply to message #310301] Tue, 01 April 2008 02:05 Go to previous messageGo to next message
bluerratiq
Messages: 22
Registered: March 2008
Location: Bucharest
Junior Member
Thanks David for the answer. Silly me, sometime I "refuse" to think Very Happy

I still have a question .. how can I make use of substitution variables in Forms? I mean, that I want the user to input a value for the procedure's parameter.
In Toad I used to write:
INSERT INTO CARTI (NUME_CARTE, AN_APARITIE, STOC)
VALUES ('&NUME_CARTE',&AN_APARITIE,&STOC);

Thank you again.

[Updated on: Tue, 01 April 2008 07:58]

Report message to a moderator

Re: Call a procedure [message #310921 is a reply to message #310403] Wed, 02 April 2008 19:29 Go to previous message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
INSERT INTO CARTI
            (NUME_CARTE, AN_APARITIE, STOC)
     VALUES (:blk.itm1, :blk.itm2, :blk.itm3);

David
Previous Topic: report generation shows ora00942-table or view does not exist
Next Topic: Disable keyboard (merged)
Goto Forum:
  


Current Time: Tue Feb 11 20:21:28 CST 2025