473,786 Members | 2,304 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

update table a.fkid from table b.pkid

I have tried to solve this on my own for a long time now, so i really need
some help here...

I use Oracle 10.1 and SQL *plus 10.1.

How do i update table a.fkid from table b.pkid with the following "rule".
The table b.pkid's should be evenly distributed over table a as fkid's.

Does anyone have a tip on how to solve this?

Thank you.
Jul 19 '05 #1
2 3872

"amwi" <am**@yahoo.com > wrote in message
news:6u******** ************@ne wsc.telia.net.. .
I have tried to solve this on my own for a long time now, so i really need
some help here...

I use Oracle 10.1 and SQL *plus 10.1.

How do i update table a.fkid from table b.pkid with the following "rule".
The table b.pkid's should be evenly distributed over table a as fkid's.

Does anyone have a tip on how to solve this?

Thank you.

An example:

Table b contains 10 rows with specific id's (primary keys).
Table a contains 10000 rows and contains a fk to table b.id.
The problem is to update the 10000 fk's in table a so that the 10 pk's in
table a is spread evenly into 10000 items in table a.

That is:
The first id in table b is written to 1000 rows in table a.
The second id in table b is written to the next 1000 rows in table a.
....
The twentieth id in table b is written to the last 1000 rows in table a.

This is the basic idea and it should be real easy to solve in SQL,
somehow...

Thank you
Jul 19 '05 #2
"amwi" <am**@yahoo.com > wrote in message news:<FB******* ***********@new sb.telia.net>.. .
"amwi" <am**@yahoo.com > wrote in message
news:6u******** ************@ne wsc.telia.net.. .
I have tried to solve this on my own for a long time now, so i really need
some help here...

I use Oracle 10.1 and SQL *plus 10.1.

How do i update table a.fkid from table b.pkid with the following "rule".
The table b.pkid's should be evenly distributed over table a as fkid's.

Does anyone have a tip on how to solve this?

Thank you.

An example:

Table b contains 10 rows with specific id's (primary keys).
Table a contains 10000 rows and contains a fk to table b.id.
The problem is to update the 10000 fk's in table a so that the 10 pk's in
table a is spread evenly into 10000 items in table a.

That is:
The first id in table b is written to 1000 rows in table a.
The second id in table b is written to the next 1000 rows in table a.
...
The twentieth id in table b is written to the last 1000 rows in table a.

This is the basic idea and it should be real easy to solve in SQL,
somehow...

Thank you


You should ask your professor for help. If you want help with homework
in this group, you should:
try to write the SQL on your own.
If you cannot do it, post what you tried and we will lend some
guidance.
(we will not do your homework for you.)

Here's a hint via a question: Is there a way, using the current
columns and data in table a to groups the values in sets of 1000?

IOW can a query like

SELECT count(*),<some column list>
FROM table a
GROUP BY <some column list> ;

result in 10 rows with counts of about 1000 for each?

HTH,
ed
Jul 19 '05 #3

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

Similar topics

7
248484
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a particular surname in a particular town. I can select the records fine with this syntax (testing in Oracle SQL* Plus) SELECT NAMEINFO.LASTNAME, NAMEINFO.FIRSTNAME, NAMEINFO.MIDDLENAME, NAMEINFO.GENDER, ADDRESSINFO.REGION FROM NAMEINFO, ADDRESSINFO...
5
4014
by: red85 | last post by:
hello i have mysql 4.1 with win2000 SP3, i know that it is only an alpha and i don't know if someone else has already posted this problem: when i execute this sql UPDATE tableX SET fieldX=valueX WHERE id IN (SELECT tX.id FROM tableX AS tX WHERE tX.fieldY=valueY AND filedZ=valueZ);
8
89320
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON tblMyTable.UniqueID = tblMyTableTEMP.UniqueID SET tblMyTable.myField = tblMyTableTEMP.myField, tblMyTable.myField2 = tblMyTableTEMP.myField2,
8
2722
by: BigJohnson | last post by:
We're using ASPUpload as a tool to upload files to our server and save the details to SQLServer. However, I have an application where I need to return the pkID of the just saved file. I'm assuming that I could use the @@Identity command but cannot get this to function. Has anyone used this command with ASPUpload with an success, or any other methods that could be used? Thanks.
1
1826
by: BabuMan | last post by:
Hi, I have a FormView control on a page which is bound to a SQLDataSource table. Everything works fine except for the "Update". I get an InvalidCastException. The problem only seems to surface when I have a 'datetime' column in the table. I tested this with a very simple sample table. As long as there is no datetime column either in the table or on the form, all are peachy. Here is the code, in case somebody can figure it out. I...
3
1840
by: Ryan | last post by:
I have a form that contains a field that is a Foreign Key (UserID) I want this control to have a "label" appearance but I want it to act as a lookup table (SelectedValue = FKID, SelectedText = "Joe Blow"). Using a ComboBox control is the only way I've found to do this (and its actually really easy) but I haven't found a way to disable everything and make that combo box just look like a standard label. The label control doesn't seem to...
4
7254
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which - "Modified" of type DateTime - is hidden since it should not be edited by a user. The system handles the update for this column. So, I have hidden (Visible=false) this column on the grid. In order to access the value in this field, I have created a...
2
465
by: amwi | last post by:
I have tried to solve this on my own for a long time now, so i really need some help here... I use Oracle 10.1 and SQL *plus 10.1. How do i update table a.fkid from table b.pkid with the following "rule". The table b.pkid's should be evenly distributed over table a as fkid's. Does anyone have a tip on how to solve this?
3
3968
by: Michel Esber | last post by:
Hi all, DB2 V8 LUW FP 15 There is a table T (ID varchar (24), ABC timestamp). ID is PK. Our application needs to frequently update T with a new value for ABC. update T set ABC=? where ID = ?
0
9491
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10104
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
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7510
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
6744
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
5397
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...
0
5532
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4063
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3668
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.