Re: [SQL] Escaping the $1 parameter in stored procedures

2003-10-15 Thread robert
Found a solution: -- my_constraint(0) = turn off constraint -- my_constraint(1) = turn ON constraint CREATE OR REPLACE FUNCTION my_constraint(INTEGER) RETURNS VARCHAR AS ' DECLARE cmd VARCHAR; BEGIN IF $1 = 0 THEN

[SQL] Escaping the $1 parameter in stored procedures

2003-10-14 Thread robert
I'm running Postgres 7.3.2 in Redhat 9.0. I'm trying to execute a function below defined as a stored procedure ALTER TABLE tms_schedule DROP CONSTRAINT "$1"; However, postgres thinks the "$1" is a parameter value. How do I tell postgres to treat it as a literal $1? TIA, Robert

Re: [SQL] Escaping \

2001-03-29 Thread Cedar Cox
> > I've a problem with escaping a \ in a string. > > > > When I enter the query: > > > > SELECT '''\\\''; I get the right result: '\' > > > > But when I try this in a Function: > > > > CREATE FUNCTION sp_tmp() RETURNS varchar(10) > > AS ' > > SELECT ''\\\' AS RESULT' > > LANGUAGE 'sql';

Re: [SQL] Escaping \

2001-03-29 Thread Tom Lane
"Martijn van Dijk" <[EMAIL PROTECTED]> writes: > But when I try this in a Function: > CREATE FUNCTION sp_tmp() RETURNS varchar(10) > AS ' > SELECT ''\\\' AS RESULT' > LANGUAGE 'sql'; > I get the following Parse-erros: You need an extra level of quoting because the function body is itsel

Re: [SQL] Escaping \

2001-03-29 Thread Richard Huxton
From: "Martijn van Dijk" <[EMAIL PROTECTED]> > I've a problem with escaping a \ in a string. > > When I enter the query: > > SELECT '''\\\''; I get the right result: '\' > > But when I try this in a Function: > > CREATE FUNCTION sp_tmp() RETURNS varchar(10) > AS ' > SELECT ''\\\' AS RESUL

[SQL] Escaping \

2001-03-29 Thread Martijn van Dijk
Hello all, I've a problem with escaping a \ in a string. When I enter the query: SELECT '''\\\''; I get the right result: '\' But when I try this in a Function: CREATE FUNCTION sp_tmp() RETURNS varchar(10) AS ' SELECT ''\\\' AS RESULT' LANGUAGE 'sql'; I get the following Parse-erros: