pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh <jgooding@ttitech.net>
To: pgsql-sql@postgresql.org
Subject: Re: Greetings folks, dumb question maybe?
Date: Wed, 12 May 2010 13:57:14 -0400
Message-ID: <4BEAEBFA.5090304@ttitech.net> (raw)
In-Reply-To: <4BEAE646.9050902@ttitech.net>
References: <4BEAE646.9050902@ttitech.net>

On 05/12/2010 01:32 PM, Josh wrote:
> Hello, I'm a little new at this so please bear with me.
>
> I am trying to create a function that loads 100M test records into a 
> database,  however I am having a hard time building the function that 
> does so.
>
> I'm trying to do this in PGAdmin III for Ubuntu.  Is there something 
> that I have wrong with this?  I know that this works in MySQL (and yes 
> I know that MySQL bends the SQL Standards), but I am not sure what I 
> am doing wrong exactly.  I am coming up with the error that says 
> there's an error in my syntax near the v INTEGER := 0 line.  I get the 
> same error in psql as I do in the PGAdmin III.
>
> I have the following so far:
>
> DECLARE
> v INTEGER := 0;
> BEGIN
> while v < 100000000
> DO
> INSERT INTO unpart_tbl_test VALUES
> (v, 'test string data', adddate('1995-01-01', (rand(v)*36520) mod 3652));
> v := v + 1;
> END WHILE;
> END;
>
> Any insight would be greatly appreciated.
>
> - J

after some digging I had to first create a language plpgsql, then I 
changed the function to be as follows:

CREATE FUNCTION no_part_tbl() RETURNS void AS '
DECLARE
v INTEGER := 0;
BEGIN
WHILE v < 100000000 LOOP
INSERT INTO no_part_tbl VALUES
(v, "testing no parts", adddate("1995-01-01",
(rand(v)*36520 % 3652));
v := v + 1;
END LOOP;
END;
' LANGUAGE 'plpgsql';

And it seems to accepted the function finally.   SOrry for the waste of 
bandwidth and anyones time.  I'm not used to this syntax, so it will 
take me a bit to get on boad with it.

- J




view thread (6+ messages)  latest in thread

Message-ID: <4BEAEBFA.5090304@ttitech.net>
Permalink:  ../4BEAEBFA.5090304@ttitech.net/
Also on:    postgresql.org/message-id/4BEAEBFA.5090304@ttitech.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jgooding@ttitech.net
  Subject: Re: Greetings folks, dumb question maybe?
  In-Reply-To: <4BEAEBFA.5090304@ttitech.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox