473,770 Members | 4,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Remembering values in pl/pgsql

Running 7.4.2, I have a pl/pgsql function with a WHILE LOOP that inserts
records a set number of times. Each time, the function generates a
random number and INSERT INTO a table, if that number has been used
already, I need to enter all fields leaving the incremented number NULL.
How can I keep track of the numbers already used, does it support arrays
and them? I tried a SELECT INTO (shown below), but I guess the INSERT
does not commit until the LOOP is finished. Is there a way to commit the
record before the next item in the LOOP?

WHILE sampleno <= units_to_test LOOP
randno := random();
randresult := bldginfo.units_ count*randno;
randround := CEIL(randresult );
SELECT INTO checkit COUNT(public.tb lhud74b.similar _group_id) AS
unit_count FROM public.tblhud74 b WHERE
(public.tblhud7 4b.similar_grou p_id = bldginfo.simila r_group_id) AND
(public.tblhud7 4b.rounded = randround);
IF NOT FOUND THEN
INSERT INTO tblhud74b VALUES (bldginfo.simil ar_group_id,
bldginfo.units_ count, randno, randresult, randround, sampleno);
sampleno := sampleno + 1;
nounits := nounits + 1;
ELSE
INSERT INTO tblhud74b VALUES (bldginfo.simil ar_group_id,
bldginfo.units_ count, randno, randresult, randround);
END IF;
END LOOP;

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

Nov 23 '05 #1
0 1120

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1791
by: Hema Sekhar | last post by:
Hi I am Hemasekhar K.P I am trying to replicae pgsql on REDHATLinux 8, but the site http://gborg.postgresql.org/genpage?replication_72install. is giving instructions on REDHATLinux 7, is there any site which gives instructions on how to replicate on REDHATLinux 8, Actually in postgresql.conf which is under /usr/local/pgsql/data/postgresql.conf, I added the following lines
11
2350
by: Daniel E. Fisher | last post by:
> I can't get a rest for a min guys. > > I go away for the weekend and my server is getting this error. > > Fatal error: Call to undefined function: pg_connect() in > /var/www/html/crohns/phpBB2/db/postgres7.php on line 79 Your PHP doesn't have support for PostgreSQL. Look at phpinfo();
3
6593
by: Keith Bottner | last post by:
I have been looking for an interactive PL/pgSQL for Postgres with no luck. Does anybody know of one open source or commercial? If not then I would like to know if there is currently a debugging API that can be attached to for writing such a debugger? And finally... If there isn't any debugging API how many people are interested in either the debugging API or the final product which would be an interactive
4
1837
by: Postgresql | last post by:
Hello, I am unable to get on many of the postgresql mailing lists. I usually get this message back with no attachment and no email comes afterwards with a confirmation. I've tried this over and over on multiple lists. After a while I was able to get on pgsql-admin...but it took a few tries. It's been a couple days now, so I'm assuming majordomo has had time to process my request.
0
282
by: Robert Fitzpatrick | last post by:
Running 7.4.2, I have a pl/pgsql function with a WHILE LOOP that inserts records a set number of times. Each time, the function generates a random number and INSERT INTO a table, if that number has been used already, I need to enter all fields leaving the incremented number NULL. How can I keep track of the numbers already used, does it support arrays and them? I tried a SELECT INTO (shown below), but I guess the INSERT does not commit...
11
3620
by: Ed L. | last post by:
Has anyone successfully built 7.3.4, 7.4.3, or 8.0.0beta1 on IA64 with HP-UX 11i v2 (11.23)? I'm not having any success, running into 'make' failures. Googling old posts suggests this might be due to missing test-and-set code for ia64? I saw a disputed/repudiated ViSolve patch, but nothing else. Is this still broken? Here's my attempt on 8.0.0beta1: $uname -a
7
2320
by: snpe | last post by:
Is it down ? regards ---------------------------(end of broadcast)--------------------------- TIP 9: the planner will ignore your desire to choose an index scan if your joining column's datatypes do not match
1
7214
by: John French | last post by:
I just installed postgresql 7.4.5 and pgadmin3 1.0.2 on FreeBSD and noticed that pgadmin allows the pgsql user to log in while ignoring the password. You can enter a wrong password or no password and still get into postgresql. I started the postmaster as a FreeBSD user named pgsql by running postmaster -i -D /usr/local/pgsql/data I changed postgresql's pgsql user account to have a new password via pgadmin3 too. But I can still log in to...
1
2484
by: sysxperts | last post by:
Hello, Having an issue that is specific to PHP compiled with PGSQL support with versions noted in subject line. I understand that there are many variables to consider here but believe I have narrowed down the Apache Client Cert failures to my PHP/PGSQL build. 1. Apache PHP without PGSQL works as expected using client certificates 2. Apache PHP with PGSQL works fine with standard SSL connections 3 Apache PHP with PGSQL fails with...
1
2523
by: ghjk | last post by:
I'm having php page with validation. This is the code. <script language="javascript" src="../javascripts/validate.js"></script> <script type="text/javascript"> function valForm(){ if(!valid_required(document.add.FullName.value)) { add.FullName.style.background = 'Yellow'; alert("First name is required field.")
0
10237
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8905
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5326
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.