Unix Technical Forum

procedures for adding data

This is a discussion on procedures for adding data within the pgsql Novice forums, part of the PostgreSQL category; --> Hi all I wanted to know how to add a large no of columns in postgresql by running a ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Novice

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-17-2008, 09:24 PM
Mogin Mohandas
 
Posts: n/a
Default procedures for adding data

Hi all
I wanted to know how to add a large no of columns in postgresql by
running a procedure....
but i cant seem to find a syntax for one like the one in
Oracle...if anybody has any idea...please tell me...
Thnks in advance
Mogin

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-17-2008, 09:24 PM
Michael Glaesemann
 
Posts: n/a
Default Re: procedures for adding data


On Dec 19, 2005, at 12:41 , Mogin Mohandas wrote:

> I wanted to know how to add a large no of columns in
> postgresql by running a procedure....


Adding a large number of columns or a large number of rows? I'm
unaware of any method to add a large number of columns other than
using ALTER TABLE.

http://www.postgresql.org/docs/curre...ltertable.html

If you're interested in adding a large number of rows, you may be
interested in COPY.

http://www.postgresql.org/docs/curre.../sql-copy.html

Also, if you describe your situation in more detail (i.e., what you
are trying to accomplish by adding a large number of columns), you
may receive suggestions on how to do this.

> but i cant seem to find a syntax for one like
> the one in Oracle...if anybody has any idea...please tell me...


I am not familiar with Oracle, but others on this list may be. If you
provide the Oracle syntax for what you would like to do, perhaps
another may be able to help you.

Michael Glaesemann
grzm myrealbox com




---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-17-2008, 09:24 PM
Mogin Mohandas
 
Posts: n/a
Default Re: procedures for adding data

Micheal,
Thanx for the info. Im sorry, it was a typing mistake......I
meant a large no of rows......
Basically, I do not want to give each row. I just want to write some
procedure which will generate the column values of each row in a specified
manner.....this is so that I can test a GIST index i tried to build on a UDT
called Complex. The values in the rows dont matter.
In Oracle, a procedure can be used:
Create or Replace Procedure "tablename"
//variable declarations
BEGIN
//do some kind of incrementing or whatever for the variables
used for each column
insert into "tablename" values(
//give the values of each column as required
)
commit;
END

I just wanted to know whether there is something like this in Postgresql
Thanks a lot
Mogin


On 12/18/05, Michael Glaesemann <grzm@myrealbox.com> wrote:
>
>
> On Dec 19, 2005, at 12:41 , Mogin Mohandas wrote:
>
> > I wanted to know how to add a large no of columns in
> > postgresql by running a procedure....

>
> Adding a large number of columns or a large number of rows? I'm
> unaware of any method to add a large number of columns other than
> using ALTER TABLE.
>
> http://www.postgresql.org/docs/curre...ltertable.html
>
> If you're interested in adding a large number of rows, you may be
> interested in COPY.
>
> http://www.postgresql.org/docs/curre.../sql-copy.html
>
> Also, if you describe your situation in more detail (i.e., what you
> are trying to accomplish by adding a large number of columns), you
> may receive suggestions on how to do this.
>
> > but i cant seem to find a syntax for one like
> > the one in Oracle...if anybody has any idea...please tell me...

>
> I am not familiar with Oracle, but others on this list may be. If you
> provide the Oracle syntax for what you would like to do, perhaps
> another may be able to help you.
>
> Michael Glaesemann
> grzm myrealbox com
>
>
>
>


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-17-2008, 09:24 PM
Michael Glaesemann
 
Posts: n/a
Default Re: procedures for adding data


On Dec 20, 2005, at 8:08 , Mogin Mohandas wrote:

> In Oracle, a procedure can be used:
> Create or Replace Procedure "tablename"
> //variable declarations
> BEGIN
> //do some kind of incrementing or whatever for the
> variables used for each column
> insert into "tablename" values(
> //give the values of each column as required
> )
> commit;
> END


Take a look at PL/pgsql. I believe it should be able to do what you
require.

http://www.postgresql.org/docs/curre...e/plpgsql.html

The PostgreSQL documentation is quite good, and is most likely
included with your PostgreSQL installation. It's also included in the
source code, which is available for download. These are good options
if you're interested in offline viewing. The current documentation is
also available online at

http://www.postgresql.org/docs/curre...ive/index.html

Hope this helps.

Michael Glaesemann
grzm myrealbox com




---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:04 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com