× 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.



Joe,

Could you share your quote function code ?

Thanks.


-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx
[mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Joe Pluta
Sent: 02 April 2008 07:01
To: RPG programming on the AS400 / iSeries
Subject: Re: Assistance With Embedded SQL

Barbara Morris wrote:
Maybe none of your
code will ever been needed for a VA RPG application, and maybe any VA
RPG programmer who reads your recommendation will know that x'7D'
isn't correct, and maybe your code will never need to be ported to a
non-EBCDIC environment. But maybe it will; you might as well avoid
using techniques that are known to be non-portable, especially when a
completely portable mechanism exists.

Eh, I don't feel strongly either way about it - personally, I find using
a constant to specify a quote is a little bit of overkill. Yes, there
are places where it might make things more readable. But there are also
places when it just makes things long. And then you have to deal with
the inevitable cute short names like QT, QU or even worse, $Q (I always
get a kick out of people who use an variant character in a name meant to
provide an invariant solution).

I've always gotten around the issue by using a quote function. Instead
of trying to add the quotes, I call a routine to do it. Instead of:

+ 'WHERE FIELD=' + QT + myField + QT + " AND ..."

I would use:

+ 'WHERE FIELD=' + quote(myField) + " AND ..."

The nice thing about this is that you can also include flags to check
whether the field itself needs to be checked for embedded quotes,
whether you need to trim, and so on. The only time I might not like
this is if performance is a consideration; there is some overhead
involved in returning a VARYING field.

In any case, if you ARE going to use a named constant for something like
this, it's a prime candidate for a copy book. That way, it stays
consistent throughout your site.

Joe
--
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 ...

Follow-Ups:
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.