How to insert double quotes & single quotes in postgres using stored procedure.
I have create the table as :
CREATE TABLE public.test (
id INT,
name varchar(50),
lname varchar(100)
)
WITH (oids = false);
2 . Created the stored procedure to insert into that table.
CREATE OR REPLACE FUNCTION test_insert( p_array in TEXT[] ) RETURNS TEXT AS
$$
DECLARE
arrstrMixrecordData ALIAS FOR $1;
plid integer = 0;
pid integer = arrstrMixrecordData[1];
pname varchar = arrstrMixrecordData[2];
plname varchar = arrstrMixrecordData[3];
BEGIN
INSERT INTO
test(id, name, lname)
values
(pid, pname, plname);
plid = ( SELECT id from test ORDER BY id desc limit 1 );
plid = plid + 1;
RETURN plid;
END;
$$
LANGUAGE plpgsql;
3.inserted data using this query:
SELECT * from test_insert( '{1,abc,pqr}'::TEXT[] );
It works !!!
4.All below combination failed . When double quotes comes in single quotes and wise versa
SELECT * from test_insert( '{1,ab"c,pqr}'::TEXT[] );
SELECT * from test_insert( "{1,ab'c,pqr}"::TEXT[] );
SELECT * from test_insert( "{1,ab"c,pqr}"::TEXT[] );
SELECT * from test_insert( '{1,ab'c,pqr}'::TEXT[] );
how to insert above data using stored procedure??