Received: from maia.hub.org (maia-1.hub.org [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 965F06337DC for ; Thu, 13 May 2010 07:10:13 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 70866-09 for ; Thu, 13 May 2010 10:10:00 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from smtpcorp.com (smtpcorp.com [67.192.120.76]) by mail.postgresql.org (Postfix) with ESMTP id B897B632A6D for ; Thu, 13 May 2010 07:10:04 -0300 (ADT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=smtpcorp.com; s=main; h=Content-Transfer-Encoding:Content-Type:Mime-Version:References:Message-ID:Date:Subject:From:To; bh=BXP/gRYMYCuUBGJTkr+K9g3riqttmifS0iW+WTOtM5g=; b=PEEnYPbrpdRiU5RfFNG1OdWC54Nnc+UyZPQBHYrKp9eru1VraJyvnD8Oxinua5PUtHGZiQLTgC4HkXTNrMT40IN4+qOKnLysKgzW09RrayqZm5GGM23oZSyitvuXAQ5U; Received: from ip-118-90-137-155.xdsl.xnet.co.nz ([118.90.137.155] helo=gonzo) by smtpcorp.com with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.70) id 1OCVMg-0003se-8i; mid 144 for pgsql-sql@postgresql.org; Thu, 13 May 2010 10:09:38 +0000 Received: from news by gonzo with local (Exim 4.69) (envelope-from ) id 1OCVMV-0006SQ-Fp for pgsql-sql@postgresql.org; Thu, 13 May 2010 22:09:51 +1200 To: pgsql-sql@postgresql.org Path: not-for-mail From: Jasen Betts Newsgroups: gmane.comp.db.postgresql.sql Subject: Re: Greetings folks, dumb question maybe? Date: 13 May 2010 10:09:51 GMT Organization: Dis (not Dat) Organisation Lines: 37 Message-ID: References: <4BEAE646.9050902@ttitech.net> NNTP-Posting-Host: localhost Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: reversiblemaps.ath.cx 1273745391 24641 127.0.0.1 (13 May 2010 10:09:51 GMT) X-Face: ?)Aw4rXwN5u0~$nqKj`xPz>xHCwgi^q+^?Ri*+R(&uv2=E1Q0Zk(>h!~o2ID@6{uf8s; a +M[5[U[QT7xFN%^gR"=tuJw%TXXR'Fp~W; (T"1(739R%m0Yyyv*gkGoPA.$b,D.w:z+<'"=-lVT?6 {T?=R^:W5g|E2#EhjKCa+nt":4b}dU7GYB*HBxn&Td$@f%.kl^:7X8rQWd[NTc"P"u6nkisze/Q; 8 "9Z{peQF,w)7UjV$c|RO/mQW/NMgWfr5*$-Z%u46"/00mx-,\R'fLPe.)^ User-Agent: slrn/pre1.0.0-2 (Linux) X-Smtpcorp-Track: 2580292.1.63015540 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.5 tagged_above=-5 required=5 tests=BAYES_05=-0.5 X-Spam-Level: X-Archive-Number: 201005/60 X-Sequence-Number: 34108 On 2010-05-12, 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 don't need a function for that one. INSERT INTO unpart_tbl_test SELECT GENERATE_SERIES(0,9999999), 'teststring data', date '1995-01-01' +(floor(random()*36520)::int % 3652);