Connecting Tech Pros Worldwide Help | Site Map

double quotes inside single quotes => ' " ... " '

Newbie
 
Join Date: Oct 2007
Posts: 1
#1: Oct 27 '07
Hi everyone !

I'm new to PostgreSQL and I'm just reading about sequences.
If a sequence is created with upper and lower letters, e.g.

Expand|Select|Wrap|Line Numbers
  1. create sequence "MySeq"
then when one want to use it, it must be done like this:

Expand|Select|Wrap|Line Numbers
  1. insert into table values (nextval('"MySeq"')
I thought that single quotes are enough for that purpose :/
If you do:

Expand|Select|Wrap|Line Numbers
  1. delete from table where something='Test';
it looks only for "Test", not "test" and it used single quotes.
Why isn't it enough for nextval ? Why is it done this way ?

Also, is there a way to automatically insert an incremented
value ? I thought it could be done by inserting null values,
but it inserts a null value - it doesn't trigger the nextval function
to be called, even when a field is defined as default nextval(' ')
Is there a way to achieve it ?

Cheers,

Adrian
Moderator
 
Join Date: Dec 2006
Location: Europe
Posts: 292
#2: Oct 28 '07

re: double quotes inside single quotes => ' " ... " '


Quote:

Originally Posted by serid

Hi everyone !

I'm new to PostgreSQL and I'm just reading about sequences.
If a sequence is created with upper and lower letters, e.g.

Expand|Select|Wrap|Line Numbers
  1. create sequence "MySeq"
then when one want to use it, it must be done like this:

Expand|Select|Wrap|Line Numbers
  1. insert into table values (nextval('"MySeq"')
I thought that single quotes are enough for that purpose :/
If you do:

Expand|Select|Wrap|Line Numbers
  1. delete from table where something='Test';
it looks only for "Test", not "test" and it used single quotes.
Why isn't it enough for nextval ? Why is it done this way ?

Also, is there a way to automatically insert an incremented
value ? I thought it could be done by inserting null values,
but it inserts a null value - it doesn't trigger the nextval function
to be called, even when a field is defined as default nextval(' ')
Is there a way to achieve it ?

Cheers,

Adrian


Put the default value of the column as nextval(sequence_name) when creating table.
Reply