Subject Re: [firebird-support] Re: Inserting 100's of thousands from a SP
Author Jason Dodson
What is "one thing"? That term alone is completely ambiguous. I could
have a function DecodeMP3ToWavFile(...). It does one thing, and that is,
decoding mp3 files to wav files. Inside though, you will see it goes
about this by doing "a bunch of whacky stuff".

A more explicit example would be:

We have a table, we will call "People". For the sake of simplicity, we
will have the fields Person_ID, FirstName, and LastName (Dont dwell on
the example, just try and understand the direction).

Now we make a stored procedure:

Create Procedure AddNewPerson
(
In_FirstName VarChar(50),
In_LastName VarChar(50)
)
Returns
(
Out_Person_ID Integer
)
as
Begin
New_Person_ID = NULL;
For
Select Person_ID
From People
Where Upper(FirstName) = Upper(:In_FirstName)
Into :New_Person_ID
Do Begin
Leave;
End

If (New_Person_ID = NULL) Then
Begin
New_Person_ID = Gen_ID(Person_ID_Generator, 1);

Insert Into People
(Person_ID, FirstName, LastName)
Values
(:New_Person_ID, :In_FirstName, :In_LastName);
End

Suspend;
End


Clay Shannon wrote:
> << I will give you a perfect example of wanting to do a Commit within a
> stored procedure. Currently, I have a messload of stored procedures that
> work like function calls, in that, they do a bunch of wacky stuff...>>
>
> I consider that to be a design flaw--functions should do one thing and one
> thing only, not "a bunch of wacky stuff."
>
> Clay Shannon,
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Yahoo! Groups Links
>
>
>
>
>
>
>
>