Concatenation Of two Strings.......

Database
Enthusiast

Concatenation Of two Strings.......

Hi,

If I am executing

select * from user where userid=102;

This is working properly, But
if I am rewriting the above query as

select * from user ||' where '|| userid=102;

this is giving me following error

3706: Syntax error: expected something between the word 'user' and '"||"'.
Output directed to Answerset window

where it matters anyone knows please reply me.
4 REPLIES 4
Enthusiast

Re: Concatenation Of two Strings.......

I am not sure how you want the final result to be.

Shouldnt you be using the || operator in the SELECT list?

example:

SELECT 'HELLO' || ' WORLD';
Enthusiast

Re: Concatenation Of two Strings.......

Thanks,

I am writing a macro with a parameter and I need to concatenate this parameter as where condition for the select statement in the macro.

Create macro mymacro (whereCondition varchar(100)) As
(

select myno,myname,myaddress from mytable where ||' '|| :whereCondition;

);

this is giving error

3706: Syntax error: expected something between the 'where' keyword and '"||"'.
Output directed to Answerset window

if someone having it's solution please let me know...

Enthusiast

Re: Concatenation Of two Strings.......

You cant do that with macro's! Its possible to create a dynamic SQL with Stored Procedures.

REPLACE procedure MyProc (IN WhereCondition varchar(100))
BEGIN

CALL DBC.SysExecSQL('select * from SomeTable where ' || whereCondition || ';');
END;

Note:
1. You should have the CREATE PROCEDURE privilege
2. The Owner and the Creator of the procedure should be the same if you have dynamic SQL in the procedure.
Highlighted
Enthusiast

Re: Concatenation Of two Strings.......

And you can't run a select statement from dynamic sql call... you can however declare a dynamic sql cursor if your are on TD12