Re: [SQL] insert into table from list or array ?

2010-10-18 Thread Andreas
Am 18.10.2010 20:14, schrieb Pavel Stehule: 2010/10/18 Andreas: is it possible to insert into a table from list or an array ? yes, it's possible INSERT INTO tmptab SELECT v FROM unnest(string_to_array('1,2,4,2,1',',')) g(v) Thanks Pavel, though I'm just not yet 100% aware how it

Re: [SQL] insert into table from list or array ?

2010-10-18 Thread Pavel Stehule
Hello 2010/10/18 Andreas : >  Hi, > > is it possible to insert into a table from list or an array ? > yes, it's possible INSERT INTO tmptab SELECT v FROM unnest(string_to_array('1,2,4,2,1',',')) g(v) Regards Pavel Stehule > Suppose there is a set of numbers that might be IDs of tables

Re: [SQL] insert into table from list or array ?

2010-10-18 Thread Viktor Bojović
i think that you can try to create temporary table tmptable(id integer, numbers integer[]); and insert into table values (1,array[2, 3, 5, 7, 11, 13, 17, 19, 23, 31, 37, ...]); On Mon, Oct 18, 2010 at 8:00 PM, Andreas wrote: > Hi, > > is it possible to insert into a table from list or an array

[SQL] insert into table from list or array ?

2010-10-18 Thread Andreas
Hi, is it possible to insert into a table from list or an array ? Suppose there is a set of numbers that might be IDs of tables within the DB. To work with them I'd need a temporary table that just holds a single column with those numbers. Something like create temporary table tmptable as se

Re: [SQL] insert into help

2010-09-24 Thread James Kitambara
because of    DEFAULT nextval('table1_id_seq'::regclass)   James Kitambara Computer System Analyst and Programmer Bank of Tanzania, P.O. Box 2939, Mobile : +255 71 3307632, Dar es Salaam, Tanzania.   --- On Wed, 22/9/10, Guillaume Lelarge wrote: From: Guillaume Lelarge Subje

Re: [SQL] insert into help

2010-09-22 Thread venkat
HI, Please go through http://www.java2s.com/Tutorial/Oracle/0080__Insert-Update-Delete/CopyingRowsfromOneTabletoAnotherINSERTINTOselect.htm Thanks and Regards, Venkat On Wed,

Re: [SQL] insert into help

2010-09-22 Thread Guillaume Lelarge
Le 22/09/2010 09:32, Nicholas I a écrit : > Hi, > > i have two tables, > --- > *table1 > > id type serial, name varchar;* > *-- > table 2 > > name varchar;* >

[SQL] insert into help

2010-09-22 Thread Nicholas I
Hi, i have two tables, --- *table1 id type serial, name varchar;* *-- table 2 name varchar;* --- i want to insert

[SQL] INSERT INTO...RETURNING vs SELECT

