By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,994 Members | 2,036 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,994 IT Pros & Developers. It's quick & easy.

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

P: 1
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
Oct 27 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 700
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.
Oct 28 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.