Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate a parameter with a SQL?

Status
Not open for further replies.

AlexTardif

Programmer
Apr 11, 2002
14
0
0
CA
Hi,

I just wanna know if it is possible include a parameter or variable to a query.

The code below is not functional (and not useful at all... lol), it's just to give you the general idea behind my question.

Code:
CREATE OR REPLACE FUNCTION Func_Test(P_STRING as VARCHAR2)
RETURN INTEGER
As
V_Cnt INTEGER
BEGIN
    SELECT COUNT(*) INTO V_Cnt
    FROM MyTable
    WHERE MyColumn LIKE ' || P_STRING || ';

END;

Thanks!

Alex
 
Alex -
Yes, and you almost have it:
Code:
CREATE OR REPLACE FUNCTION Func_Test(P_STRING as VARCHAR2)
RETURN INTEGER
As
V_Cnt INTEGER;
BEGIN
    SELECT COUNT(*) INTO V_Cnt
    FROM MyTable
    WHERE MyColumn LIKE '%' || P_STRING || '%';
    RETURN v_cnt;
END;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top