[SQL] Dynamic sql program using libpq

2002-12-17 Thread Prashanth - Kamath
Hi, I am new to the embeeded sql programming. I am able to find couple of example for dynamic sql programming through ecpg. But i want to do dynamic sql programming through libpq. If anyone has program doing the dynamic sql programmming using the libpq libraries please mail to me.Even pointers o

Re: [SQL] Postgres V/S Oracle

2002-12-17 Thread Josh Berkus
Prashanth, > I am working in the database area for the first time. > My work is related to Postgres. Now comparatively i am familiar with > the Postgres. > I am looking for any document on differences between postgres and > oracle w.r.t SQL syntax and built-in functions. > Any pointers in this dir

[SQL] Postgres V/S Oracle

2002-12-17 Thread Prashanth - Kamath
Hi, I am working in the database area for the first time. My work is related to Postgres. Now comparatively i am familiar with the Postgres. I am looking for any document on differences between postgres and oracle w.r.t SQL syntax and built-in functions. Any pointers in this direction will be of

Re: [SQL] pl/pgsql question

2002-12-17 Thread Ludwig Lim
--- Tim Perdue <[EMAIL PROTECTED]> wrote: > I have created a function in pl/pgsql to modify a > row before it gets put > into the database, but it seems my modification is > being ignored, and > the unmodified row is being inserted. > > I have confirmed with this RAISE EXCEPTION that my > "NEW"

Re: [SQL] pl/pgsql question

2002-12-17 Thread Tom Lane
Tim Perdue <[EMAIL PROTECTED]> writes: > I have created a function in pl/pgsql to modify a row before it gets put ^^^ > into the database, but it seems my modification is being ignored, and > the unmodified row is being inserted. > CREAT

[SQL] pl/pgsql question

2002-12-17 Thread Tim Perdue
I have created a function in pl/pgsql to modify a row before it gets put into the database, but it seems my modification is being ignored, and the unmodified row is being inserted. I have confirmed with this RAISE EXCEPTION that my "NEW" row is modified properly, however it is not being stored

[SQL] handling error in a function

2002-12-17 Thread Peter Gabriel
Hi all! i made desperate efforts with handling errors in a function. I am using functions for encapsulating a few sql-statements. Please have a look at this: CREATE FUNCTION sp_fdelce(int4) RETURNS int4 AS ' DECLARE id ALIAS FOR $1; BEGIN DELETE FROM f_ces WHERE fce_id = id; -- "v

Re: Upgrade question - was Re: [SQL] join and dynamic view

2002-12-17 Thread Andreas Joseph Krogh
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Tuesday 17 December 2002 16:09, Christoph Haller wrote: > > That explains it - the server I'm developing on is quite old - I > > didn't > > > realise how old. I'm about to do an upgrade from 7.1.3 to 7.2.1-5 > > over > > > christmas in fact. > > >

Re: Upgrade question - was Re: [SQL] join and dynamic view

2002-12-17 Thread Christoph Haller
> > That explains it - the server I'm developing on is quite old - I didn't > realise how old. I'm about to do an upgrade from 7.1.3 to 7.2.1-5 over > christmas in fact. > > Will I need to dump/restore the database for this upgrade? > I'm not sure. But I think it's never ever a bad idea to do a du

Upgrade question - was Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
On Tuesday 17 Dec 2002 2:31 pm, Tomasz Myrta wrote: > Gary Stainburn wrote: > > I found that the compile error complaining about the 'OR' was on the > > > > CREATE OR REPLACE FUNCTION > > > > line. I removed the 'OR REPLACE' and everything worked fine. > > OR REPLACE is since postgres 7.2 That ex

Re: [SQL] join and dynamic view

2002-12-17 Thread Tomasz Myrta
Gary Stainburn wrote: I found that the compile error complaining about the 'OR' was on the CREATE OR REPLACE FUNCTION line. I removed the 'OR REPLACE' and everything worked fine. OR REPLACE is since postgres 7.2 Also I had to change the returns to 'opaque' and 'return 0' to 'return nul

Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
Hi Christoph, Tomasz, Thanks to you both, I now have: garytest=# select * from users; sid | sname | ops | mpd -+-+-+- 1 | Rod | | 3 2 | Jayne | 5 | 2 3 | Freddie | 3 | (3 rows) garytest=# insert into depts values ('A', 'ADM', 'Administrative'); I

