UPDATE matching records non-null conversion statement
HelloI'm trying to update a table that contains the columns partnerkey, timekey and the is_current. At present, the is_current field is set to "n" for all records. I want to update 'Y' where the timekey is newest and let others like 'n'.
I wrote the following update statement:
UPDATE of d_partner_all_time d
SET d.is_current =
(SELECT 'Y'
FROM (select partnerkey, max (timekey) d_partner_all_time of partnerkey group timekey) pl
WHERE d.partnerkey = pl.partnerkey
AND d.timekey = pl.timekey
)
Although it was updating all the last recordings of timekey for is_current value of 'Y', all other values that were previously ' was changed to null.
Can someone explain why this is and what I should change to prevent it?
Thank you
SQL> CREATE TABLE D_PARTNER_ALL_TIME
2 (
3 IS_CURRENT CHAR(1),
4 PARTNERKEY NUMBER,
5 TIMEKEY DATE
6 );
Table created.
SQL> INSERT INTO D_PARTNER_ALL_TIME VALUES ('N',1,TO_DATE('01/01/2009','DD/MM/YYYY'));
1 row created.
SQL> INSERT INTO D_PARTNER_ALL_TIME VALUES ('N',1,TO_DATE('02/01/2009','DD/MM/YYYY'));
1 row created.
SQL> INSERT INTO D_PARTNER_ALL_TIME VALUES ('N',1,TO_DATE('03/01/2009','DD/MM/YYYY'));
1 row created.
SQL> INSERT INTO D_PARTNER_ALL_TIME VALUES ('N',2,TO_DATE('01/01/2009','DD/MM/YYYY'));
1 row created.
SQL> INSERT INTO D_PARTNER_ALL_TIME VALUES ('N',2,TO_DATE('02/01/2009','DD/MM/YYYY'));
1 row created.
SQL> INSERT INTO D_PARTNER_ALL_TIME VALUES ('N',3,TO_DATE('03/01/2009','DD/MM/YYYY'));
1 row created.
SQL> commit;
Commit complete.
SQL> select * from D_PARTNER_ALL_TIME;
I PARTNERKEY TIMEKEY
- ---------- ---------
N 1 01-JAN-09
N 1 02-JAN-09
N 1 03-JAN-09
N 2 01-JAN-09
N 2 02-JAN-09
N 3 03-JAN-09
6 rows selected.
SQL> UPDATE
2 D_PARTNER_ALL_TIME D
3 SET IS_CURRENT = 'Y'
4 WHERE
5 TIMEKEY =
6 (SELECT MAX(TIMEKEY) FROM D_PARTNER_ALL_TIME A
7 WHERE
8 A.PARTNERKEY = D.PARTNERKEY
9 GROUP BY PARTNERKEY);
3 rows updated.
SQL> select * from D_PARTNER_ALL_TIME;
I PARTNERKEY TIMEKEY
- ---------- ---------
N 1 01-JAN-09
N 1 02-JAN-09
Y 1 03-JAN-09
N 2 01-JAN-09
Y 2 02-JAN-09
Y 3 03-JAN-09
6 rows selected.
Tags: Database
Similar Questions
-
Second update statement is not updated all records
Hello
I've written a procedure for updating a table "REFDUMP". The second statement to update the id of the procedure does not update all records. It updates only few records about 3500 off 15967.
Please can someone help me in this.
create or replace PROCEDURE refdump1
AS
cursor c1 is select r.REF_QUARTER, q.QUARTER, r.reference_date, refdump r.created r, q quarter
where nvl (r.reference_date, r.created) = q.REFERENCE_DATE;
cursor c2 is select r.REFnom_QUARTER, q.QUARTER, r.NOMINATION_DATE, refdump r.created r, q quarter
where nvl (r.nomination_date, r.created) = q.REFERENCE_DATE;
SLIDER C3 is SELECT * FROM country_region;
BEGIN
BEGIN
I'm looping c1
UPDATE refdump
SET ref_quarter = i.quarter
WHERE (reference_date, CREATED) = nvl nvl (i.reference_date, i.created);
COMMIT;
end loop;
EXCEPTION WHEN others then
DBMS_OUTPUT. Put_line (' error in the update of the quarter Ref');
END;
BEGIN
I'm looping c2
UPDATE refdump
SET refnom_quarter = i.quarter
WHERE the NVL (nomination_date, CREATED) = NVL (i.nomination_date, i.created);
COMMIT;
END LOOP;
EXCEPTION WHEN others THEN
DBMS_OUTPUT. Put_line ('error in the update of the quarter of nomination');
END;
BEGIN
UPDATE refdump SET oracle_ovi = 'other '.
WHERE oracle_ovi is null.
COMMIT;
END;
BEGIN
I'm looping c3
UPDATE refdump SET country = i.country_name2, region_cluster = i.region_cluster, region = i.region
Superior WHERE (countries) in (upper (i.country_name), upper (i.country_name2));
COMMIT;
END LOOP;
END;
BEGIN
UPDATE refdump SET country = 'other '.
WHEN the country is null;
COMMIT;
UPDATE refdump SET region_cluster = region, region = substr (region, 1, instr(region,'-') - 2).
Countries WHERE = "other";
END;
END;
Thank you
Vikas
-
Update the records in the table
I have an INCOME_LOT table. Now, I need to update records with the current max (lot_id) + rownum where lot_id = 0.
Note: There are multiple records with lot_id = 0.CREATE TABLE INCOME_LOT
(
LOT_ID NUMBER OF NON-NULL,
NUMBER OF DETAIL_ID
DATE OF EFFECTIVE_DATE,
DATE OF UPDATE_DATE
)
It is only a sample data of 4 records, while in fact, I have millions of records to be updated.Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773490, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773491, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773492, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:40 ',' DD/MM/YYYY HH24:MI:SS'));))
Insert into INCOME_LOT
(LOT_ID, DETAIL_ID, EFFECTIVE_DATE, UPDATE_DATE)
Values
(0, 5773493, TO_DATE (MAY 5, 2014 00:00:00 ',' DD/MM/YYYY HH24:MI:SS'), TO_DATE (MAY 6, 2014 00:22:41 ',' DD/MM/YYYY HH24:MI:SS'));))
COMMIT;Can someone help me to update all records with a single SQL query or maybe a PL/SQL block? I could design a cursor to update, but it would be tedious to use.
Do you want this:
UPDATE INCOME_LOT
Set lot_id = 262696 + ROWNUM
WHERE lot_id = 0;
-
History of backfilling with non-null values
Hi gurus,
in Oracle 11 g, which would be the best way to update a null with the next available non-null value?
For example: in the code below, I need to update the null in 20130201 record (key = 1) (key date) with a value of 100 available at the next available date IE 20130203.
Same key = 3 value will be updated with key = 4 value i.e. 200.
Thank you1,ABCD, 20130201, NULL 2,ABCD,20130203, 100 3,ABCD, 20130205, NULL 4, ABCD,20130207, 200
Swith t as ( select tbl.*, last_value(nvl2(c4,c1,null) ignore nulls) over(order by c1) prev_c1, last_value(c4 ignore nulls) over(order by c1) prev_c4, first_value(nvl2(c4,c1,null) ignore nulls) over(order by c1 rows between current row and unbounded following) next_c1, first_value(c4 ignore nulls) over(order by c1 rows between current row and unbounded following) next_c4 from tbl ) select c1, c2, c3, c4, case when c4 is not null then c4 when c1 - prev_c1 < next_c1 - c1 then prev_c4 else next_c4 end new_c4 from t / C1 C2 C3 C4 NEW_C4 ---------- ---- ---------- ---------- ---------- 1 ABCD 20130201 100 2 ABCD 20130203 100 100 3 ABCD 20130205 200 4 ABCD 20130207 200 200 SQL>
SY.
-
Update a record questioned using the parameter
Hi all
Have someone to help me to update an interviewed record of forms. It's like that when I use ID to search for the details, I want to update the record you are searching.
ArifHi Arif,
Here you're doing something complicated with you.1 UCID_PARAM and USERCREATION are 2 revenge in the same form
2 UCID_PARAM contain column UCID which is the primary key of the table usercreation. I used this block to passThe blockk UCID_PARAM here is the database block and why you must pass the value as a parameter because as you say it is primary key and foreign key in the block. Then why do you use search mechanism Assembly. I mean just create relationship between UCID_PARAM and USERCREATION block or if he joins then just use the method ENTER_QUERY and EXECUTE_QUERY. I understand because if you enter a value in the UCID_PARAM block and goes to the block of detail and do EXECUTE_QUERY by selecting a WHERE CLAUSE.
So, what's going to happen here. System takes into account that you are inserting record in UCID_PARAM. So, there is a field that is not null, then the error is coming.
Just use the default behavior of your forms. Or if you really want to use this method. Next, create a block of data non-base to pass the parameter. Do not use UCID_PARAM as the database block.
And one more thing, I noticed in your this clause
set_block_property ('USERCREATION', onetime_where, 'UCID =' |) ': UCID_PARAM. UCID');
It should be
set_block_property('USERCREATION',onetime_where,'UCID='||:FORM_FIELD_NAME);
I hope it is clear now.
-Clément
-
Find the matching record better
create table data(item_no int,item_size varchar2(10),color varchar2(10)); insert into data values (1,null,null); insert into data values (1,'small',null); insert into data values (1,null,'pink'); insert into data values (1,'large','red'); create table filters(item_no int,item_size varchar2(10),color varchar2(10),comments varchar2(100)); insert into filters values (1,null,null,'all sizes and colors'); insert into filters values (1,'small',null,'small comment'); insert into filters values (1,null,'pink','love pink'); insert into filters values (1,'large','red','large red comment'); select d.item_no,d.item_size,d.color,f.comments from data d,filters f where d.item_no=f.item_no(+) and d.item_size = f.item_size(+) and d.color = f.color(+);
How would I go about matching records in the data table with the best matching filter table record? Best way where the majority of the attributes match (item_no, item_size and color). I thought a simple outer join would, but it does not quite what I need.
What Miss me? Thank you
Hello
Thanks for posting the sample data.
Don't forget to post the exact results you want from these data.
One thing you can do is a Top - N query, like this:
WITH got_r_num AS
(
SELECT d.item_no, d.item_size, d.color, f.comments - or other
ROW_NUMBER () (PARTITION BY d.ROWID - OR primary key,
IN CASE of ORDERS WHEN d.item_no = f.item_no THEN 1 END ELSE 0
+ CASE WHEN d.item_size THEN 1 END ELSE f.item_size = 0
+ CASE WHEN d.color THEN 1 END ELSE f.color = 0
--+... If you have other attributes
/ / DESC
) AS r_num
DATA d
CROSS JOIN filters f
)
SELECT item_no, item_size, color, comments
OF got_r_num
WHERE r_num = 1
;
I would like a unique identifier to each table, and I had want to display in the results.
Remember, in SQL if x or y is NULL then
x = y
won't be TRUE. If you want NULL in two tables to match anything in the other table, then the same general approach will work, but it is messier.
What results do you want to tie (i.e. for a given line in d, 2 or several lines of f have exactly the same number of corresponding attributes)?
If this number is 0?
-
Problem of Collection NON-NULL
CREATE OR REPLACE TYPE VARCHAR2_COL_TYP AS TABLE OF VARCHAR2 (32767).
/
DECLARE
l_names VARCHAR2_COL_TYP not null: = new VARCHAR2_COL_TYP();
VARCHAR2 (10) L_Name not null default 'TEST '.
BEGIN
dbms_output.put_line (' name = ' | l_name);
l_names.extend;
l_names (l_names. (Last): = null;
dbms_output.put_line (' count = ' | l_names.count);
END;
/
I want to set not null in code as above, but it should work right?PapuS1 wrote:
It accepts null values. I set the variable non-null, taking null values...Declare type does not allow NULL values:
SQL> CREATE OR REPLACE 2 TYPE VARCHAR2_COL_TYP 3 AS TABLE OF VARCHAR2(32767) NOT NULL 4 / Type created. SQL> set serveroutput on SQL> DECLARE 2 l_names VARCHAR2_COL_TYP not null := new VARCHAR2_COL_TYP() ; 3 l_name varchar2(10) not null default 'TEST' ; 4 BEGIN 5 dbms_output.put_line ( 'name = ' || l_name ); 6 l_names.extend; 7 l_names(l_names.last) := 'PapuS1'; 8 dbms_output.put_line ( 'count = ' || l_names.count ); 9 END; 10 / name = TEST count = 1 PL/SQL procedure successfully completed. SQL> DECLARE 2 l_names VARCHAR2_COL_TYP not null := new VARCHAR2_COL_TYP() ; 3 l_name varchar2(10) not null default 'TEST' ; 4 BEGIN 5 dbms_output.put_line ( 'name = ' || l_name ); 6 l_names.extend; 7 l_names(l_names.last) := null; 8 dbms_output.put_line ( 'count = ' || l_names.count ); 9 END; 10 / l_names(l_names.last) := null; * ERROR at line 7: ORA-06550: line 7, column 26: PLS-00382: expression is of wrong type ORA-06550: line 7, column 1: PL/SQL: Statement ignored SQL>
SY.
-
TypeError: Error #2007: url parameter must be non-null - HELP!
Hey everybody. I (as well as everyone who posts a question here) am quite new to AS3. If I'm going crazy trying to figure out what is the cause of this error. I have a "jukebox" player that loads songs accordingly when the button is clicked. BUT it's my mistake:
TypeError: Error #2007: url parameter must be non-null.
to flash.media::Sound/_load()
to flash.media::Sound/load()
at lesson09_V2_S5_fla::MainTimeline/frame1()
And here is my code:
Import fl.events.SliderEvent;
create instances of the three sound related classes that will be used for this project
var snd:Sound;
var channel: SoundChannel;
var trans:SoundTransform;
create variables to store the values for the power of the song and its volume and pan settings.
var currSong:String;
var currVol:Number is. 5;
var currPan:Number = 0;
Table of all songs in the current playlist.
var songList:Array = new Array ("nothing on You.mp3","Grenade.mp3","Ride.mp3","Pretty Girl Rock.mp3","Tick Tock.mp3", "Dynamite.mp3");
don't need to see the volume and pan controls until a song
panSlide.visible = false;
volSlide.visible = false;
Headphones for the buttons of the song on stage
song1.addEventListener (MouseEvent.CLICK, chooseSong);
Song2.addEventListener (MouseEvent.CLICK, chooseSong);
song3.addEventListener (MouseEvent.CLICK, chooseSong);
song4.addEventListener (MouseEvent.CLICK, chooseSong);
song5.addEventListener (MouseEvent.CLICK, chooseSong);
song6.addEventListener (MouseEvent.CLICK, chooseSong);
headphones for the volume sliders and pan
panSlide.addEventListener (SliderEvent.CHANGE, panChange);
volSlide.addEventListener (SliderEvent.CHANGE, volumeChange);
sets the text of all the buttons of the song field to display the names of the songs in the songList array
for (var i = 0; i < songList.length; i ++) {}
var str:String = [i] songList have thong;
Str = str.replace(".mp3","");
var clip = this ["song" + (i + 1)] .title;
clip. Text = str;
}
statement to define a song based on the song button was clicked switch.
function chooseSong(e:MouseEvent):void {}
Switch (e.currentTarget.name) {}
case "song1:
currSong = '... /MP3s/ ' + songList [0] as String;
break;
case "song2":
currSong = '... /MP3s/ ' + songList [1] as String;
break;
case "song3":
currSong = '... /MP3s/ ' + songList [2] as String;
break;
case "song4":
currSong = '... /MP3s/ ' + songList [3] as String;
break;
case "song5":
currSong = '... /MP3s/ ' + songList [4] as String;
break;
case "song6":
currSong = '... /MP3s/ ' + songList [5] as String;
break;
}
}
If (snd! = null) {}
Channel.Stop ();
}
SND = new Sound();
SND. Load (new URLRequest (currSong));
snd.addEventListener (IOErrorEvent.IO_ERROR, onError);
function onError(e:IOErrorEvent):void {}
Do nothing
}
Channel = new SoundChannel;
TRANS = new SoundTransform (currVol, currPan);
Channel = snd.play ();
channel.soundTransform = trans;
panSlide.visible = true;
volSlide.visible = true;
currVolume and pan values are used here for display in the text beside the sliders fields
volLabel.text = "Current Volume" + int(currVol * 100);
panLabel.text = "Current Pan" + int(currPan * 100);
listen to the arrival of ID3 tags
snd.addEventListener (Event.ID3, id3Handler);
triggered when the id3 tags are available
sets the info text field to display the information of the current song from id3 tags.
function id3Handler(event:Event):void {}
var id3:ID3Info = snd.id3;
If (id3.songName! = null) {}
songTitle.text = id3.songName + "\n";
info. Text = "" Artist: \n"+id3.artist+"\n \n ";"
info.appendText ("Album: \n" + id3.album);
info.appendText ("\n\n" + "available at: \n" + "passionrecords \n.com");
}
}
var format: TextFormat = new TextFormat();
format.font = "Arial Black";
format. Color = 0xFFFF00;
format. Size = 14;
format.url = " " http://www.passionrecords.com/ ";
info.defaultTextFormat = format;
uses the value of volume slider to control the volume
function volumeChange(e:SliderEvent):void {}
currVol = e.target.value;
volLabel.text = "current Volume:"+ int(currVol*100); "
TRANS.volume = currVol;
channel.soundTransform = trans;
}
uses pan value of the slider to control pan
function panChange(e:SliderEvent):void {}
currPan = e.target.value;
panLabel.text = "Current Pan" + int(currPan*100);
TRANS. Pan = e.target.value;
channel.soundTransform = trans;
}
Any help would be greatly appreciated! Thank you!
This looks to another case of code not be placed where it should be.
If this code is not in a function, then it executes immediately when the program starts. At this point, snd is not defined, no said. You do not create the instance until the line... snd = new Sound(); that, I believe, you have now moved inside a function.
You might have to go through all the code to see what parts you always floating around this need of houses inside functions.
-
Update the query using nulls update box
I need to update a column according to the conditions that I've used below, the update query, I used is updated as well to null values. How can I stop this and keep the old values when no match was found for the case.
create table sample (name varchar2(10),eno number(10),salary number(10)); insert into sample (name,eno,salary) values ('emp1',1,100); insert into sample (name,eno,salary) values ('emp2',2,200); insert into sample (name,eno,salary) values ('emp3',3,300); select * from sample; update sample set salary = case when salary = 100 then 10000 else case when salary = 150 then 15000 else case when salary = 200 then 20000 end end end where name is not null; Actual o/p: emp1 1 10000 emp2 2 20000 emp3 3 Required o/p: emp1 1 10000 emp2 2 20000 emp3 3 300
Hello
The updated control WHERE clause lines.
If you do not have a WHERE clause, then updates all rows in the table.update sample set salary = case when salary = 100 then 10000 when salary = 150 then 15000 when salary = 200 then 20000 end where salary IN (100, 150, 200) ;
Note that you do not need to nest BOX icies expressions (or almost anywhere else). If the 'salary = 100' condition is true, then its correspondent WHEN the value is returned, and the remaining terms will not be evaluated. If the first condition is not true, then only will be the "salary = 150" condition to be evaluated. (The terms are mutually exclusive in this example anyway, so it does not matter.)
Published by: Frank Kulash, June 5, 2012 13:09
-
Child parameter must be non-null. Error #2007
Hello world!
I'm about to finish my game (A matching game cards) and I encountered a problem.
The piece of code tha giving me the problem is:
compare two cards
If (firstCard.cardface == secondCard.cardface) {}
var beginTime:int = getTimer();
addEventListener (Event.ENTER_FRAME, removeMatch);
function removeMatch(event:Event) {}
milliseconds spent
var timePassed:int = getTimer () - beginTime;
calculate seconds
var seconds: int = Math.floor (timePassed/1000);
If (seconds == 1) {}
remove a match
removeChild (firstCard);
removeChild (secondCard);
Reset selection
firstCard = null;
secondCard = null;
}
}
Add points
gameScore += pointsForMatch;
showGameScore();
playSound (theMatchSound);
cardsLeft-= 2; 2 cards lessTypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/removeChild()
at Function/EasyDifficulty/clickCard/removeMatch()[C:\Users\Adi\Desktop\Playbook\Playbook Match Game\Project\EasyDifficulty.as:132]Above is the output error I get when clicking on two cards that are the same.
What is the problem here... I can't fix perhaps because I worked for hours.
Thanks in advance.
The problem is probably due to you using an enterframe event continually calling this function. You must remove this enterframe listener as soon as it has achieved its objectives, or else he will always try to remove objects that they have already been removed.
You shouldn't bury this function inside the conditional.
If the goal of all that is simply adds a slight delay before removing objects, you should consider using setTimeout or Timer class instead of using an enterframe scenario.
-
Update multiple records at once
First, thank you very much the people who have helped me out several times now. I put things together and came across another issue of 'beauty' begin as follows. In the previous topics, I had a way to get to an array of automated classification based on the inputs of a fixtures table and some simple calculations. Now, which has been accomplished which resulted in me having to update all the teams by simply clicking a button.
As you can see in the code below, using a table with every row a form, at the end of the line, there is a button called 'OK' I have to push to update the record according to. A repeat region for all teams in this query shows the ranking of 'new', but is not yet inserted in the League table. Is it possible to have this repeat region without having to push 18 or 20 times a button update? At the end of the table, one (1) button update all records? The primary key is composed like this ' 0000 - u00a "(4 numéros un tiret puis un «u» 1 ou 2 numéros et 1 ou 2 lettres à nouveau)."
<?php require_once('Connections/connection.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "klassement")) {
$updateSQL = sprintf("UPDATE klassement SET wedstrijden=%s, overwinning=%s, verlies=%s, gelijkspel=%s, goalsvoor=%s, goalstegen=%s, goalverschil=%s, punten=%s WHERE ploegid=%s",
GetSQLValueString($_POST['wedstrijden'], "int"),
GetSQLValueString($_POST['overwinning'], "int"),
GetSQLValueString($_POST['verlies'], "int"),
GetSQLValueString($_POST['gelijkspel'], "int"),
GetSQLValueString($_POST['goalsvoor'], "int"),
GetSQLValueString($_POST['goalstegen'], "int"),
GetSQLValueString($_POST['goalverschil'], "int"),
GetSQLValueString($_POST['punten'], "int"),
GetSQLValueString($_POST['ploegid'], "text"));
mysql_select_db($database_koscw, $koscw);
$Result1 = mysql_query($updateSQL, $koscw) or die(mysql_error());
$updateGoTo = "klassement-ploegen.php?reeksid=" . $row_klassement['reeksid'] . "";
if (isset($_SERVER['QUERY_STRING'])) {
$updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?";
$updateGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $updateGoTo));
}
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
}
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$reeks_klassement = "-1";
if (isset($_GET['reeksid'])) {
$reeks_klassement = $_GET['reeksid'];
}
mysql_select_db($database_koscw, $koscw);
$query_klassement = sprintf("select * from klassement where reeksid = %s order by status asc, punten desc, overwinning desc, goalverschil desc", GetSQLValueString($reeks_klassement, "text"));
$klassement = mysql_query($query_klassement, $koscw) or die(mysql_error());
$row_klassement = mysql_fetch_assoc($klassement);
$totalRows_klassement = mysql_num_rows($klassement);
$id_reeks = "-1";
if (isset($_GET['reeksid'])) {
$id_reeks = $_GET['reeksid'];
}
mysql_select_db($database_koscw, $koscw);
$query_reeks = sprintf("select reeksnaam from reeksen where reeksid = %s", GetSQLValueString($id_reeks, "text"));
$reeks = mysql_query($query_reeks, $koscw) or die(mysql_error());
$row_reeks = mysql_fetch_assoc($reeks);
$totalRows_reeks = mysql_num_rows($reeks);
mysql_select_db($database_koscw, $koscw);
$query_seizoen = "select * from seizoen";
$seizoen = mysql_query($query_seizoen, $koscw) or die(mysql_error());
$row_seizoen = mysql_fetch_assoc($seizoen);
$totalRows_seizoen = mysql_num_rows($seizoen);
$huidig=$row_seizoen['huidigseizoen'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" media="all" href="../_styles/koscw-admin.css" />
<title>Klassement <?php echo $row_reeks['reeksnaam']; ?> | Beheerpaneel | 1349</title>
</head>
<body>
<div id="container">
<h1 class="overzichth1">Klassement <?php echo $row_reeks['reeksnaam']; ?></h1>
<?php if ($totalRows_klassement > 0) { // Show if recordset not empty ?>
<table cellpadding="5" cellspacing="0" border="0" id="klassement">
<tr>
<td class="klassementsmall bgccc bold"></td>
<td class="klassementteam bgccc bold">Ploegnaam</td>
<td class="klassementsmall bgccc bold">+</td>
<td class="klassementsmall bgccc bold">-</td>
<td class="klassementsmall bgccc bold">=</td>
<td class="klassementsmall bgccc bold">#</td>
<td class="klassementsmall bgccc bold"><img src="../_img/goalsmade.png" alt="Goals +" /></td>
<td class="klassementsmall bgccc bold"><img src="../_img/goalsagainst.png" alt="Goals -" /></td>
<td class="klassementsmall bgccc bold"><img src="../_img/goalsdifference.png" alt="Goals ≈" /></td>
<td class="klassementsmall bgccc bold">PTN</td>
<td class="klassementsmall bgccc"> </td>
</tr>
<?php
$i=0;
do {
$i++;
if($i % 2) { //this means if there is a remainder
echo "<tr class=\"calendareven\">";
} else { //if there isn't a remainder we will do the else
echo "<tr class=\"calendarodd\">";
}
?>
<td>
<?php
$rank += 1;
echo $rank;
?> </td>
<td class="klassementteam">
<?php
$thuisploeg=$row_klassement ['ploegid'];
$sql_select_thuisploeg="select ploegnaam from ploegen where ploegid = ('$thuisploeg')";
$resultset_thuisploeg=mysql_query($sql_select_thuisploeg);
while ($data_thuisploeg=mysql_fetch_array($resultset_thuisploeg))
{echo $data_thuisploeg['ploegnaam'] . " ";}?></td>
<form action="<?php echo $editFormAction; ?>" method="POST" name="klassement">
<input type="hidden" name="ploegid" value="<?php echo $row_klassement ['ploegid']; ?>" />
<td>
<?php
$tw=$row_klassement['ploegid'];
$sql_select_tw="SELECT COUNT( * ) AS twin FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND thuisploegid = '$tw' AND thuisploeggoals > bezoekersgoals";
$resultset_tw=mysql_query($sql_select_tw);
$data_tw=mysql_fetch_array($resultset_tw);
$data_tw['twin'];
$uitwin=$row_klassement['ploegid'];
$sql_select_uitwin="SELECT COUNT( * ) AS awin FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND bezoekersid = '$uitwin' AND thuisploeggoals < bezoekersgoals";
$resultset_uitwin=mysql_query($sql_select_uitwin);
$data_uitwin=mysql_fetch_array($resultset_uitwin);
$data_uitwin['awin'];
$win=($data_tw['twin'])+($data_uitwin['awin']);
?>
<input type="text" name="overwinning" value="<?php echo $win; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php
$tv=$row_klassement['ploegid'];
$sql_select_tv="SELECT COUNT( * ) AS tver FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND thuisploegid = '$tv' AND thuisploeggoals < bezoekersgoals";
$resultset_tv=mysql_query($sql_select_tv);
$data_tv=mysql_fetch_array($resultset_tv);
$data_tv['tver'];
$uitverlies=$row_klassement['ploegid'];
$sql_select_uitverlies="SELECT COUNT( * ) AS aver FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND bezoekersid = '$uitverlies' AND thuisploeggoals > bezoekersgoals";
$resultset_uitverlies=mysql_query($sql_select_uitverlies);
$data_uitverlies=mysql_fetch_array($resultset_uitverlies);
$data_uitverlies['aver'];
$ver=($data_tv['tver'])+($data_uitverlies['aver']);
?>
<input type="text" name="verlies" value="<?php echo $ver; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php
$thuisdraw=$row_klassement['ploegid'];
$sql_select_thuisdraw="SELECT COUNT( * ) AS tdraw FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND thuisploegid = '$thuisdraw' AND thuisploeggoals = bezoekersgoals";
$resultset_thuisdraw=mysql_query($sql_select_thuisdraw);
$data_thuisdraw=mysql_fetch_array($resultset_thuisdraw);
$data_thuisdraw['tdraw'];
$awaydraw=$row_klassement['ploegid'];
$sql_select_awaydraw="SELECT COUNT( * ) AS adraw FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND bezoekersid = '$awaydraw' AND thuisploeggoals = bezoekersgoals";
$resultset_awaydraw=mysql_query($sql_select_awaydraw);
$data_awaydraw=mysql_fetch_array($resultset_awaydraw);
$data_awaydraw['adraw'];
$draw=($data_thuisdraw['tdraw'])+($data_awaydraw['adraw']);
?>
<input type="text" name="gelijkspel" value="<?php echo $draw ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php $wedstrijden=$win+$ver+$draw; ?>
<input type="text" name="wedstrijden" value="<?php echo $wedstrijden; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php
$tgv=$row_klassement ['ploegid'];
$sql_select_tgv="SELECT SUM( thuisploeggoals ) AS tgv1 FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND thuisploegid = '$tgv'";
$resultset_tgv=mysql_query($sql_select_tgv);
$data_tgv=mysql_fetch_array($resultset_tgv);
$data_tgv['tgv1'];
$ugv=$row_klassement ['ploegid'];
$sql_select_ugv="SELECT SUM( bezoekersgoals ) AS ugv1 FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND bezoekersid = '$ugv'";
$resultset_ugv=mysql_query($sql_select_ugv);
$data_ugv=mysql_fetch_array($resultset_ugv);
$data_ugv['ugv1'];
$gv=($data_tgv['tgv1'])+($data_ugv['ugv1']);
?>
<input type="text" name="goalsvoor" value="<?php echo $gv; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php
$tgt=$row_klassement ['ploegid'];
$sql_select_tgt="SELECT SUM( thuisploeggoals ) AS tgt1 FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND bezoekersid = '$tgv'";
$resultset_tgt=mysql_query($sql_select_tgt);
$data_tgt=mysql_fetch_array($resultset_tgt);
$data_tgt['tgt1'];
$ugt=$row_klassement ['ploegid'];
$sql_select_ugt="SELECT SUM( bezoekersgoals ) AS ugt1 FROM kalender WHERE seizoen = '$huidig' AND speeldag !=0 AND thuisploegid = '$ugv'";
$resultset_ugt=mysql_query($sql_select_ugt);
$data_ugt=mysql_fetch_array($resultset_ugt);
$data_ugt['ugt1'];
$gt=($data_tgt['tgt1'])+($data_ugt['ugt1']);
?>
<input type="text" name="goalstegen" value="<?php echo $gt; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php $goals=$gv-$gt; ?>
<input type="text" name="goalverschil" value="<?php echo $goals; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<?php $punten=($win*3)+($draw*1); ?>
<input type="text" name="punten" value="<?php echo $punten; ?>" class="inputscore" readonly="readonly" />
</td>
<td>
<input type="submit" value="OK" />
</td>
<input type="hidden" name="MM_update" value="klassement" />
</form>
</tr>
<?php } while ($row_klassement = mysql_fetch_assoc($klassement)); ?>
</table>
<?php } // Show if recordset not empty ?>
</div>
</body>
</html>
<?php
mysql_free_result($klassement);
mysql_free_result($reeks);
mysql_free_result($seizoen);
?>Each record is separated, as well as a record can be updated at once, unless you want that all records have the same value.
To update multiple records in a single operation, you must send the form tabular data. You do this by adding an empty pair of brackets at the end of the name attribute of each entry on the form like this:
This translates by $_POST ['ploegid'] which contains a table of all IDS: $_POST ['ploegid'] [0], $_POST ['ploegid'] [1], $_POST ['ploegid'] [2] and so on. All the attributes of the repeat region name need to have added hooks. The following hidden field should be outside of the repeat region and may not have the brackets:
You can then use a loop for updating the values like this:
for ($j = 0, $len = count($_POST['ploegid']); $j < $len; $j++) { $updateSQL = sprintf("UPDATE klassement SET wedstrijden=%s, overwinning=%s, verlies=%s, gelijkspel=%s, goalsvoor=%s, goalstegen=%s, goalverschil=%s, punten=%s WHERE ploegid=%s", GetSQLValueString($_POST['wedstrijden'][$j], "int"), GetSQLValueString($_POST['overwinning'][$j], "int"), GetSQLValueString($_POST['verlies'][$j], "int"), GetSQLValueString($_POST['gelijkspel'][$j], "int"), GetSQLValueString($_POST['goalsvoor'][$j], "int"), GetSQLValueString($_POST['goalstegen'][$j], "int"), GetSQLValueString($_POST['goalverschil'][$j], "int"), GetSQLValueString($_POST['punten'][$j], "int"), GetSQLValueString($_POST['ploegid'][$j], "text")); mysql_select_db($database_koscw, $koscw); $Result1 = mysql_query($updateSQL, $koscw) or die(mysql_error());}
-
Adobe Encore CS3 recorder: none found?
I use Encore CS3. I burned DVD with her many times before, but today he told me in the 'Build-> Destination' box: "recorder: None Found." I click on update, but nothing happens. I know I have two working DVD burners connected to the computer, but still refuses to recognize. I tried to reinstall, but I still have the same problem. I also tried to run the program as administrator. It can be the cause of this problem?
I was having the same problem and just think about it. If you are on a mac:
Go to your system preferences
Go to the energy saver
Uncheck the box for the hard drives was able to sleep when Possible
This fixed the problem for me.
-
Add/assign value to non-null text values
I have a database that stores the (item) values for each day of the month - for example if a person is OFF or VAC (holiday). So, it should look like this:
Name LUN Mar Wed John Smith OFF OFF Charlie Murphy TRN Ricky James VAC VAC VAC TOTAL 2 3 1 So, I need the line 'TOTAL' to add the columns whose value is non-null. I thought maybe I could somehow assign a value of 1 for each of the columns, and then perform a sum.
If anyone can help in a solution of Coldfusion or SQL Server 2005? Thank you.
I thought maybe I could somehow assign a value of 1 for each of the columns, and then perform a sum.
Yes, you can use a CASE statement to return 1 or 0. Then pack them in a SUM (.).
SELECT SUM (CASE WHERE ColumnName IS NULL THEN 0 ELSE 1 END) AS ofcases...
-
Update/Insert Record Wizard syntax error
Try using the Wizard update of records, I get the following error when you click the update button:
You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near 'Condition 'Very good' =, system = "related" ', Desc "=" Art and decoration July thru' at line 1
I get to the page for editing a page that displays all dbase, passing the index parameter to the update page when I click on a bound column index number. The update page appears full on the appropriate folder. It won't just accept the update button is clicked without generating the error, even if I make any changes at all to the record.
An almost identical error pops up just trying to open the page to insert a form created with the wizard insert a Record for this same table/dbase.
You have an error in your SQL syntax; consult the manual for your version of the MySQL server for the right syntax to use near 'State system 'Desc', price, weight, ThumbPic, library LargePic' at line 1
The mysql database update etc directly through php admin, but not through these pages of the wizard due to the error message. I have not modified any coding, just followed the instructions. I've done several of these pages Update and Insert before for other dbases and tables, so I have an idea of what I'm doing, but never confronted to this. This can be a problem with the syntax of one of my titles of rank or something to do with the structure of the dbase? Any ideas would be greatly appreciated? Thank youI got it. Condition, one of my domain names and the first field mentioned in the error message is a reserved word in MySQL 5... Shortcut to the top name, cleaned the server behaviors for the new name of field and Update and Insert work very well.
-
Hello!
IAM using the following update statement.,.
Now, I want a set folder to update only once despite the way that many times I have run this code...update bal_assign c set existing_balance=existing_balance+1 where exists(select distinct a.employeeid,a.leavetype,a.status,a.status2,a.todate,b.date_of_hol from empaply a,closed_hol b where a.todate=b.date_of_hol and a.status='Approved' and a.status2='Approved' and c.leavetype=a.leavetype and c.employeeid=a.employeeid)
Is there a way to do this?
Pls help!
Thanks and greetings
user 10685325
Edited by: user10685325 may 4, 2009 04:34You can optionally add a column "State" which actually is a flag that indicates that the record has been updated. Then change your update statement to update only records where the flag is false.
HTH!
Maybe you are looking for
-
HDR-AS50 is backward compatible with RM-LVR2?
Does anyone know if Live View remote control 2 last year works with the new HDR-AS50?
-
precision of typical Voltimeter DAQ USB-6009
Features: I wonder what are the features of the USB DAQ 6009 regarding:-Stability and accuracy, + /-(reading ppm + ppm of range) and the resolution of analog input Thank you
-
To install XP in AHCI mode do not work, after work in the bios to "ide mode". Once installed, place all the drivers. I have 2 problems: 1. the wireless is active, but not find any network 2. If I go back to AHCI mode in the bios, I've got blu screen,
-
Service OR update: communication problems
Hello on different computers running different versions of Windows (XP, XP64, 7) and for the different versions of the Service OR update (from 2.0.1 to the last 2.2.1.7), I get the same error message (not just today, so I tend to exclude the possibil
-
How can I restore arccon.dll?
I uninstalled my computer on accident arccon.dll how I put back it?