postgresql - Postgres escape a single quote -


i have following postgres query:

select sum(cost)  db id not in (<parameter>) 

<parameter> dynamic text field multiple id's need inserted. if type in

123, 456

as id's, results in:

select sum(cost)  db id not in ('123,456') 

which doesn't run properly.

i can change query, can't change input field. if type in

123','456

it results in:

select sum(cost)  db id not in ('123'',''456') 

when change query into:

select sum(cost)  db id not in ('<parameter>') 

and type in

123,456 results in:

select sum(cost)  db id not in (''123'',''456'') 

i've got working mysql, not postgresql. idea how trick postgresql?

try like:

select sum(cost)  db id != all(('{'||'123,456'||'}')::numeric[]) 

it form array string input values : {123,456}, cast array , check id against elements of array.


Comments

Popular posts from this blog

image - ClassNotFoundException when add a prebuilt apk into system.img in android -

I need to import mysql 5.1 to 5.5? -

Java, Hibernate, MySQL - store UTC date-time -