alternative to locate function

hi there,
any alternative to locate function,please let me know
LOCATE(';',AL3.MPid) = 0

Thanks
nav29Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave FordSoftware Developer / Database AdministratorCommented:

Personally, I like the LOCATE function better, but POSITION or POSSTR accomplish a similar task.

----------------------------------------------------
POSSTR ( source-string , search-string )

or

POSITION ( search-string IN source-string )

-----

The POSITION and POSSTR functions return the starting position of the first occurrence of one string (called the search-string) within another string (called the source-string).

e.g.
 
Select RECEIVED and SUBJECT columns as well as the starting position of the words 'GOOD' within the NOTE_TEXT column for all entries in the IN_TRAY table that contain these words. 
 
SELECT RECEIVED,
       SUBJECT,
       POSSTR(NOTE_TEXT, 'GOOD') 
FROM   IN_TRAY 
WHERE  POSSTR(NOTE_TEXT, 'GOOD) <> 0

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nav29Author Commented:
error,

AND POSSTR (';',AL3.CMPPLNMPIDS) = 0
order by 1
fetch first 5 rows only;
------------------------------------------------------------------------------
SELECT DISTINCT AL3.CMPPLNMPIDS AS MSGPLANIDENTIFIER, AL3.IMCPLANNAME AS CAMP_PLAN_NAME, AL3.LASTUPDATEDATE, AL3.IMCCAMPPLANCLAS AS CAMP_PLAN_CLASS, AL3.IMCCAMPPLANPRIMGOAL AS CAMP_PLAN_GOAL, AL1.DIMLEVEL1LONGNAME AS CAMP_PLAN_SPONS_LVL1, AL1.DIMLEVEL2LONGNAME AS CAMP_PLAN_SPONS_LVL2, AL1.DIMLEVEL3LONGNAME AS CAMP_PLAN_SPONS_LVL3, CASE WHEN AL2.DIMLEVEL3CODE IS NULL THEN '**' ELSE AL2.DIMLEVEL3CODE END AS ISO_COUNTRY_CODE FROM PDB.IMCCAMPPLAN AL3 LEFT OUTER JOIN PDB.DIMIBMGEOGRAPHY AL2 ON (AL3.IBMGEOGRAPHYID=AL2.IBMGEOGRAPHYID) LEFT OUTER JOIN PDB.DIMSPONSOR AL1 ON (AL1.SPONSORID=AL3.SPONSORID) LEFT OUTER JOIN PDB.DIMIMCPROGRAM AL4 ON (AL4.IMCPROGRAMID=AL3.IMCPROGRAMID) LEFT OUTER JOIN PDB.IMCCAMPPLANMPID AL5 ON (AL3.IMCCAMPPLANID=AL5.IMCCAMPPLANID) WHERE AL3.SYSTEMDEPL <> '' AND AL3.CMPPLNMPIDS <> '' AND POSSTR (';',AL3.CMPPLNMPIDS) = 0 order by 1 fetch first 5 rows only
SQL0132N  A LIKE predicate or POSSTR scalar function is not valid because the
first operand is not a string expression or the second operand is not a
string.  SQLSTATE=42824

SQL0132N  A LIKE predicate or POSSTR scalar function is not valid because the first operand is not a string expression or the second operand is not a string.

Explanation:
0
Dave FordSoftware Developer / Database AdministratorCommented:

According to the error-message, one of the two arguments is not a string. Since we know that a string literal is a string, then AL3.CMPPLNMPIDS must not be string.

Can you tell me the specific data-type of AL3.CMPPLNMPIDS?

-- DaveSlash
0
Dave FordSoftware Developer / Database AdministratorCommented:

Actually, on second glance, it looks like you've got the parameters switched.

Look at the example code I gave above.

HTH,
DaveSlash
0
momi_sabagCommented:
and make sure that AL3.CMPPLNMPIDS is a string
if it's not you can convert it
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
DB2

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.