Re: [SQL] join and dynamic view

2002-12-17 Thread Christoph Haller
> > Christoph Haller wrote: > > > Tomasz, > > Could you please point out why this is not a good idea. Thanks. > > How often do you change structure of this view? What happens when during > querying this view someone recreates it? > > What happens to your reports? Do you have them already dynamic? >

Re: [SQL] join and dynamic view

2002-12-17 Thread Tomasz Myrta
Christoph Haller wrote: Tomasz, Could you please point out why this is not a good idea. Thanks. How often do you chage structure of this view? What happens when during querying this view someone recreates it? What happens to your reports? Do you have them already dynamic? Usually I create A4-

Re: [SQL] join and dynamic view

2002-12-17 Thread Christoph Haller
> > I've now started amending your plpgsql script to create this, but as you can > see I've cocked up somewhere. I wonder if you could have a peek at it for > me. > Gary, CREATE OR REPLACE FUNCTION create_users_view() returns integer as ' DECLARE pg_views_rtype pg_views%ROWTYPE; vname_param

Re: [SQL] join and dynamic view

2002-12-17 Thread Tomasz Myrta
Gary Stainburn wrote: How could a plpgsql dynamically create the view? How about a trigger from the on-update of the depts table to drop the view and then create a new one. Could it not do the same thing using outer joins. I don't think it's good idead to do this, but you can recreate views in

Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
Thanks for that Christoph. I've got the view I need : create view users as select s.*, o.rrank as ops, m.rrank as mpd from staff s left outer join ranks o on o.rsid = s.sid and o.rdid = 'O' left outer join ranks m on m.rsid = s.sid and m.rdid = 'M'; which provides: garytest=# select * from

Re: [SQL] join and dynamic view

2002-12-17 Thread Christoph Haller
> As soon as you or somebody else can tell me how to merge Jayne's two > rows into one, > I'm sure I can write a plpgsql function to dynamically create the view > you're looking for. Ok, got it: SELECT sid, sname, SUM("OPS") AS "OPS", SUM("MPD") AS "MPD" FROM ( SELECT staff.*, CASE dsdesc

Re: [SQL] Difference between DB2 7.0 & latest version of PostgresSQL?

2002-12-17 Thread Tarun Galarani
Hello Thanks Hans-Jürgen for quick reply. Would you tell me how can I import a database from DB2 to Postgres. Regards, Tarun Galrani - Original Message - From: "Hans-Jürgen Schönig" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Tuesday, December 17, 2002 5:18 PM Subject: Re: Differ

Re: [SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
Hi Christoph, On Tuesday 17 Dec 2002 12:06 pm, Christoph Haller wrote: > > is it possible to make a dynamically declare a view based on a table? > > Yes, by all means. > > > Is it possible to now define a view such that it returns: > > > > select * from myview; > > sid | Name| OPS | MPD > > -

Re: [SQL] join and dynamic view

2002-12-17 Thread Christoph Haller
> > is it possible to make a dynamically declare a view based on a table? > Yes, by all means. > > Is it possible to now define a view such that it returns: > > select * from myview; > sid | Name| OPS | MPD > -+-+-+- > 1 | Rod | | 3 > 2 | Jayne | 2 | 5

[SQL] Difference between DB2 7.0 & latest version of PostgresSQL?

2002-12-17 Thread Tarun Galarani
Hello We are planning to shift from DB2 to PostgresSQL. What type of problem we can face? Where can I find the difference between IBM DB2 7.0 & latest version of PostgresSQL? Regards Tarun Galrani (Sr. Software Engineer) Waterford India Institute B-5 Pasayadan Panch Pakhadi Thane(W) Ph: 022-25

[SQL] join and dynamic view

2002-12-17 Thread Gary Stainburn
Hi folks is it possible to make a dynamically declare a view based on a table? I have 3 tables create table depts ( did character unique not null, -- key dsdesc character (3), -- short desc ddesc character varying(40) -- long desc ); create table staff ( si

Re: [SQL] UPDATE with a SELECT and subSELECT(About comparing dates and non dates data)

2002-12-17 Thread Christoph Haller
> My problem is that I need to fill in the gaps (the available rain data in the > corresponding stations), and this would be a very good output for me. > I've prepared an UPDATE but it doesn't work. Perhaps someone could tell me > where is the error (I've not a very good knowledge of Postgresql). T