Re: string = any()

Поиск
Список
Период
Сортировка
От Andy Colson
Тема Re: string = any()
Дата
Msg-id 4F0C652B.6040704@squeakycode.net
обсуждение исходный текст
Ответ на Re: string = any()  ("David Johnston" <polobo@yahoo.com>)
Ответы Re: string = any()  ("David Johnston" <polobo@yahoo.com>)
Список pgsql-general
> This still does not work, even in psql:
> select 'bob' = any( '{''joe'', ''bob'' }'::varchar[] )
>
>     $$ ^ This works for me just fine....though I am not using psql; are
> you having quoting issues?  What error do you get?
>

It runs, but it returns false.  I get false at least.  I'm assuming you
do to, otherwise something weird is going on.



> Its the same as if I try to prepare it in psql:
> clayia=# prepare x as select 'bob' = any($1::varchar[]); PREPARE
> Time: 1.884 ms
> clayia=# execute x( 'string_to_array(''joe,bob'', '','')' );
>
>     $$ ^ Why do you have single-quotes surrounding "string_to_array";
> the EXECUTE now sees the entire literal 'string_to_array....' as a single
> scalar value and thus does not resolve the function call into an array.

Because it simulates how php is actually running the function.  I
prepare the statement, and pass it a string.

execute x( 'string_to_array(''joe,bob'', '','')' );

That simulates pass a single string.  It also results in the same
error's that php is getting... so I just assumed I was testing it correct.

Without the string works fine... but that's not how php works.
execute x( string_to_array('joe,bob', ',') );

You should have the same problem in java, if you:
q = databaseFactory.queryFactory.prepare("select 'bob' =
any($1::varchar[])");

:-) just kidding

Then when you execute it, you have to pass the argument as a string:
q.execute("{'joe','bob'}");


yeah, I'm thinking the execute param step is not running the param
through the entire parse/analyze/whatnot step, so I cannot use functions.

Eh, well, the input is from a website, so wanted to use prepared queries
as much as possible, but I'll just pg_escape all the strings and cat
them all into the sql statement itself.

Ok, nevermind, just got Tom's email.  Double Quotes...

Thanks for the help,

-Andy

В списке pgsql-general по дате отправления:

Предыдущее
От: Andy Colson
Дата:
Сообщение: Re: string = any()
Следующее
От: "David Johnston"
Дата:
Сообщение: Re: string = any()