JOIN and UPDATE
I have two tables
Flight (FlightID, FlightDate, Origin, Destination, MaxCapacity, AvailableSeats)
FlightBooking(BookingID, CustomerID, FlightID, NumSeats, Status, BookingTime)
I'd like to somehow update AvailableSeats, given a change in Status.
When a FlightBooking is cancelled, the status is changed to 'C', then it is required to substract NumSeats from AvailableSeats (in flight), to simulate the cancellation and free up the seats associated with the cancelled booking.
A constraint is that only the BookingID is given (The rest of the data is already there, my java program just asks for the BookingID that needs to be cancelled). So somehow I need to join the two tables (via the only common column FlightID), and then update available seats.
Any ideas as to how this update and join could be combined would be much appreciated.
hi
I would sugget you to use database trigger yours front end just have to handle issue simple DML rest is to handle yours db trigger.
SQL>desc flight
Name Null? Type
FLIGHTID NUMBER
FLIGHTDATE DATE
ORIGIN VARCHAR2(10)
DESTINATION VARCHAR2(10)
MAXCAPACITY NUMBER
AVAILABLESEATS NUMBER
SQL>desc flightbooking
Name Null? Type
BOOKINGID NUMBER
CUSTOMERID VARCHAR2(10)
FLIGHTID NUMBER
NUMSEATS NUMBER
STATUS VARCHAR2(1)
BOOKINGTIME DATE
SQL> insert into flight values (1,sysdate,'ROTERDAM','TOKYO',100,100);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from flight;
FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 100
SQL> select * from flightbooking;
no rows selected
SQL> insert into flightbooking values (1,'0001',1,10,'B',sysdate);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from flight;
FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 90
SQL> update flightbooking set numseats=20 where flightid=1;
1 row updated.
SQL> select * from flight;
FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 80
SQL> delete from flightbooking where flightid=1;
1 row deleted.
SQL> commit;
Commit complete.
SQL> select * from flight;[pre]
[pre] FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 100
SQL> insert into flightbooking values (1,'0001',1,10,'B',sysdate);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from flight;
FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 90
SQL> update flightbooking set status='C' where flightid=1;
1 row updated.
SQL> commit;
Commit complete.
SQL> select * from flight;
FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 100
SQL> update flightbooking set status='B' where flightid=1;
1 row updated.
SQL> select * from flight;
FLIGHTID FLIGHTDAT ORIGIN DESTINATIO MAXCAPACITY AVAILABLESEATS
1 13-MAR-06 ROTERDAM TOKYO 100 90Khurram Siddiqui
[email protected]
Similar Messages
-
i have update my iphone, 4 days ago and now when i try to connect it to a network it says unable to join and before i update, it worked perfect so if u guys know anything about it please let me know!
sincerly
AfghanproPlace the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
iOS: Forgot passcode or device disabled
If recovery mode does not work try DFU mode.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings
For how to restore:
iTunes: Restoring iOS software
To restore from backup see:
iOS: Back up and restore your iOS device with iCloud or iTunes
If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
You can redownload most iTunes purchases by:
Downloading past purchases from the App Store, iBookstore, and iTunes Store
If problem what happens or does not happen and when in the instructions? When you successfully get the iPod in recovery mode and connect to computer iTunes should say it found an iPod in recovery mode.
If not backup you MAY be able to get some info from the restored iPod via
How to perform iPad recovery for photos, videos
Wondershare Dr.Fone for iOS: iPhone Data Recovery - Wondershare Official
http://www.amacsoft.com/ipod-data-recovery.html
iPod recovery software to restore lost music files
-iPod touch Deleted Photo Recovery Tips You Should Know -
Hi, I already installed photoshop trial version and three weeks later I paid on-line for 300 Baht for buy it but it still ask me to join and pay for it. How can I update it in my log in account. Please help.?
You do not buy Photoshop for 300 baht, you are renting it for that much a month. You set up an account with a valid credit card and to see if it is active, you go here. https://www.adobe.com/account/my-products-services.html Look under my Subscriptions.
If all is good, then with the same Adobe ID/password, select "License this Product" and sign in, or Help > Sign in.
That will license it.
Gene -
Timeout error while reading and updating in batches in a single transaction
Problem:-
In a transaction I do read and update to the database in batches. First batch it runs fine and for second batch it get hanged at
sqlCommand.ExecuteReader(). The following is not my complete code but required bits of it which will give more information about the problem. At the end of this post please find the error log. Please help me.
My guess:-
The problem i see here is with the locks acquired while reading and update still remain when it comes for the second batch which is blocking the next read. But could not find a way to solve it.
Get connection and open it.
Begin Transaction.
sqlUpdateTransaction = sqlUpdateConnection.BeginTransaction(String.Format("UpdateUsageDetailTransaction{0}", storageClassId))
Get application lock.
GetApplock
const String sqlText = @"DECLARE @result int EXEC @result = sp_getapplock Resource=@resourceName,@LockMode='Exclusive',@LockOwner='Transaction',@LockTimeout=@timeout select @result";
using (SqlCommand sqlCommand = sqlTransaction.Connection.CreateCommand())
sqlCommand.CommandText = sqlText;
sqlCommand.Parameters.AddWithValue("@resourceName", resourceName);
sqlCommand.Parameters.AddWithValue("@timeout", milliSecondsTimeout);
sqlCommand.CommandTimeout = secondsTimeout;
sqlCommand.Transaction = sqlTransaction;
Int32 lockResult = (Int32) sqlCommand.ExecuteScalar();
Seek and read the range of records.
using (var sqlReadConnection = new SqlConnection(_connectionString))
sqlReadConnection.Open();
SqlTransaction sqlTransaction = _sqlUpdateTransaction;
_cdrList = CdrOps.FetchByrecordsIdRange(_yearMonth, firstSkid, firstSkid + count - 1, sqlReadConnection);
sqlReadConnection.Close();
return _cdrList.Count > 0;
static public Dictionary FetchByrecordsIdRange(Int32 yearMonth, Int64 startCdrId, Int64 endCdrId, SqlConnection sqlConnection)
Dictionary cdrList = new Dictionary();
using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
sqlCommand.CommandText = "EXEC P_GetCDRData @yearMonth, @startCdrId, @endCdrID";
sqlCommand.Parameters.AddWithValue("@yearMonth", yearMonth);
sqlCommand.Parameters.AddWithValue("@startCdrId", startCdrId);
sqlCommand.Parameters.AddWithValue("@endCdrID", endCdrId);
sqlCommand.CommandTimeout = DbOps.TwoHourTimeoutValue;
using (SqlDataReader sqlDataReader = sqlCommand.ExecuteReader())
FetchrecordPieces(sqlDataReader, cdrList);
return cdrList;
Update the records to the list by using a loop Go and check if the number of records read is equal to the batch size then write and flush.
update()
_tollUpdatedList.Add((Toll) record);
_legacyUpdateCount++;
Dispose.
Dipose()
if (_sqlUpdateTransaction != null && _sqlUpdateTransaction.Connection != null)
sqlUpdateTransaction.Rollback(String.Format("UpdateUsageDetailTransaction{0}", _storageClassId));
_sqlUpdateTransaction.Dispose();
_sqlUpdateTransaction = null;
Commit.
commit()
if(_sqlUpdateTransaction != null)
_sqlUpdateTransaction.Commit();
_sqlUpdateTransaction.Dispose();
_sqlUpdateTransaction = null;
Error log.
Error: [0x80004005] MonthlyFileDb::Seek - Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.Thank you, I used beta_lockinfo and observed the following
spid=59/0/2
command = SELECT
appl=.Net SqlClient Data Provider
hostprc= 3640
dbname = DEV_ECAP_P_CAP_ENT_CMN
prcstatus= SUSPENDED
spid_ =
59/0/2
blklvl = 1
blkby = 55
rsctype =
locktype =
lstatus =
ownertype =
rscsubtype =
waittime = 785.139
waittype = LCK_M_IS
spid__ = 59/0/2
nstlvl = 3
inputbuffer = (@yearMonth int,@startCdrId bigint,@endCdrID bigint)EXEC P_GetCDRData @yearMonth, @startCdrId, @endCdrID
current_sp = DEV_ECAP_P_CAP_ENT_CMN.dbo.P_GetCDRData
spid=55
command = NULL
appl=.Net SqlClient Data Provider
hostprc= 3640
dbname = DEV_ECAP_P_CAP_ENT_CMN
prcstatus= sleeping
spid_ = 55
blklvl = !!
blkby =
rsctype = APPLICATION
locktype = X
lstatus = grant
ownertype = transaction
rscsubtype =
waittime =
waittype =
spid__ = 55
nstlvl =
inputbuffer =UPDATE UsgDetailCommon SET RunId = t2.RunId FROM UsgDetailCommon t1 INNER JOIN #UsgDetailCommon_Update t2 ON t1.YearMonth = t2.YearMonth AND t1.CdrId = t2.CdrId ;DROP TABLE #UsgDetailCommon_Update
current_sp =
But what is the solution for this...? I am googling and I found similar post but with no solution, here it is not allowing me to post html link -
JOIN in UPDATE using JDBC receiver
Hi All
The scenarios is as follows :
I have to implement,updation of a flag in a table where the column names in the WHERE clause are from two different tables in the same database.
i.e
UPDATE T1
Set T1.flag =1
where T1.columnA=value1 and T2.columnB=value2
where T1 and T2 are tables in the same database,
and the values (value1 and value 2 ) are provided to XI by SAP based on which the flag need to be updated in T1
one way is to write a stored procedure specifying the join and call it in XI,
I want to accomplish this directly using SQL statement from XI
Is that possible ???
kindly reply
thanks
sdHi Sd,
You can execute an SQL statement directly in your Receiver JDBC adapter.
Check this link for that,
http://help.sap.com/saphelp_nw04/helpdata/en/2e/96fd3f2d14e869e10000000a155106/content.htm
Check the part for STATEMENTNAME6 and also the example for that in the same link,
Regards,
Bhavesh -
Joins And For all Enteries in Select Statement
Could you please tell me when there is a high amount of data which is being handled in the table, does the use of INNER JOINS and FOR ALL ENTERIES in SELECT Statement decreases the system performance? ?
Can you also let me know where can i get some tips regarding do's and dont's for ABAP Programming, I want to increase my system performance.
Currently the programs which are being used are taking a lot of time for execution...
Its very URGENT!Hai Jyotsna
Go through the following Tips for improving Performence
For all entries
The for all entries creates a where clause, where all the entries in the driver table are combined with OR. If the number of entries in the driver table is larger than rsdb/max_blocking_factor, several similar SQL statements are executed to limit the length of the WHERE clause.
The plus
Large amount of data
Mixing processing and reading of data
Fast internal reprocessing of data
Fast
The Minus
Difficult to program/understand
Memory could be critical (use FREE or PACKAGE size)
Some steps that might make FOR ALL ENTRIES more efficient:
Removing duplicates from the driver table
Sorting the driver table
If possible, convert the data in the driver table to ranges so a BETWEEN statement is used instead of and OR statement:
FOR ALL ENTRIES IN i_tab
WHERE mykey >= i_tab-low and
mykey <= i_tab-high.
Nested selects
The plus:
Small amount of data
Mixing processing and reading of data
Easy to code - and understand
The minus:
Large amount of data
when mixed processing isnt needed
Performance killer no. 1
Select using JOINS
The plus
Very large amount of data
Similar to Nested selects - when the accesses are planned by the programmer
In some cases the fastest
Not so memory critical
The minus
Very difficult to program/understand
Mixing processing and reading of data not possible
Use the selection criteria
SELECT * FROM SBOOK.
CHECK: SBOOK-CARRID = 'LH' AND
SBOOK-CONNID = '0400'.
ENDSELECT.
SELECT * FROM SBOOK
WHERE CARRID = 'LH' AND
CONNID = '0400'.
ENDSELECT.
Use the aggregated functions
C4A = '000'.
SELECT * FROM T100
WHERE SPRSL = 'D' AND
ARBGB = '00'.
CHECK: T100-MSGNR > C4A.
C4A = T100-MSGNR.
ENDSELECT.
SELECT MAX( MSGNR ) FROM T100 INTO C4A
WHERE SPRSL = 'D' AND
ARBGB = '00'.
Select with view
SELECT * FROM DD01L
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
SELECT SINGLE * FROM DD01T
WHERE DOMNAME = DD01L-DOMNAME
AND AS4LOCAL = 'A'
AND AS4VERS = DD01L-AS4VERS
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
SELECT * FROM DD01V
WHERE DOMNAME LIKE 'CHAR%'
AND DDLANGUAGE = SY-LANGU.
ENDSELECT.
Select with index support
SELECT * FROM T100
WHERE ARBGB = '00'
AND MSGNR = '999'.
ENDSELECT.
SELECT * FROM T002.
SELECT * FROM T100
WHERE SPRSL = T002-SPRAS
AND ARBGB = '00'
AND MSGNR = '999'.
ENDSELECT.
ENDSELECT.
Select Into table
REFRESH X006.
SELECT * FROM T006 INTO X006.
APPEND X006.
ENDSELECT
SELECT * FROM T006 INTO TABLE X006.
Select with selection list
SELECT * FROM DD01L
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
ENDSELECT
SELECT DOMNAME FROM DD01L
INTO DD01L-DOMNAME
WHERE DOMNAME LIKE 'CHAR%'
AND AS4LOCAL = 'A'.
ENDSELECT
Key access to multiple lines
LOOP AT TAB.
CHECK TAB-K = KVAL.
ENDLOOP.
LOOP AT TAB WHERE K = KVAL.
ENDLOOP.
Copying internal tables
REFRESH TAB_DEST.
LOOP AT TAB_SRC INTO TAB_DEST.
APPEND TAB_DEST.
ENDLOOP.
TAB_DEST[] = TAB_SRC[].
Modifying a set of lines
LOOP AT TAB.
IF TAB-FLAG IS INITIAL.
TAB-FLAG = 'X'.
ENDIF.
MODIFY TAB.
ENDLOOP.
TAB-FLAG = 'X'.
MODIFY TAB TRANSPORTING FLAG
WHERE FLAG IS INITIAL.
Deleting a sequence of lines
DO 101 TIMES.
DELETE TAB_DEST INDEX 450.
ENDDO.
DELETE TAB_DEST FROM 450 TO 550.
Linear search vs. binary
READ TABLE TAB WITH KEY K = 'X'.
READ TABLE TAB WITH KEY K = 'X' BINARY SEARCH.
Comparison of internal tables
DESCRIBE TABLE: TAB1 LINES L1,
TAB2 LINES L2.
IF L1 <> L2.
TAB_DIFFERENT = 'X'.
ELSE.
TAB_DIFFERENT = SPACE.
LOOP
AT TAB1.
READ TABLE TAB2 INDEX SY-TABIX.
IF TAB1 <> TAB2.
TAB_DIFFERENT = 'X'. EXIT.
ENDIF.
ENDLOOP.
ENDIF.
IF TAB_DIFFERENT = SPACE.
ENDIF.
IF TAB1[] = TAB2[].
ENDIF.
Modify selected components
LOOP AT TAB.
TAB-DATE = SY-DATUM.
MODIFY TAB.
ENDLOOP.
WA-DATE = SY-DATUM.
LOOP AT TAB.
MODIFY TAB FROM WA TRANSPORTING DATE.
ENDLOOP.
Appending two internal tables
LOOP AT TAB_SRC.
APPEND TAB_SRC TO TAB_DEST.
ENDLOOP
APPEND LINES OF TAB_SRC TO TAB_DEST.
Deleting a set of lines
LOOP AT TAB_DEST WHERE K = KVAL.
DELETE TAB_DEST.
ENDLOOP
DELETE TAB_DEST WHERE K = KVAL.
Tools available in SAP to pin-point a performance problem
· The runtime analysis (SE30)
· SQL Trace (ST05)
· Tips and Tricks tool
· The performance database
Optimizing the load of the database
Using table buffering
Using buffered tables improves the performance considerably. Note that in some cases a statement can not be used with a buffered table, so when using these statements the buffer will be bypassed. These statements are:
Select DISTINCT
ORDER BY / GROUP BY / HAVING clause
Any WHERE clause that contains a sub query or IS NULL expression
JOIN s
A SELECT... FOR UPDATE
If you wan t to explicitly bypass the buffer, use the BYPASS BUFFER addition to the SELECT clause.
Use the ABAP SORT Clause Instead of ORDER BY
The ORDER BY clause is executed on the database server while the ABAP SORT statement is executed on the application server. The database server will usually be the bottleneck, so sometimes it is better to move the sort from the database server to the application server.
If you are not sorting by the primary key ( E.g. using the ORDER BY PRIMARY key statement) but are sorting by another key, it could be better to use the ABAP SORT statement to sort the data in an internal table. Note however that for very large result sets it might not be a feasible solution and you would want to let the database server sort it.
Avoid the SELECT DISTINCT Statement
As with the ORDER BY clause it could be better to avoid using SELECT DISTINCT, if some of the fields are not part of an index. Instead use ABAP SORT + DELETE ADJACENT DUPLICATES on an internal table, to delete duplicate rows.
Thanks & regards
Sreenivasulu P -
Compare table A and table B and update table B ,,,,table B has 300k rows
Hi,
I m trying to write a code, I have tables A and table B.
I need to compare table A and table B , and update table B with one column.
using joins b/w A&B tables, I selected one record from table A in cursor.
After Begin I m trying to open cursor and in FOR LOOP
Im trying to update table B WHERE CURRENT OF Cursor.
this is erroring out.
could you let me know on this.
there is another way like selecting required columns from both table.but i was told to do as above.
Thanks> this is erroring out.
You haven't posted nearly enough for anyone to help you. You didn't even tell us what error you are getting.
So about the only thing we can do is post a generic MERGE statement which you'll have to modify for your use.
merge into tableB b
using (select some_key, some_column from tableA where etc.) u
on (u.some_key = b.some_key)
when matched then update
set b.some_column = u.some_column; -
Help with drop create and update table
Sir/Madam,
I have joined 5 tables and selected some columns ,then I need to update some columns in that. After updating I need to create a report with the new column values.
To do this my method is to create temp table with the select statement then update the temp table , use this temp table for the report and then drop the temp table.
Is there anyother way to do this ??
Can I create a cursor and update the cursor column ??
Does dynamic sql always be created as procedure ??Hi,
you need to understand how eventing works in BSP and MVC architecture. Pls refer to the below link for a basic understanding of how BSP works - View, Controller and Model class concepts.
http://www.sapdev.co.uk/webapps/bsp/washome.htm
For your requirement -
1. you need a view on which you will create a drop down list UI element and a table view element
2. you will need to create a contoller class - this will be used to handle the event that will be triggered when user selects an entry from drop down list
3. you will need a model class in which you will write the business logic to retrieve employees of selected department.
Pls search this forum or blogs for - data binding with BSPs, Table View. Pls read these concepts and try to develop your requirement. You can come back to this forum if you face any issues during development.
hope this helps. -
Check two columns and update other table
HI ,
I have a table called trackCenterline .Below is the table.
What i want to do is If the segmentSequenceID is 1 it should pick the corresponding SegmentID i.e 10001 and Check for the same segment id in other table called TrackSegment which is below. and pick the BeginMilepost of that segmentID and Update That
Milepost in a new table .At end SegmentSequenceID number it should pick ENDMilepost and update
TrackCenterline table.
TrackSegment table
In the below table for 10001 SegmentID it should pick BeginMilepost. For end Number of SegmentSequenceID in above table ID ends at 121 for that end sequenceID It should refer TrackSegment table below and pick EndMilepost and should be updated in another
table Milepost column.
after that a new segment starts with new sequence .and so on ...
bhavanaHi Deepa_Deepu,
According to your description, since the issue regards T-SQL. I will help you move the question in the T-SQL forums at
http://social.technet.microsoft.com/Forums/en-US/home?forum=transactsql. It is appropriate and more experts will assist you.
When you want to check two columns from two tables then return some results and update the third table. I recommend you use join function and combine two tables, then use update select from statement for modifying the Mailpost table. You can refer to the
following T-SQL Statement.
-----using join to connect to two tables
select TrackCenterline.FeatureId,TrackCenterline.SegmentId,
TrackCenterline.SegmentSequenceId,TrackSegment.BeginMilepost,TrackSegment.EndMilepost
from dbo.TrackCenterline join dbo.TrackSegment
on TrackCenterline.SegmentId=TrackSegment.SegmentId
order by TrackCenterline.SegmentId, TrackCenterline.SegmentSequenceId
---the result shows as following.
FeatureId SegmentId SegmentSequenceId BeginMilepost EndMilepost
AMK100011 10001 1 61.0000 61.3740
AMK100012 10001 2 61.0000 61.3740
AMK100013 10001 3 61.0000 61.3740
AMK1000121 10001 121 61.0000 61.3740
AMK100021 10002 1 61.1260 61.7240
AMK100023 10002 3 61.1260 61.7240
AMK100033 10003 3 61.3740 62.9530
-----Then you can use update select from statement to modify the Mailpost table, Or you can post the table structure of Mailpost
And for more information, you can review the following article about update statement.
http://www.techonthenet.com/sql/update.php
Regards,
Sofiya Li
Sofiya Li
TechNet Community Support -
Messy One to Many Joins and Grouping
I manage websites for a large state agency in Texas. I have a
need to redo
queries that list the Local intake numbers for Long term
support services
(LTSS), Area Agencies on Aging (AAA), and Mental Retardation
Authorities
(MRA) by county for each of the state's 254 counties -- in
the past there
was only one intake number per county for each AAA and MRA,
with there being
the possibility for multiple LTSS intake numbers. Now there
are counties
that have multiple numbers for MRA intake.
Basic Structure of Database Tables:
CountyCenter Table
County (text)
CountyNumber (integer)
AAA_ID (integer)
MRA_ID (integer)
LTSS Table
County (text)
CountyNumber (integer)
City (text) -- optional used when there are multiple offices
for a county
IntakeNumber (text)
Region (text)
AAA Table
AAA_ID (integer)
AAAName (text)
AAAPhone (text)
MRA Table
MRA_ID (integer)
MRAName (text)
MRAPhone
MRAOffices
MRA_ID (integer)
IntakePhone (text)
City (Text)
CountyNumber (integer)
My goal is for each county to list in a combined table:
Column 1 = County Name
Column 2 = LTSS Office (Number(s))
Column 3 = MRA Intake Number
Column 4 = AAA Intake Number(s)/City if not main
Do I need a separate table for county that simply has the
CountyNumber and
CountyName to use as a control table?
I'd like to do this as efficiently as possible -- thankfully
the query won't
be accessed by the general public and will be run only when
updated
information is received. Any suggestions as to order of the
joins and
groupings in CFOUTPUT? (what I have now creates a lot of
duplication)
Thanks in advance for your help,
Michael Brown
Webmaster, Texas Department of Aging and Disability ServicesPhil,
Thanks for taking a look. You're definitely right. The data
structures are a mess. What was originally intended to be on
three
separate pages has been requested to be "available at a
glance."
With both the LTSS Offices and MRAs having the possiblity of
multiple offices for a given county what would be the best
way to
normalize the data? The tables for MRA, AAA, and LTSS have
CountyNumber (county exists only in those tables to provide
context for those who update the information manually (not my
choice/decision)).
So to break it down 254 Counties, each can have one or
multiple
LTSS numbers (and the number's city), only one AAA number,
and one
MRA with the possiblity for multiple intake numbers (and note
containing location information).
Hopefully, there is a graceful way of getting the output the
way
it has been requested. I'm open to suggestions.
Thanks again,
Michael
"paross1" <[email protected]> wrote in
news:[email protected]:
> After taking a quick glance, it looks like you already
have
> normalization issues with your data model, since LTSS
Table and
> CountyCenter Table both contain County (text), and
MRAOffices
and LTSS
> Table both have City (text), etc. It is hard to tell
which
fields are
> primary keys and which are foreign keys to which tables.
Some of
these
> that may have a one-to-many relationship that now
changes to a
> many-to-many will require a link table (associative
entity) and
the
> foreign keys migrated to them.
>
> You need to resist creating actual "combined tables",
spreadsheet
> style, and
> instead normalize your database, so that you can create
your
"combined
> table" virtually using SQL. It is hard to offer
specifics, since
I
> would need more information to do so, but the bottom
line is
that you
> do have some obvious data model issues that need to be
resolved
before
> you can get much further. Otherwise, you are going to
have to
write
> some very kludgey SQL to solve your problem with your
current
model.
>
> Phil
>
> -
iPhone WiFi issue. I enter a password, click join, and get a message back that it is an incorrect password. I have several computers and other iPhones connected using the same password. Any ideas?
Hey there Gordo456,
It sounds like you are not able to join your Wi-Fi network with the correct password on 1 out of many devices. I recommend the troubleshooting from the article named:
iOS: Troubleshooting Wi-Fi networks and connections
http://support.apple.com/kb/TS1398
Restart your iOS device.
Update your device to the latest version of software.
Update your Wi-Fi router to the latest firmware2. For AirPort Base Stations, install updates using the AirPort Utility.
If that troubleshooting does not resolve the issue, I would next try these steps from further down the article:
Unable to connect to a Wi-Fi network
Verify that you're attempting to connect to your desired Wi-Fi network.
Make sure you're entering your Wi-Fi password correctly. Passwords may be case sensitive and may contain numbers or special characters.
Reset network settings by tapping Settings > General > Reset > Reset Network Settings. Note: This will reset all network settings including:
previously connected Wi-Fi networks and passwords
recently used Bluetooth accessories
VPN and APN settings.
Thank you for using Apple Support Communities.
Regards,
Sterling -
Memory leak/overload when looping by index over a large query and updating each DB record
I am importing a CSV file into a temporary table and then running a select query that joins my actual database table with the temporary table, looking for any changes in the data. If changes exist, the select query is looped from 1 to #recordCount# and an update is applied to each record via cfquery. It runs very quickly (much more quickly than looping the query itself), but my memory spikes and overloads after about 1500 updates are completed. I need to be able to do upwards of 20000 at a time, without killing my system. I have tried manually setting the runtime garbage collection to trigger after X number of loops, but that doesn't seem to help. I am running CF8. See below for loop example:
<cfloop from="1" to="#updatedRecordsQuery.recordCount#" index="a">
<cftry>
<cfquery datasource="#db#" name="doUpdate">
UPDATE
CI
SET
firstname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#updatedRecordsQuery.firstname[a]#" />,
lastname = <cfqueryparam cfsqltype="cf_sql_varchar" value="#updatedRecordsQuery.lastname[a]#" />,
etc, for about 15 various fields
FROM
client_info CI
WHERE
CI.client_id = <cfqueryparam cfsqltype="cf_sql_integer" value="#updatedRecordsQuery.client_id[a]#" />
</cfquery>
<cfcatch type="database">
<cfset local.updateErrorList = listappend(local.updateErrorList,updatedRecordsQuery.client_id[a]) />
<cfset local.error = true />
</cfcatch>
</cftry>
</cfloop>I would suggest to use select update instead of looping over query object and update each row one-by-one.
Procedure:
- Insert your CSV data into temp table.
- Use a select update SQL query to update the changed data instead of looping over a select query.
Example:
UPDATE
Table
SET
Table.col1 = other_table.col1,
Table.col2 = other_table.col2
FROM
Table
INNER JOIN
other_table
ON
Table.id = other_table.id
NOTE: You can put all your scripts in a Procedure. -
I have tryed to connect an AirPort Express to my wireless network. But I alwais get the errocode -4. Can anybody help. I have reset the AirPort Express and updated the software.
The ZyXEL P-2601HN-F1, as you know, is a combination DSL modem & 802.11n wireless router (or gateway device).
For your goal you will want to take a look at this Apple Support article for details on how to configure an AX for iTunes.
If you are still having difficulties with the AX joining the ZyXEL's wireless network, you can try the following:
Temporarily disable wireless encryption.
If you are hidding the SSID, disable that feature.
Change the Mode Select setting to: 802.11g Only
Change the Channel Selection from "Auto" to a set channel, like 1, 6, or 11 -
Count of inserted and updated rowcount in @@rowcount
Similarly I have created a sp which is inserting and updating the records.
Now I want to track the count of new record inserted and updated record in @@rowcount .
please suggest me the code .
below is my sp
alter Procedure SP_Archive_using_merge
AS
--exec SP_Archive
BEGIN
SET NOCOUNT ON
Declare @Source_RowCount int
Declare @New_RowCount int
DECLARE @TimeIn SMALLDATETIME
DECLARE @LatestVersion INT
SET NOCOUNT ON
---BBxKey and Hash value of all the source columns are derived in source query itself--
select @TimeIn=getdate(),@LatestVersion=1
MERGE Archive.dbo.ArchiveBBxCemxr AS stm
USING (
SELECT a.*,cast(SUBSTRING(a.Col001,1,10) as varchar(100)) BBxKey,
HashBytes('MD5', CAST(CHECKSUM(a.Col001,a.Col002,a.Col003,a.Col004,a.Col005,a.Col006,a.Col007) AS varbinary(max))) RowChecksum,
b.BBxKey as Archive_BBxKey, b.RowChecksum as Archive_RowChecksum
FROM dbo.ImportBBxCemxr a LEFT OUTER JOIN Archive.dbo.ArchiveBBxCemxr b
ON a.Col001 = b.BBxKey
Where (b.LatestVersion = 1 OR b.LatestVersion IS NULL) AND a.Col001 IS NOT NULL
) AS sd
ON sd.Archive_BBxKey = stm.BBxKey and sd.RowChecksum = stm.RowChecksum
WHEN MATCHED AND (stm.BBxKey = sd.Archive_BBxKey and stm.RowChecksum != sd.Archive_RowChecksum) THEN
UPDATE SET
stm.TimeIn = @TimeIn,
BBXKey=sd.BBXKey,
RowChecksum=sd.RowChecksum,
stm.Col001=sd.Col001,
stm.Col002=sd.Col002,
stm.Col003=sd.Col003,
stm.Col004=sd.Col004,
stm.Col005=sd.Col005,
stm.Col006=sd.Col006,
stm.Col007=sd.Col007,
stm.LatestVersion=@LatestVersion
WHEN NOT MATCHED and (sd.Archive_BBxKey is null) THEN
Insert (TimeIn,BBXKey,RowChecksum,Col001,Col002,Col003,Col004,Col005,Col006,Col007,LatestVersion)
values(getdate(),sd.BBXKey,sd.RowChecksum,sd.Col001,sd.Col002,sd.Col003,sd.Col004,sd.Col005,sd.Col006,sd.Col007,@LatestVersion);
end
Thankx & regards, Vipin jha MCPYou need to OUTPUT clause with action column to get the info into teable variable and then count from the table variable.
Try the below: (Not tested)
alter Procedure SP_Archive_using_merge
AS
--exec SP_Archive
BEGIN
SET NOCOUNT ON
Declare @Source_RowCount int
Declare @New_RowCount int
DECLARE @TimeIn SMALLDATETIME
DECLARE @LatestVersion INT
SET NOCOUNT ON
---BBxKey and Hash value of all the source columns are derived in source query itself--
select @TimeIn=getdate(),@LatestVersion=1
DECLARE @tableVariable TABLE (sAction VARCHAR(20), InsertedID INT, DeletedID INT)
MERGE Archive.dbo.ArchiveBBxCemxr AS stm
USING (
SELECT a.*,cast(SUBSTRING(a.Col001,1,10) as varchar(100)) BBxKey,
HashBytes('MD5', CAST(CHECKSUM(a.Col001,a.Col002,a.Col003,a.Col004,a.Col005,a.Col006,a.Col007) AS varbinary(max))) RowChecksum,
b.BBxKey as Archive_BBxKey, b.RowChecksum as Archive_RowChecksum
FROM dbo.ImportBBxCemxr a LEFT OUTER JOIN Archive.dbo.ArchiveBBxCemxr b
ON a.Col001 = b.BBxKey
Where (b.LatestVersion = 1 OR b.LatestVersion IS NULL) AND a.Col001 IS NOT NULL
) AS sd
ON sd.Archive_BBxKey = stm.BBxKey and sd.RowChecksum = stm.RowChecksum
WHEN MATCHED AND (stm.BBxKey = sd.Archive_BBxKey and stm.RowChecksum != sd.Archive_RowChecksum) THEN
UPDATE SET
stm.TimeIn = @TimeIn,
BBXKey=sd.BBXKey,
RowChecksum=sd.RowChecksum,
stm.Col001=sd.Col001,
stm.Col002=sd.Col002,
stm.Col003=sd.Col003,
stm.Col004=sd.Col004,
stm.Col005=sd.Col005,
stm.Col006=sd.Col006,
stm.Col007=sd.Col007,
stm.LatestVersion=@LatestVersion
WHEN NOT MATCHED and (sd.Archive_BBxKey is null) THEN
Insert (TimeIn,BBXKey,RowChecksum,Col001,Col002,Col003,Col004,Col005,Col006,Col007,LatestVersion)
values(getdate(),sd.BBXKey,sd.RowChecksum,sd.Col001,sd.Col002,sd.Col003,sd.Col004,sd.Col005,sd.Col006,sd.Col007,@LatestVersion)
OUTPUT $action as action, inserted.BBXKey as ins, deleted.BBXKey as del into @tableVariable;
--To get the action count info
SELECT sAction, COUNT(*) FROM @tableVariable GROUP BY sAction
end -
The full message said:
There was a problem downloading the software for the iPhone "Judy's iPhone 4". The network connection was reset.
Make sure your network settings are correct and your network connection is active, or try again later.
I am trying to update the iPhone for my grandmother, Judy, as I am leaving for Paris on Wednesday night and we want to have Facetime installed on her iPhone before then, so we can stay in contact with each other. It is the simplest way for this to happen but the program simply will not allow me to update her iPhone.
Is there any way to get past this error and update her iPhone? Any help will be greatly appreciated.Dear Jody..jone5
Good for you that can't update your iphone because I did it and my iphone dosen't work for example I can't download any app like Wecaht or Twitter..
Goodluck
Atousa
Maybe you are looking for
-
Automatic variable Change of the Place item on a action
I'm begining in the scripting area, but I'm lost realy. I looking in a way to change the place automatic based on the filename/ folder. Today I do like this: I'm aplying a image in the back of a photo with automate batch. My actions goes in resume l
-
Where to find a good tutorial and books on Java?
Hi Where can I find the best tutorial and books on Java?
-
CS5 SDK + AME CS4 = Crash from bad memorySuite
Hi all, I compiled the CS5 SDK_Exporter example and only changed one thing: 1: the build from x64 to x86 (because I'm on Win7 32bit with CS4 Production Premium) BTW the enviroment variable $(PREMSDKBUILDPATH) is set to points to
-
Cant get into my computer using new password - have tried to change several times. Does anyone have suggestion how to get in......? Thank you in advance Gunnar
-
helo sap masters could u plz help me out .. 1. Why should we maintain LIVE Cache separately despite of having in APO tool.??? 2. Why should we have BW in APO too in spite of having BW tool seperately ??