Home » SQL & PL/SQL » SQL & PL/SQL » How to write a script to call a procedure after checking the highest ID..??
How to write a script to call a procedure after checking the highest ID..?? [message #379267] Mon, 05 January 2009 14:48 Go to next message
chase53
Messages: 6
Registered: January 2009
Junior Member

Suppose there is a table with two columns (id, description), If we create a procedure to add a new entry to the above table

how to write a script to call a procedure after checking the highest ID in the corresponding table....???


Thanks
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379278 is a reply to message #379267] Mon, 05 January 2009 18:15 Go to previous messageGo to next message
flyboy
Messages: 1903
Registered: November 2006
Senior Member
Quote:
how to write a script to call a procedure after checking the highest ID in the corresponding table....???

What kind of script? If you mean sqlplus script, then call it in an anonymous PL/SQL block:
begin
  <check the highest ID in the corresponding table>
  <call the procedure>
end;
/

I have no idea, what "checking the highest ID in the corresponding table" shall do nor the exact procedure definition (name, parameters), so I cannot say more.
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379333 is a reply to message #379278] Tue, 06 January 2009 02:06 Go to previous messageGo to next message
pablolee
Messages: 2882
Registered: May 2007
Location: Scotland
Senior Member
Of course flyboy, you mean SQL script rather than SQLPlus script Wink
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379364 is a reply to message #379278] Tue, 06 January 2009 03:59 Go to previous messageGo to next message
chase53
Messages: 6
Registered: January 2009
Junior Member
Corresponding table means the table which I mentioned above...!!!

Lets assume table abc(id,description)....and we have created a procedure to add a new entry...!!!


Now when we call the procedure to add a new entry...it should check the highest id in abc before adding any new entries...!!

Hope u got my problem.....!!!!
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379369 is a reply to message #379364] Tue, 06 January 2009 04:07 Go to previous messageGo to next message
Michel Cadot
Messages: 68737
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Quote:
...it should check the highest id in abc before adding any new entries...!!

And what will happen if 2 users call the same procedure at the same time?

Regards
Michel
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379410 is a reply to message #379369] Tue, 06 January 2009 06:30 Go to previous messageGo to next message
Frank Naude
Messages: 4590
Registered: April 1998
Senior Member
Have you considered using a simple SEQUENCE?
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379421 is a reply to message #379410] Tue, 06 January 2009 06:57 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Probably not, as most / many people think "MAX + 1" way, not paying attention to problems in multiuser environment.
Re: How to write a script to call a procedure after checking the highest ID..?? [message #379450 is a reply to message #379333] Tue, 06 January 2009 09:52 Go to previous message
Frank
Messages: 7901
Registered: March 2000
Senior Member
pablolee wrote on Tue, 06 January 2009 09:06
Of course flyboy, you mean SQL script rather than SQLPlus script Wink

hm...
begin
...
end;

is not sql in my book. Also, such a script can (and probably will) be called from sqlplus and contain some sqlplus commands (spool, set, etc), which would make it a sqlplus-script.


Or am I not getting the joke?
Previous Topic: PL/SQL question
Next Topic: Query help....
Goto Forum:
  


Current Time: Thu Feb 13 17:26:30 CST 2025