Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 660
  • Last Modified:

alternative to locate function

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

Thanks
0
nav29
Asked:
nav29
  • 3
1 Solution
 
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
 
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

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now