[SQL]Number of rows effected

2004-06-20 Thread Pankaj Chugh
Hi, I have a question how to get number of rows effected in last DML in Postgres. actually i am using procedures for each DML so when a update procedure is called i have to return no of rows effected by it. Thanks Pankaj Chugh This email may contain confidential or privileged information for the in

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Mon, 14 Jun 2004, Jie Liang wrote: > I have a question about performance, in SQL commands: there is a > prepare/execute command, document says it will improve the performance > while repeatly execute a statement. In java.sql: there is a > PreparedStatement object, which can store precompiled

[SQL] Scalar subqueries

2004-06-20 Thread Subbiah, Stalin
Not sure what am I missing. I really appreciate if anyone could point it out to me. I've a logs table that has both sign-in and sign-out records which are differentiated by action flag. Records with action flag = (1,2) => sign-in records and action flag = (3,4,5,6,7) => sign-out records. playfiel

[SQL] pivot-like transformation

2004-06-20 Thread Torsten Lange
Hello, I have a table with measurement values and columns like this: analyses(id, sample_id, parameter[temperatur...], value, unit[°C...], error) With PL/PgSQL at the end I want try to perform a pivot-like arrangement of these data: sample_id|Temperature [°C]|pa

[SQL] question about which column(s) are the right foreign key

2004-06-20 Thread Markus Bertheau
Hi, I have objects in my database, and they have an object id generated with a sequence. Then I have object versions. The ids of object versions need to be unique only within one object id. But for simplicity they're generated with a sequence, too. Now I want to reference an object version. I can

Re: [SQL] pivot-like transformation

2004-06-20 Thread Joe Conway
Torsten Lange wrote: Hello, I have a table with measurement values and columns like this: analyses(id, sample_id, parameter[temperatur...], value, unit[?C...], error) With PL/PgSQL at the end I want try to perform a pivot-like arrangement of these data: sample_i

[SQL] help with Postgres function

2004-06-20 Thread ctrl
Hello. I'd appreciate any help with a function I'm writing. I have a simple table like this: CREATE TABLE websites ( id BIGSERIAL not null primary key, domain character varying(256) NOT NULL, last_fetch timestamp without time zone DEFAULT 'now()', crawl_status smallint not null DEFAULT 1 ); and m

Re: [SQL] Last insert id

2004-06-20 Thread Michalis Kabrianis
Andrei Bintintan wrote: "Is it safe to use "select max(table1_id) from table1" after the insert?" Yes it is safe, but ONLY if you use it inside a transaction.(BEGIN/COMMIT). BR. Hi, I think it would be safe to use : select currval('tablename_idname_seq'); inside a session to receive the current va

Re: [SQL] use of a composite type in CREATE TABLE?

2004-06-20 Thread Josh Berkus
Hannes, > does anyone know how it is posible to set a composite type as the data > type of a column when creating a new table? This is not yet supported. Hopefully it will be supported in the upcoming version 7.5. -- Josh Berkus Aglio Database Solutions San Francisco ---

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Wed, 16 Jun 2004, Jie Liang wrote: > Kris, > Thank you for your valuable response, I used the code you list > following: > > [7.5 code example] > > Then, the compiler complaint: > ServerSidePreparedStatement.java:20: cannot resolve symbol symbol : > method setPrepareThreshold (int) > locati

Re: [SQL] help with Postgres function

2004-06-20 Thread Stephan Szabo
On Wed, 16 Jun 2004, ctrl wrote: > CREATE OR REPLACE FUNCTION getNextWebsiteForCrawl(integer) RETURNS > website AS ' > DECLARE > my_record RECORD; > w website%rowtype; > count smallint; You can't safely use a variable named count and the count(*) expression below I think, so you'll want to rename

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Thu, 17 Jun 2004, Jie Liang wrote: > Kirs, > > I re-compile with setUseServerPrepare(true), it works fine, thanks. > However, reading from my log file, what I saw is that five same SELECTs > with different argument, so I am wondering that the PrepareStatement > really save time than individu

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Thu, 17 Jun 2004, Jie Liang wrote: > Kris, > I have another question, I saw some discussion regarding > PreparedStatement work with array argument, I get a error when I try to > play with it. > E.g. > I have myfunction(int[]), > So, > PrepareStatement st = conn.prepareStatment("SELECT myfunc

Re: [SQL] question about which column(s) are the right foreign key

2004-06-20 Thread Josh Berkus
Markus, > I have objects in my database, and they have an object id generated with > a sequence. Then I have object versions. The ids of object versions need > to be unique only within one object id. But for simplicity they're > generated with a sequence, too. > > Now I want to reference an object

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Thu, 17 Jun 2004, Jie Liang wrote: > Kris, > You are right, I modified that piece of code a little bit, > CallableStatement stmt = conn.prepareCall("{?=call chr(?)}"); > Then my log file were: > Select * from chr(65) as result; > Select * from chr(66) as result; > .. > However, if I use:

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Thu, 17 Jun 2004, Jie Liang wrote: > Hmm, intersting. > I am using jdk 1.3.1, and pg74.213.jdbc2.jar driver, I hope this bug > could be fixed in later version. > I suppose, but I'm going to put it pretty close to the bottom of my todo list because it still works even though it doesn't use

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Fri, 18 Jun 2004, Jie Liang wrote: > However, I am still thinking if I call one SELECT and one DELECT and one > UPDATE and one INSERT a thousand times against same table with different > arguments, should I consider performance iusse? Right, this is a case where some benefits can be found, b

Re: [SQL] [JDBC] Prepare Statement

2004-06-20 Thread Kris Jurka
On Fri, 18 Jun 2004, Jie Liang wrote: > So, I think that PreparedStatement should have a way at least case a > String to an Array or a way to create a Array, because of > conn.prepareStatement("SELECT myfunction('{1,2,3}')") is NOT very > useful. Right, this is a known issue. It's on the list.

[SQL] Function Parameters - need help !!!

2004-06-20 Thread Pradeepkumar, Pyatalo (IE10)
Hi all, I am a new joinee to this mailing list. I am using PostgreSql for my project. We are trying to port a few stored procedures written in SQL to PGSQL. But i am finding difficulties in doing that. I m new to Postgresqldont know much about it. I tried a lot of books and online documents..

[SQL] Strange behaviour updating primary key column.

2004-06-20 Thread Luis Neves
[Sorry if this is a double post.] Hello all, [Postgresql 7.4.2] CREATE TABLE "story" ( "id" int4 NOT NULL, "title" varchar (100) NOT NULL, "body" text NOT NULL, "entryDate" timestamptz NOT NULL, CONSTRAINT "story_pkey" PRIMARY KEY (id) ); In the above table why does the query: UPDATE "story" S