× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Sample use:

CALL ROUTINES/DRPCODE('ROUTINES', 'STRIPEMAIL', 'F');

CREATE FUNCTION ROUTINES/STRIPEMAIL (CHAR (512))
RETURNS CHAR (100)
DETERMINISTIC
NO SQL
RETURNS NULL ON NULL INPUT
NO EXTERNAL ACTION ALLOW PARALLEL
SIMPLE CALL
EXTERNAL NAME 'ROUTINES/SRVEMAIL(STRIPEMAIL)'; 

Rob Berendt
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





rob@xxxxxxxxx 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
11/12/2004 04:35 PM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>
cc

Fax to

Subject
Re: Drop procedure if it exists ?






I got this from the list at one time:


create procedure ROUTINES/DRPCODE ( in lib char(10), in name char(10), in
type char(1) )

 LANGUAGE SQL MODIFIES SQL DATA

 S: BEGIN

   Declare ct      Int Default 0;

   Declare tsql     char(45);

   select count(*) into ct from sysibm/ROUTINES

    where trim(SPECIFIC_SCHEMA)=trim(lib)

      and trim(SPECIFIC_NAME)=trim(name);

   IF (ct > 0 and type = 'P') then

     set tsql = 'drop Procedure ' || trim(lib) || '/' || trim(name);

   END IF;

   IF (ct > 0 and type = 'F') then

     set tsql = 'drop Function ' || trim(lib) || '/' || trim(name);

   END IF;

   IF (ct > 0) then

     PREPARE drp from tsql;

     EXECUTE drp;
  END IF;
END S;

Rob Berendt
-- 
Group Dekko Services, LLC
Dept 01.073
PO Box 2000
Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





"Luqman" <pearlsoft@xxxxxxxxxxxx> 
Sent by: rpg400-l-bounces@xxxxxxxxxxxx
11/11/2004 03:13 AM
Please respond to
RPG programming on the AS400 / iSeries <rpg400-l@xxxxxxxxxxxx>


To
rpg400-l@xxxxxxxxxxxx
cc

Fax to

Subject
Re: Drop procedure if it exists ?






Hi Hauser,

I have an sql script file which recreates 10 procedures and whenever I 
make
changes in any of the procedure, I just run that file, and if the 
procedure
does not exist and I use drop procedure, then the script stops and system
raises error that procedure cannot be drop because it does not exist.

Thats why I want to drop the procedure if it exists,before creating it 
again.

In oracle, create or replace procedure is very handy, while in sql server, 


IF EXISTS can be used to check
for procedure existance.


Best Regards,

Luqman




"HauserSSS" <Hauser@xxxxxxxxxxxxxxx> wrote in
message news:HFEAIBMAHGFKNPHBOMFIAEJNCCAA.Hauser@xxxxxxxxxxxxxxxxxx
Hi Larry and Luqman,

there is no UPDATE PROCEDURE or CHANGE PROCEDURE in SQL.
You have to drop the procedure before it can be recreated.
And because of the ability of overloading procedures, it is possible to 
have
a procedure with the same nambe but different number of parameters in the
same schema (or library).

If a procedure is overloaded, you must either specify the parameter
definitions or the specific name when dropping the procedure.

An IF-Statement can only be used in Triggers, Stored Procedures or User
Defined Functions.

But why no simply typing the drop statement and executing it.
If the procedure does not exist, the drop statement will not be 
successful!

In a Second Statement you can create the function.

Both statements can be seperated by semi colons (;)
and executed one after the other.

Birgitta


-----Ursprüngliche Nachricht-----
Von: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx]Im Auftrag
von Larry Ducie
Gesendet: Mittwoch, 10. November 2004 14:03
An: rpg400-l@xxxxxxxxxxxx
Betreff: Re: Drop procedure if it exists ?


Hi Luqman,

<snip>
How can I check using Navigator Run Sql Script, if the procedure already
exists, drop it before recreating it.
</snip>

You should be able to use:

CREATE or UPDATE procedure MYPROCEDURE... ?

Cheers

Larry Ducie


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.




--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.





--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.


--
This is the RPG programming on the AS400 / iSeries (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.