hi
create sequence mysequence;
create table foo(
id integer default nextval('mysequence'),
bla text,
wombat integer,
foobar date,
primary key(id)
);
insert into foo (wombat) values (88);
now how do i know the id of my newly inserted element? and
how can this be done in a completely co
O Erik Thiele έγραψε στις Nov 19, 2004 :
> hi
>
> create sequence mysequence;
>
> create table foo(
> id integer default nextval('mysequence'),
> bla text,
> wombat integer,
> foobar date,
> primary key(id)
> );
>
> insert into foo (wombat) values (88);
>
> now how do i know the id o
Achilleus Mantzios wrote:
now how do i know the id of my newly inserted element? and
how can this be done in a completely concurrency safe way?
The way to do this is by reading the docs :)
use currval, it is session safe.
The increase in this question suggests the number of new users has
increase
On Nov 19, 2004, at 5:41 PM, Erik Thiele wrote:
now how do i know the id of my newly inserted element? and
how can this be done in a completely concurrency safe way?
This is a FAQ (4.15.1, among others). See currval() and nextval() in
the documentation as well.
Michael Glaesemann
grzm myrealbox c
I seem to recall it was mine. I made the mistake of assuming it wasn't
concurrency safe and was gently corrected by one of the community. I
think it might have been a Tim/Tam Lane. Wonder what happened to him? :-)
M tim tams
rgds
Homer
---(end of broadcast)
Hi All,
PostgreSQL 7.4.5
assume this script:
---
create table test_table
(
id serial,
test_value text
) without oids;
insert into test_table
(test_value)
values ('A');
insert into test_table
(test_value)
values ('B');
insert into test_table
(test_value)
values ('C');
insert into test_table
Riccardo G. Facchini wrote:
Why does select test_without_transaction();
return this info:
"ABCD" (as should be)
and select test_with_transaction();
returns this error?
ERROR: SPI_prepare() failed on "start transaction"
CONTEXT: PL/pgSQL function "test_with_transaction" line 6 at SQL
statement
I'v
Hi all,
I'm trying to understand where the "[ ON COMMIT { PRESERVE ROWS |
DELETE ROWS | DROP } ]" is stored when defining a temporary table.
whenever a table is created, a record in the pg_class is stored with
the info regarding the table, but I haven't been able to locate where
the info regardin
"Riccardo G. Facchini" <[EMAIL PROTECTED]> writes:
> I'm trying to understand where the "[ ON COMMIT { PRESERVE ROWS |
> DELETE ROWS | DROP } ]" is stored when defining a temporary table.
I don't believe it's stored anyplace visible :-(. There's some private
state in the memory of the backend tha
--- Tom Lane <__> wrote:
> "Riccardo G. Facchini" <[EMAIL PROTECTED]> writes:
> > I'm trying to understand where the "[ ON COMMIT { PRESERVE ROWS |
> > DELETE ROWS | DROP } ]" is stored when defining a temporary table.
>
> I don't believe it's stored anyplace visible :-(. There's some
> private
You should use single quotes for all literals.
Examples:
select '2004-06-08' ;
?column?
2004-06-08
select 'user' ;
?column?
--
user
Failing to quote literals will cause unexpected results.
Examples:
select 2004-06-08 ;
?column?
--
1990
select user ;
current_user
--
> -Original Message-
> From: Erik Thiele [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 19, 2004 3:42 AM
> To: [EMAIL PROTECTED]
> Subject: [SQL] get sequence value of insert command
>
>
> hi
>
> create sequence mysequence;
>
> create table foo(
> id integer default nextval('mys
On Fri, Nov 19, 2004 at 12:59:07PM +, Richard Huxton wrote:
> You can have what are called "savepoints" in version 8.0 though, which
> lets you trap errors and rollback to a named (saved) point in your function.
Savepoints in functions don't work as of 8.0.0beta4, unless I'm
doing something
Michael Fuhr <[EMAIL PROTECTED]> writes:
> On Fri, Nov 19, 2004 at 12:59:07PM +, Richard Huxton wrote:
>> You can have what are called "savepoints" in version 8.0 though, which
>> lets you trap errors and rollback to a named (saved) point in your function.
> Savepoints in functions don't work
I have a function that uses an execute statement to insert data into a
table, I do in my implementation of table partitioning.
Anyway, I ran into trouble when NULL values were being passed in
(fields are nullable) and my insert statement turned into a big NULL.
Here's an equivalent statement that
On Fri, Nov 19, 2004 at 11:12:38 -0600,
Don Drake <[EMAIL PROTECTED]> wrote:
> I have a function that uses an execute statement to insert data into a
> table, I do in my implementation of table partitioning.
>
> Anyway, I ran into trouble when NULL values were being passed in
> (fields are nulla
On Fri, Nov 19, 2004 at 11:45:43AM -0600, Bruno Wolff III wrote:
> On Fri, Nov 19, 2004 at 11:12:38 -0600, Don Drake <[EMAIL PROTECTED]> wrote:
> >
> > I was able to work around the problem by using COALESCE (and casting
> > variables since it wants the same data types passed to it).
>
> This is
Don Drake wrote:
select 'some text, should be null:'|| NULL
This returns NULL and no other text. Why is that? I wasn't expecting
the "some text.." to disappear altogether.
Is this a bug?
No. Null is "unknown" if you append unknown (null) to a piece of text,
the result is unknown (null) too.
If
On Fri, 19 Nov 2004 17:48:34 +, Richard Huxton <[EMAIL PROTECTED]> wrote:
> Don Drake wrote:
> > select 'some text, should be null:'|| NULL
> >
> > This returns NULL and no other text. Why is that? I wasn't expecting
> > the "some text.." to disappear altogether.
> >
> > Is this a bug?
>
> N
On Fri, 19 Nov 2004, Don Drake wrote:
> On Fri, 19 Nov 2004 17:48:34 +, Richard Huxton <[EMAIL PROTECTED]> wrote:
> > Don Drake wrote:
> > > select 'some text, should be null:'|| NULL
> > >
> > > This returns NULL and no other text. Why is that? I wasn't expecting
> > > the "some text.." to
Don Drake <[EMAIL PROTECTED]> writes:
> This is still strange to me. In Oracle, the same query would not
> replace the *entire* string with a NULL, it treats the NULL as a no
> value.
Oracle is a bit, um, standards-challenged. They fail to make a
distinction between an empty string and a NULL, b
Someone on this list provided me with a rather elegant solution to this a few
weeks ago:
CREATE OR REPLACE FUNCTION text_concat_nulls_with_an_embedded_space(text, text)
RETURNS text AS 'SELECT CASE WHEN $1 IS NULL THEN $2 WHEN $2 IS NULL THEN $1
ELSE $1 || '' '' || $2 END' LANGUAGE sql;
CREAT
Slick ;o)
This goes in my tool kit...
On Friday 19 November 2004 03:03 pm, Gregory S. Williamson saith:
> Someone on this list provided me with a rather elegant solution to this a
> few weeks ago:
>
> CREATE OR REPLACE FUNCTION text_concat_nulls_with_an_embedded_space(text,
> text) RETURNS text A
On Fri, 19 Nov 2004 15:01:42 -0500, Tom Lane <[EMAIL PROTECTED]> wrote:
> Don Drake <[EMAIL PROTECTED]> writes:
> > This is still strange to me. In Oracle, the same query would not
> > replace the *entire* string with a NULL, it treats the NULL as a no
> > value.
>
> Oracle is a bit, um, standard
24 matches
Mail list logo