I have some problem with postgresql functions. My table name is people and name is text and year is integer.
I like to write a function like this:
create function add() returns void as '
insert into people(name, year) VALUES ('danilo', 12)
' LANGUAGE SQL;
I can't insert string, like danilo.
ERROR: syntax error at or near "danilo"
I tried
...
insert into people(name, year) VALUES ( \'danilo\', 12)
...
but doesn't works.
this works perfectly:
...insert into people( year) VALUES ( 12)...
and this too:
create function add(text) returns void as '
insert into people(name, year) VALUES ($1, 12)
' LANGUAGE SQL;
select add('danilo');
but how can I do something like:
...
insert into people(name, year) VALUES ('danilo', 12)
...
Can anyone help me?
Thank you.