2010-04-06 Thread Cliff Wells
I was doing some experimenting and was wondering why the following does not work: CREATE TABLE accounts ( id SERIAL PRIMARY KEY NOT NULL, accounts_id INTEGER REFERENCES accounts, name TEXT ); INSERT INTO accounts (accounts_id, name) VALUES ( (INSERT INTO accounts (accounts_id, name) VALUE

Re: [SQL] INSERT INTO...RETURNING vs SELECT

2010-04-05 Thread Cliff Wells
On Mon, 2010-04-05 at 09:10 +0200, Andreas Kretschmer wrote: > Cliff Wells wrote: > > > As far as I can see, INSERT INTO...RETURNING is semantically equivalent > > to SELECT...FROM with a side-effect, so it seems this construct should > > work. Can someone shed some light? > > Well, at the mome

Re: [SQL] INSERT INTO...RETURNING vs SELECT

2010-04-05 Thread Andreas Kretschmer
Cliff Wells wrote: > As far as I can see, INSERT INTO...RETURNING is semantically equivalent > to SELECT...FROM with a side-effect, so it seems this construct should > work. Can someone shed some light? Well, at the moment you can't reuse the RETURNING-values, you have to wait for 9.1, writeabl

[SQL] INSERT INTO...RETURNING vs SELECT

2010-04-04 Thread Cliff Wells
I was doing some experimenting and was wondering why the following does not work: CREATE TABLE accounts ( id SERIAL PRIMARY KEY NOT NULL, accounts_id INTEGER REFERENCES accounts, name TEXT ); INSERT INTO accounts (accounts_id, name) VALUES ( (INSERT INTO accounts (accounts_id, name) VALUE

Re: [SQL] Insert into and Sequence

2007-12-19 Thread Ireneusz Pluta
Apparently, new records are not inserted in the table according to the order selected by "Test_Step_Id" field; As seen in: http://en.wikipedia.org/wiki/SQL: "The order of rows returned by an SQL query is never guaranteed unless an ORDER BY clause is specified". In other words, a databas

[SQL] Insert into and Sequence

2007-12-17 Thread Luigi Pirillo
Hi to all, executing an INSERT INTO like this: INSERT INTO "_Tests_Steps" ( "New_Test_Step_Id", "Test_Step_Id", "Process_Test_Id", "Step_Id", "Sequence_Id", "StepGrou

Re: [SQL] INSERT INTO relational tables

2007-12-10 Thread Stefan Scheidegger
Original-Nachricht > Datum: Mon, 10 Dec 2007 12:29:15 +0100 > Von: "A. Kretschmer" <[EMAIL PROTECTED]> > An: pgsql-sql@postgresql.org > Betreff: Re: [SQL] INSERT INTO relational tables > am Mon, dem 10.12.2007, um 12:08:48 +0100 mailte A. Kretsch

Re: [SQL] INSERT INTO relational tables

2007-12-10 Thread A. Kretschmer
am Mon, dem 10.12.2007, um 12:08:48 +0100 mailte A. Kretschmer folgendes: > am Mon, dem 10.12.2007, um 11:42:04 +0100 mailte Stefan Scheidegger > folgendes: > > Thanks for your hints so far. > > > > I'm looking for both syntax simplicity and referential integrity. I'm > > using c++ with libpqxx

Re: [SQL] INSERT INTO relational tables

2007-12-10 Thread A. Kretschmer
am Mon, dem 10.12.2007, um 11:42:04 +0100 mailte Stefan Scheidegger folgendes: > Thanks for your hints so far. > > I'm looking for both syntax simplicity and referential integrity. I'm > using c++ with libpqxx, but I didn't find a good object-relational > mapper. And I'm too lazy to implement a w

Re: [SQL] INSERT INTO relational tables

2007-12-10 Thread Stefan Scheidegger
Thanks for your hints so far. I'm looking for both syntax simplicity and referential integrity. I'm using c++ with libpqxx, but I didn't find a good object-relational mapper. And I'm too lazy to implement a whole persistency layer as I don't have a huge DB with many relations. I tried Andreas'

Re: [SQL] INSERT INTO relational tables

2007-12-08 Thread Steve Midgley
At 09:23 AM 12/7/2007, [EMAIL PROTECTED] wrote: Date: Fri, 07 Dec 2007 14:22:26 +0100 From: "Stefan Scheidegger" <[EMAIL PROTECTED]> To: pgsql-sql@postgresql.org Subject: INSERT INTO relational tables Message-ID: <[EMAIL PROTECTED]> Hi all I'm new to SQL and I'm facing a problem I can't find a

Re: [SQL] INSERT INTO relational tables

2007-12-07 Thread Andreas Kretschmer
Stefan Scheidegger <[EMAIL PROTECTED]> schrieb: > An example to explain my Problem: Lets say I have a table containing > information about the customer (name, address, ...) and about his > order (pieces, product-name, price). Because one customer can order > several products I split the table into

[SQL] INSERT INTO relational tables

2007-12-07 Thread Stefan Scheidegger
Hi all I'm new to SQL and I'm facing a problem I can't find any information about (google, forums). By now I wonder if I understood something wrong about relational DBs. An example to explain my Problem: Lets say I have a table containing information about the customer (name, address, ...) and

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-04 Thread Richard Broersma Jr
--- Collin Peters <[EMAIL PROTECTED]> wrote: > 2. currval() is guaranteed to be correct within the RULE. This was my > second question. If I call "INSERT INTO Vschematic_insert(..." > simultaneously 1000 times is it guaranteed to be correct? To illistrate using psudo code: //This will always w

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-04 Thread Collin Peters
Hi Richard, Your situation is the same as mine. The only difference is that I actually had a call to nextval() in the actual call to the VIEW. In your case this would be something like "INSERT INTO Vschematic_insert(...". So if you were to try "INSERT INTO Vschematic_insert(nextval('foo_sql'),

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-03 Thread Richard Broersma Jr
--- Collin Peters <[EMAIL PROTECTED]> wrote: > The exact problem is that you can't use nextval() with an INSERTable VIEW I apoligize if I am not understanding your problem correctly. I am unsure as to intent behind using nextval() as opposed to currval(). I do not know if the following DDL wi

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-03 Thread Collin Peters
The exact problem is that you can't use nextval() with an INSERTable VIEW Problem is the same as that in this post: http://archives.postgresql.org/pgsql-sql/2003-07/msg00333.php On 5/3/07, Richard Broersma Jr <[EMAIL PROTECTED]> wrote: --- Collin Peters <[EMAIL PROTECTED]> wrote: > I am havin

Re: [SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-03 Thread Richard Broersma Jr
--- Collin Peters <[EMAIL PROTECTED]> wrote: > I am having the same problem that is documented elsewhere in the > archives. Namely when you have a INSERT RULE on a VIEW the nextval() > function doesn't behave properly (or it doesn't behave how I'd like it > to). > > http://archives.postgresql.o

[SQL] Insert into VIEW using RULE. Not possible to use nextval()?

2007-05-03 Thread Collin Peters
I am having the same problem that is documented elsewhere in the archives. Namely when you have a INSERT RULE on a VIEW the nextval() function doesn't behave properly (or it doesn't behave how I'd like it to). http://archives.postgresql.org/pgsql-sql/2003-07/msg00333.php I'm wondering if anythi

Re: [SQL] INSERT INTO

2007-03-16 Thread Josh Williams
From: "Shavonne Marietta Wijesinghe" <[EMAIL PROTECTED]> > I have 2 tables. TABLE1 and TABLE2. > > TABLE1 has about 400 records with details (client code, name, surname, > address, date of birth) of my clients. > TABLE2 is filled with some of the client details and other extra details > (client cod

Re: [SQL] INSERT INTO

2007-03-16 Thread Alvaro Herrera
Shavonne Marietta Wijesinghe wrote: > Thanks alot What happens if you try to insert a string with $$ on it? -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support ---(end of broa

Re: [SQL] INSERT INTO

2007-03-16 Thread Shavonne Marietta Wijesinghe
TED]>; Sent: Friday, March 16, 2007 2:08 PM Subject: Re: [SQL] INSERT INTO INSERT INTO TABLE2 (TE_INDI) VALUES ($SANT'ANGELO LODIGIANO$); My mistake, a single $ will not work you need two like $$: INSERT INTO TABLE2 (TE_INDI) VALUES ($$SANT'ANGELO LODIGIANO$$); Regards, R

Re: [SQL] INSERT INTO

2007-03-16 Thread Richard Broersma Jr
> INSERT INTO TABLE2 (TE_INDI) VALUES ($SANT'ANGELO LODIGIANO$); My mistake, a single $ will not work you need two like $$: INSERT INTO TABLE2 (TE_INDI) VALUES ($$SANT'ANGELO LODIGIANO$$); Regards, Richard Broersma Jr. ---(end of broadcast)--- T

Re: [SQL] INSERT INTO

2007-03-16 Thread Richard Broersma Jr
> When i have a string that has a ' inside of it the record is not inserted in > to TABLE2. I know > that writing it twice will fix it but how can i ask my ASP code to do it.. > > INSERT INTO TABLE2 (TE_INDI) VALUES ('SANT'ANGELO LODIGIANO'); If you are using PostgreSQL >= 8.0 you can use dollar

Re: [SQL] INSERT INTO

2007-03-16 Thread Guillaume Lelarge
Shavonne Marietta Wijesinghe a ecrit le 16/03/2007 11:31: i took a look at the link Guillaume gave me. But it also explains on PHP i'm using ASP :( Yes, that's why I said that it didn't answer your question. Sorry if this wasn't clear. After a bit of googling, I found the replace function.

Re: [SQL] INSERT INTO

2007-03-16 Thread Shavonne Marietta Wijesinghe
t;[EMAIL PROTECTED]> Sent: Friday, March 16, 2007 10:16 AM Subject: Re: [SQL] INSERT INTO Bart Degryse a ecrit le 16/03/2007 10:03: I don't use ASP but in PHP I would do something in the line of $valuetoinsert = "SANT'ANGELO LODIGIANO"; $query = "INSERT INTO TABLE

Fw: [SQL] INSERT INTO

2007-03-16 Thread Shavonne Marietta Wijesinghe
IL PROTECTED]> Cc: ; "Shavonne Marietta Wijesinghe" <[EMAIL PROTECTED]> Sent: Friday, March 16, 2007 10:16 AM Subject: Re: [SQL] INSERT INTO Bart Degryse a ecrit le 16/03/2007 10:03: I don't use ASP but in PHP I would do something in the line of $valuetoinsert = "S

Re: [SQL] INSERT INTO

2007-03-16 Thread Guillaume Lelarge
Bart Degryse a ecrit le 16/03/2007 10:03: I don't use ASP but in PHP I would do something in the line of $valuetoinsert = "SANT'ANGELO LODIGIANO"; $query = "INSERT INTO TABLE2 (TE_INDI) VALUES ('" . str_replace("'", "''", $valuetoinsert) . "')"; I'm sure ASP has also a string replacement fun

Re: [SQL] INSERT INTO

2007-03-16 Thread Bart Degryse
I don't use ASP but in PHP I would do something in the line of $valuetoinsert = "SANT'ANGELO LODIGIANO"; $query = "INSERT INTO TABLE2 (TE_INDI) VALUES ('" . str_replace("'", "''", $valuetoinsert) . "')"; I'm sure ASP has also a string replacement function >>> "Shavonne Marietta Wijesinghe" <[

[SQL] INSERT INTO

2007-03-16 Thread Shavonne Marietta Wijesinghe
Hello I have 2 tables. TABLE1 and TABLE2. TABLE1 has about 400 records with details (client code, name, surname, address, date of birth) of my clients. TABLE2 is filled with some of the client details and other extra details (client code, address, telephone, etc) So in my ASP page i have a sel

Re: [SQL] Insert into a date field

2007-02-05 Thread Hiltibidal, Robert
g Subject: [SQL] Insert into a date field Hi list, I am trying to insert a record in a table with a date field but the postgresql reports me the following error: ERROR: column "data_nascimento" is of type date but expression is of type integer SQL state: 42804 Hint: You will ne

Re: [SQL] Insert into a date field

2007-02-02 Thread Ezequias Rodrigues da Rocha
Now it's ok thank you. 2007/2/2, Shoaib Mir <[EMAIL PROTECTED]>: Just tried the following way, that might help you: postgres=# create table testing (a date); CREATE TABLE postgres=# insert into testing values (to_date('1963-09-01', '-MM-DD')); INSERT 0 1 postgres=# select * from testing;

Re: [SQL] Insert into a date field

2007-02-02 Thread Shoaib Mir
Just tried the following way, that might help you: postgres=# create table testing (a date); CREATE TABLE postgres=# insert into testing values (to_date('1963-09-01', '-MM-DD')); INSERT 0 1 postgres=# select * from testing; a 1963-09-01 (1 row) -- Shoaib Mir EnterpriseDB (ww

Re: [SQL] Insert into a date field

2007-02-02 Thread Richard Huxton
Ezequias Rodrigues da Rocha wrote: Hi list, I am trying to insert a record in a table with a date field but the postgresql reports me the following error: ERROR: column "data_nascimento" is of type date but expression is of type integer SQL state: 42804 Hint: You will need to rewrite or cast th

[SQL] Insert into a date field

2007-02-02 Thread Ezequias Rodrigues da Rocha
Hi list, I am trying to insert a record in a table with a date field but the postgresql reports me the following error: ERROR: column "data_nascimento" is of type date but expression is of type integer SQL state: 42804 Hint: You will need to rewrite or cast the expression. I tryed like this:

Re: [SQL] insert into / select from / serial problem

2005-08-15 Thread PFC
On Wed, 10 Aug 2005 05:03:47 +0200, tgh002 <[EMAIL PROTECTED]> wrote: I am using a insert statement like: INSERT INTO newtable SELECT field1, field2 FROM anothertable newtable structure is: serial, varchar, varchar What syntax do I use to insert the serial field? Ive tried something like:

Re: [SQL] insert into / select from / serial problem

2005-08-14 Thread Tom Lane
"tgh002" <[EMAIL PROTECTED]> writes: > I am using a insert statement like: > INSERT INTO newtable > SELECT field1, field2 FROM anothertable > newtable structure is: serial, varchar, varchar > What syntax do I use to insert the serial field? I think you want to just let it default, which you'd do

[SQL] insert into / select from / serial problem

2005-08-14 Thread tgh002
I am using a insert statement like: INSERT INTO newtable SELECT field1, field2 FROM anothertable newtable structure is: serial, varchar, varchar What syntax do I use to insert the serial field? Ive tried something like: INSERT INTO newtable SELECT nextval('newtable_id_seq'), field1, field2 FRO

[SQL] INSERT INTO VIEW - Replacement

2004-11-09 Thread marc ratun
Hi, I've this data model: CREATE SEQUENCE a_seq START 1; CREATE SEQUENCE b_seq START 1; CREATE TABLE a ( aid integer NOT NULL PRIMARY KEY, aval character varying (255) NOT NULL ); INSERT INTO a (select nextval('a_seq'),'a1'); INSERT INTO a (select nextval('a_seq'),'a2'); CREATE TABLE b ( b

Re: [SQL] Insert into

2004-01-13 Thread Gabriel Dovalo Carril
El lun, 12-01-2004 a las 10:12, [EMAIL PROTECTED] escribió: > > Hi, > / > > My SELECT STATEMENT : > > dwnc=> insert into cust_lo_dim > dwnc-> (lo_no,lo_date,rcvdate,lo_status) > dwnc-> select c.lono,c.lodate,c.rcvdate,c.status > dwnc-> from custlo_temp c ; > ERROR: column "lo_date" is

[SQL] Insert into

2004-01-12 Thread azwa
Hi,   i've structure table like below and want to load data from temp table into table below :     dwnc=> \d cust_lo_dim                           Table "biosadm.cust_lo_dim"   Column   |         Type          |                 Modifiers ---+---+--

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Jonathan Gardner
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Monday 11 August 2003 03:21, Silke Trissl wrote: > > Is there something like > > INSERT INTO test_table (int_id, cust_id, cust_name) '1', SELECT id, > name from CUSTOMER: > > and if so, what ist the correct statement? If not, what is an > alternativ

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Christopher Browne
Centuries ago, Nostradamus foresaw when [EMAIL PROTECTED] (Silke Trissl) would write: > I would like to insert into a table values from a table and user > defined ones. Here is the example: > > I found this statement to insert values from another table: > > INSERT INTO test_table (cust_id, cust_nam

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Vernon Smith
Coincidentally, I have a very similar case using some twists. The table I want to insert data is something like table A ( user01 int, user02 int, ... primary key (user01, user02), CHECK ( user01 < user02 ) ); And the user table is: tabe user_table ( user int constraint pk_user primary key UNIQ

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Christoph Haller
> > Coincidentally, I have a very similar case using some twists. > > The table I want to insert data is something like > > table A ( > user01 int, > user02 int, > ... > primary key (user01, user02), > CHECK ( user01 < user02 ) > ); > > And the user table is: > > tabe user_table ( > user int constr

Re: [SQL] INSERT INTO ... SELECT

2003-08-14 Thread Vernon Smith
Thanks, Christoph for your thought. An alternative solution I have is to fetch the user table first and act according with the retured value. It doesn't seem to have a single query solution. v. -- - Original Message - DATE: Wed, 13 Aug 2003 13:40:53 From: Christoph Haller <[EM

[SQL] INSERT INTO ... SELECT

2003-08-14 Thread Silke Trissl
Hi, I would like to insert into a table values from a table and user defined ones. Here is the example: I found this statement to insert values from another table: INSERT INTO test_table (cust_id, cust_name) SELECT id, name from CUSTOMER; But the test_table has another column, which should hav

Re: [SQL] Insert into VIEW ???

2001-03-03 Thread Richard Huxton
Jacek Zagorski wrote: > > Is it possible to INSERT into xyz > where xyz is a view ? > What is the proper syntax ? > > Thanks Much > Jacek Zagorski You'll need to set up the rules for updating - PG can't figure out what you want automatically. There's a page on this in the programmer's guide. -

[SQL] Insert into VIEW ???

2001-03-02 Thread Jacek Zagorski
Is it possible to INSERT into xyz where xyz is a view ? What is the proper syntax ? Thanks Much Jacek Zagorski Shasta NetWorks LLC [EMAIL PROTECTED] ---(end of broadcast)--- TIP 3: if posting/reading through Usenet, please send an appropriate sub