landsharkdaddy wrote:
I have not tried that but I will in the morning. The @ in SQL is used to
indicate a parameter passed to the query. In PostgreSQL it seems that the :
is the same as the @ in SQL Server. I tried something like:
SELECT * FROM Customers WHERE FirstName LIKE :custfirst + '%';
And it told me that the + could not be used. Not sure the exact message but
I will check again tomorrow and see what it was and post the results.
T-SQL defines that variables need to start with @ (like, for instance,
in PHP they star with $).
In postgres you have positional parametars, $1, for instance.
You could, for instance, write SQL function in postgres that would do
what you need:
CREATE FUNCTION get_customers_with_like (a_name_part character varying)
RETURNS SETOF customers
AS
$$
SELECT * FROM customers WHERE firstname LIKE $1 || '%';
$$
LANGUAGE 'sql';
In postgres, you use '||' for string concatenation (instead of '+' in
T-SQL).
Mario
--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql