How to UPDATE multiple rows in T1 with unique value from T2
Hi,
having on mind update query with where clause:
WHERE (SELECT LEFT(ColumnName,7) FROM tblName) = emp2.ColumnName
error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
The statement has been terminated.
What am I suppose to change in WHERE clause....
Note: there is always unique value in T2 while, in T1, there could be both, only one value to be updated or number of them that all need to be updated with that unique value from T2 (alias emp2)
T1
T2
colimn1 column2 column3 column4
001A001A string1 001A001 string10
001A001B string2 001A005 string20
001B005A string3
001B005B string4
001B005C string5
should become:
T1
colimn1 column2
001A001A string10
001A001B string10
001B005A string20
001B005B string20
001B005C string20
UPDATET1
SET column2 = emp2.column4
FROM T2 as emp2
WHERE (SELECT LEFT(column1,7) FROM T1 = emp2.column3
Hi daredevil3011,
Based on my test, the error is caused by where statement in the query. Just as the error message, in your where statement, there is a subquery “SELECT LEFT(ColumnName,7) FROM tblName” follows ”=”, this is not permitted in SQL Server.
To fix this issue, please modify your query to like below:
UPDATE T1
SET column2 = emp2.column4
FROM T2 as emp2
WHERE LEFT(column1,7) = emp2.column3
Reference:
WHERE (Transact-SQL)
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support
Similar Messages
-
How to update multiple rows in one query using php
i am new to this can any one help me how to update multiple rows at a time i am doing an school attendance page
Often the situation is such that you have multiple courses across a range of dates.So students may take more than one course, and you need to track attendance for each course date. The following graphic demonstrates this:
In such a situation, you need four database tables as follows:
students (student_id, student_name, etc.)
courses (course_id, course_name, etc.)
students_courses (student_id, course_id)
attendance (student_id, course_id, dater)
A fifth table may also be needed to define the dates of courses, but you may also be able to build this array programmatically by using PHP's robust date functions, which can give you, for instance, all the Tuesdays and Thursdays between a start date and end date.
The students_courses table simply keeps track of which students are taking which courses, so it has just two columns for the primary keys of both of the main tables. The attendance table is similar, but it also includes a date field. The following view of the attendance table demonstrates this:
So if David's solution does cover your needs, consider yourself lucky, because this could quickly grow from a beginner-appropriate project to a moderately advanced one. -
How to update multiple rows in ADF Tble
Hi,
I have created a search form and ADF table. This ADF table is having column of Select Boolean check box along with actual table columns.
When I click on Search button it should show the result in ADF table. I will be able to select the check box in multiple rows.
Finally when I click on Submit button status column should be updated against the rows for which Boolean check box is selected.
Here the thing that I would like to know is how to identify the rows whichever are selected when I click on Submit button.
Could you please help.
Regards
Vinod.http://sameh-nassar.blogspot.de/2009/12/use-checkbox-for-selecting-multiple.html shows how to use a checkbox via a transient attribute on the EO. To get the selected row you check the transient attribute of each row.
Timo -
How to update multiple rows using cursor.
hi all,
i want to update rows fetched by a cursor. it don't update the rows.
and gives error:
ORA-01002 fetch out of sequence
here is the trigger.
Declare
alert_id ALERT := Find_Alert('on');
alert_button NUMBER;
var number :=10;
v_al char(3);
v_al_da date;
s_date date;
al_on number;
to_time number;
cursor rem is
select re_about, alarm, alert_date
from remind
where alarm='ON' AND alert_date = :control.showdate
for update;
begin
for rem_record IN rem LOOP
Set_Alert_Property(alert_id, ALERT_MESSAGE_TEXT, rem_record.re_about);
al_on := show_alert('ON');
IF alert_button = ALERT_BUTTON1 THEN
update remind
set alarm = 'OFF'
--where re_about = rem_record.re_about
where current of rem;
ELSE
NULL;
END IF;
COMMIT;
END LOOP;
end;
thanks
Muhammad Nadeem
Mardanthanks dear,
i tried the following code outside the loop
but the same problem.
here is the code:
Declare
alert_id ALERT := Find_Alert('on');
alert_button NUMBER;
var number :=10;
v_al char(3);
v_al_da date;
s_date date;
al_on number;
to_time number;
cursor rem is
select re_about, alarm, alert_date
from remind
where alarm='ON' AND alert_date = :control.showdate
for update;
begin
for rem_record IN rem LOOP
Set_Alert_Property(alert_id, ALERT_MESSAGE_TEXT, rem_record.re_about);
al_on := show_alert('ON');
IF alert_button = ALERT_BUTTON1 THEN
update remind
set alarm = 'OFF'
where current of rem;
ELSE
NULL;
END IF;
END LOOP;
if :SYSTEM.FORM_STATUS = 'changed' then
COMMIT;
end if;
end;
thanks
Muhammad Nadeem -
How to update multiple row using procedure in table
Hi,
create or replace procedure TESTLEDGER1(var_date varchar2)
as
var_date1 date;
CURSOR C1 IS
select DISTINCT ta.accountid,day PROCESSDATE,
(NVL(payment,0))PAYMENT,NVL(TOTALDUE,0)TOTALDUE,NVL(currentbillamount,0)CURBILL,NVL(srf,0)SRF,NVL(sbpnt,0)sbpnt,
NVL(srv,0)SRV,NVL(sbf,0)SBF,NVL(SBV,0)SBV,NVL(EF,0)EF,NVL(EV,0)EV,NVL(TSRV,0)TSRV,
NVL(tsub,0)TSUB,NVL(teqe,0)TEQE,NVL(DT,0)DT,
NVL(A.dep,0)RDEP,NVL(B.DEP,0)PDEP,
NVL(pnt,0)PNT,NVL(eqp,0)EQP,NVL(dtr,0)DTR,NVL(drf,0)DRF,NVL(unadj,0)UNADJ
from
(select DISTINCT day ,accountid
from
syntblmaccount, tblmtime where yyyy =2010)ta,
(SELECT accountid,
SUM(srfee)srf,
SUM(srvat)srv,
SUM(subfee)sbf,
SUM(subvat)sbv,
SUM(eqefee)ef,
SUM(eqevat)ev,
SUM(ttlsrv)tsrv,
SUM(ttlsub)tsub,
SUM(ttleqe)teqe,
SUM(dep)dep,
SUM(dt)dt,trunc(fromdate)fromdate
FROM VWDT_v2
GROUP BY accountid,trunc(fromdate)
)a,
(SELECT accountid,
SUM(pnt)pnt,
SUM(subpnt)sbpnt,
SUM(eqpnt)eqp,
SUM(dep)dep,
SUM(DEPTRANSFER)dtr,
SUM(DEPREFUNDED)drf,
SUM(unadj)unadj,trunc(paymentdate)paymentdate
FROM vwkt_v4
GROUP BY accountid,trunc(paymentdate)
)b,
(SELECT ACCOUNTID,REFUND,trunc(createdate) createdate FROM vwrefund)F,
( SELECT ACCOUNTID,
TRUNC(CREATEDATE)CREATEDATE,
sum(TOTALDUE)/100 TOTALDUE,sum(currentbillamount)currentbillamount
FROM SYNTBLTDEBITDOCUMENT
group by ACCOUNTID, TRUNC(createdate))debit,
(SELECT ACCOUNTID accountid,TRUNC(createdate)CREATEDATE, SUM(totalamount)PAYMENT
from syntbltcreditdocument
where CREDITDOCUMENTTYPEID IN ('CDT01','CDT04')
-- AND ACCOUNTID='ACC000003014'
group by accountid,TRUNC(createdate))credit
where ta.accountid=a.accountid(+)
and ta.accountid=b.accountid(+)
--and ta.accountid=pay.accountid(+)
and ta.accountid=debit.accountid(+)
and ta.accountid=credit.accountid(+)
and ta.accountid=f.accountid(+)
and ta.day=a.fromdate(+)
--and ta.day=pay.createdate(+)
and ta.day=debit.createdate(+)
and ta.day=credit.createdate(+)
and ta.day=b.paymentdate(+)
and ta.day=f.createdate(+)
and trunc(ta.day)=to_date(var_date,'DD-MON-YY');
begin
select distinct processdate into var_date1 from ledgerdetail;
FOR V1 IN C1 LOOP
UPDATE LEDGERDETAILtest
SET PAYMENT=v1.payment,
TOTALDUE=v1.TOTALDUE,
CURBILL=v1.curbill,
SRF=v1.srf,
SBPNT=v1.sbpnt,
SRV=v1.srv,
SBF=v1.sbf,
SBV=v1.sbv,
EF=v1.ef,
EV=v1.ev,
TSRV=v1.tsrv,
TSUB=v1.tsub,
TEQE=v1.teqe,
DT=v1.dt,
PDEP=v1.rdep,
PNT=v1.pnt,
EQP=v1.eqp,
DTR=v1.dtr,
DRF=v1.drf,
UNADJ=v1.unadj
where accountid=v1.accountid
and processdate=v1.processdate;
--DBMS_OUTPUT.PUT_LINE('INSERTED ROW');
commit;
end loop;
end;
I have created above procedure to update table column....but i am getting run time error....
Error report:
ORA-01422: exact fetch returns more than requested number of rows
ORA-06512: at "CRESTELVIEWSPRD501.TESTLEDGER1", line 70
ORA-06512: at line 1
01422. 00000 - "exact fetch returns more than requested number of rows"
*Cause: The number specified in exact fetch is less than the rows returned.
*Action: Rewrite the query or change number of rows requested
how to resolve this error...
Pl give me solution...
thanks in advance.Hi:
You have to make sure that join condition joins one record to one record not to a group of records.
Saad,
http://saadnayef.blogspot.com/ -
i have one array of string score1[]
and i want to update those value in table
how the query should be.........
i thought it work as like for insert query
but following is not working
PreparedStatement ps = con.prepareStatement("update class_test_scores set score=? where student_id=? and test_no='fct' and subject_id=?");
while(j<k)
ps.setString(1, score1[j]);
ps.setString(2, name[j]);
ps.setString(3, subject);
ps.executeUpdate();
j++;
}thanx & regards
sweetytahnx for reply
Akash_Ganga
actually now it is working fine
there was no error
but the conformation page that i was displaying after updating
was not loading
now i got it correctly
cheers & regards
sweety -
How to generate multiple "gift certificate" pdfs with unique serial #s
I am a new Acrobat user (have Adobe Acrobat 9 Pro) and poked around a bit to see if I could find out how to do this, but found nothing.
I assume this has been done before and hope someone can point me in the right direction.
Here's what I am trying to do:
1. I currently have a pdf doc with a field for a unique serial # (let's call the doc a "Gift Certificate" for simplicity, though that's not quite what it is).
2. I want to generate multiple pdf files, say 100 of them, based on this original Gift Certificate, but with each one having a unique serial # in the appropriate field, say starting at ser # 1001, and running through to ser # 1100.
3. I want to be able to save each of these new files on a hard drive - not outputting them to a printer (though this might come in handy in the future too).
Is this something I can do in Adobe Acrobat Pro 9? I looked at the Batch Processing tool, but that didn't seem to have any ability to create new files.
Or do I need a plug-in? Or a separate software altogether?
Any help for this novice would be greatly appreciated.
Thanks
keithProblem solved.
Forum member try67 wrote me a script, complete with simple installation instructions.
It works perfectly right out of the box. Great stuff!!!
Wish it always worked that way.
Keith -
How to populate multiple text boxes by selecting a value from drop down
I apologize in advance if this is redundant, but I have searched this forum relentlessly to no avail. I have a form connected to an MS Access database. The database is linked to another datadase on an Advantage server. This is dynamic data that has an ODBC driver allowing to link access tables to the Advantage data. Macros on access updates the table being used on this form. The livecycle form connects to the access data via a DSN on a machine that uses acrobat (not reader). This is a physician office, this form should expedite ordering radiology tests on patients. The plan is to use a drop down to select a chart number that will trigger several text boxes to populate dynamically with the corresponding demographic values like name, age, insurance etc.
Using a data drop down I am able to select the chart number. When I used the example from the office supplies database, so that a button will trigger the event with the following code:
if (Len(Ltrim(Rtrim(SelectField.rawValue))) > 0) then
$sourceSet.DataConnection.#command.query.commandType = "text"
$sourceSet.DataConnection.#command.query.select.nodes.
item(0).value = Concat("Select * from OfficeSupplies Where ID = ", Ltrim(Rtrim(SelectField.rawValue)) ,"")
I recieve a syntax error, despite adjusting quotation since I am using text rather than numeric fields.
My question is the following:
Is there a simple javascript that I can use to populate these text boxes (which may be read only but would be better if it allows user input)? Or does anyone recommend an alternative method? I would be happy with a link that solves this problem if someone can provide. I am somewhat familiar with js but open to any suggesstion.
Thanks
PS this form could also be linked to a Sequel database if that offers an advantage.The View object API has a setQurery() method that you can use to set the query as needed before executing it via executeQuery(). You can do this in a custom Application Module method exposed to its client interface and bound to the binding layer. You can call this method from your backing bean on a value change listener.
-
Updating multiple rows with different values
Hi!
I have a problem. I need to update more then 1000 rows with different values. How can I do it?
For exsample i have table:
id; color, date,
1 red
2 green
3 white
I need to update date field.
Update table
set date='01.02.03'
where id=1
Update table
set date='01.03.03'
where id=2
Maybe there is way how to update multiple rows at one query?
Sorry for my bad english.
Thanks!Hi,
You can try this
UPDATE TABLE SET DATE = CASE
WHEN ID = 1 THEN TO_DATE('01-02-03','DD-MM-RR')
WHEN ID = 2 THEN TO_DATE('01-03-03','DD-MM-RR')
ENDcheers
VT -
Updating Multiple Rows With A Sequence
I'm trying to update multiple rows of data in one column based on if its date is greater than a certain date. Starting with the lowest date from those dates I'll give it a 2000 and every ascending date from that point will be another number in sequence (2001, 2002, 2003, etc.).
Apologization Edit:
11g XE
Edited by: spysmily1 on Jun 4, 2012 5:50 PM
Edited by: spysmily1 on Jun 4, 2012 5:51 PMI would use a counter and start at a specific number. Then I would try to keep updating with this number and incrementing each time. The part I can't quite grasp is how to use this number with the lowest record and apply this sequence to each date that ascends from there. What I was going to try to come up with is something like:
DECLARE
counter := 2000;
BEGIN
loop
update table_name
set column_name = counter
where date > specified date;
counter := counter + 1;
end loop;
This is my first thought but I couldn't see a way to just update the first one that is greater than the specified date and then keep cycling through the dates until the last date(most recent). I know I would need a loop but what can I set that loop to so it would know when to stop. I could use a variable I know is less than the total amount that need to be altered.
Edited by: spysmily1 on Jun 4, 2012 6:21 PM -
How to update multiple records in the table using POST parameters:
i got this idea from this website:http://www.karlrixon.co.uk/articles/sql/update-multiple-rows-with-different-values-and-a-s ingle-sql-query/comment-page-1/#comment-5409. Basically i am trying to update all the status in the results page, and by adding $i in front of the id in the text fields, and checkboxes, i can name the different inputs with different names:
The image of how it takes the inputs is shown here:http://forums.adobe.com/thread/709034?tstart=0
I tried this but got this error:Parse error: syntax error, unexpected T_IF, expecting ')' in C:\xampp\htdocs\Database Query\results_change.php on line 51
will not work in the update code section:
for($i=0;$i<$maxRows_Recordset1;$i++)
{$a=sprintf("%s",GetSQLValueString($_POST['changeid $i'],"int"));
$b=sprintf("%s",GetSQLValueString($_POST['checkbox $i'],"text"));
$display_order .= array(
$a => $b
if($i<$maxRows_Recordset1-1)
$ids = implode(',', array_keys($display_order));
$updateSQL = "UPDATE `change` SET Status = CASE Change_id ";
foreach ($display_order as $a => $b) {
$updateSQL .= sprintf("WHEN %d THEN %s ", $a,$b);
$updateSQL .= sprintf("END WHERE `Change_id` IN ($ids)");Hi,
Try
BEGIN
FOR i IN 1..APEX_APPLICATION.G_F03.COUNT LOOP
UPDATE xx_test
SET checkbox = 'Y'
WHERE rec_no = APEX_APPLICATION.G_F03(i);
END LOOP;
END;Code loops all checked checkbox. You do not need commit on page process.
Regards,
Jari
http://dbswh.webhop.net/dbswh/f?p=BLOG:HOME:0 -
Update multiple rows based on two columns in same row
I have a 1000 rows in a table I would like to update with a unique value. This unique value is a cocatenation of two columns in teh same row.
Each row has a (i) date and a (ii) time and a (iii) date_time column. I would like to update the date_time (iii) column with a cocatenation of the (i) date and (ii) time columns.
I know how I would update a single row but how can I update multiple rows with a cocatenation of each of the two columns - i.e put a different value into the date_time column for each row?this?
update table tab_name
set date_time =date||time
where your_condition -
BC4J datagrid to update multiple rows
Hi,
How do we update multiple rows at a time in a BC4J JSP with Struts. I intend to have a datagrid control on a JSP so that users may update multiple rows at a time and click 'Update' once.
There is a possible (workaround) solution using struts nested tags but one would lose the benefits of JBO tags on using struts tags (e.g Calendar control would not be visible for Date input).
Any implementation suggestions?
Regards,
AshishDoes the database only contain data where there are events on a given 15-minute time slot?
-
Updating multiple rows in a table in ADF
Hi
How do we update multiple rows in a table.
Onclicking a update button the changed rows must be updated.Hi Prince,
currently I am selecting one row from the table and rendering a region at the top of the table and capturing the user entered data with the following code:
ViewObjectVOImpl vo = getViewObjectVO1();
Row CurrentRow = vo.getCurrentRow();
//After this I perform the checks like user entered value is not null or check input as per business logic.
if(CurrentRow.getAttribute("attributeName") ==null){
//Add what message you want to display
//Add other business logic.
After making all the checks, i commit it.
getOADBTransaction().commit();
Now in my new page I am capturing the user input in the table itself like an excel sheet. Suppose there are ten rows in my advanced table on my page, and each row has one editable field. I have one save button at the bottom of the table.
Now on clicking the save button I have to capture the user input, check whether there is any null value and if all the entered data is correct then only I should commit it.
Can you please let me know how we can accomplish that.
Regards
Hawker -
Update multiple rows involving spatial data
Hi,
i have 2 table, that are
temp
store_id
store_state
geom mdsys.sdo_geometry
us_states
state
geom mdsys.sdo_geometry
i have indexed both table with spatial index.
If i wanna find state that temp.geom is inside us_states.geom using
SQL> select state from us_states, temp
where sdo_inside(temp.geom, us_states.geom) = 'TRUE';
it's work
but if i wanna update temp.store_state using
SQL> update temp set store_state = (select state from us_states
where sdo_inside(temp.geom, us_states.geom) = 'TRUE');
it gives this error
update temp set store_state = (select state from us_states where sdo_inside(temp.geom, us_states.geom) = 'TRUE')
ERROR at line 1:
ORA-13226: interface not supported without a spatial index
ORA-06512: at "MDSYS.MD", line 1723
ORA-06512: at "MDSYS.MDERR", line 8
ORA-06512: at "MDSYS.SDO_3GL", line 62
ORA-06512: at "MDSYS.SDO_3GL", line 192
any idea how can i update multiple rows that involving spatial data?
Thanks
HadiHadi,
There are a number of things wrong with the second item. First up you most likely will return more than one row, which is not allowed as the = expects only one item.
Here is what I would use, which will update everything that meets the requirements, and ignore the rest:
UPDATE (
SELECT /*+ bypass_ujvc */
state, store_id, store_state
FROM temp, us_states
WHERE sdo_inside(temp.geom, us_states.geom) = 'TRUE')
SET store_state = state;
With the /*+ bypass_ujvc */ you're telling the db to not worry about requiring a "unique join view condition" -- which roughly mean "trust me, my rows are key preserved." This is important since there is really no "hard" key-based relationship to tie the two together.
However, unless you really think there are stores that border on two states, this will run much quicker with an anyinteract comparison.
Bryan
Maybe you are looking for
-
Already I have changed the settings to no proxy, but it doesn't work. Each time I want to open internet again I get the same report and I have to change the setting to no proxy again! Also I noticed that FF has changed the proxy adjustment himself to
-
Battery Life on brand new macbook pro 15 inch i5 only lasting 3 hours
The battery on my macbook pro is only lasting 3 hours with light use...If i'm watching a video or on a game it lasts maybe an hour or 2. I charged it fully when I first got it out of the box 2 days ago. I have tried calibrating it which worked a litt
-
Incoming Invoice Create from data without posting the GR details
Hi Experts, I am trying to create a MM invoice (MIRO) using the BAPI BAPI_INCOMINGINVOICE_CREATE and I do not want to post GR details in this invoice. But I have not been able to see the face of success yet. Following are the parameters that I pass t
-
Can I convert a pdf to word doc with adobe send?
can i convert a pdf to word doc with adobe send--if so, how?
-
Can KN3 export flash with sound?
I'm working on a presentation in KN2 and I need to export a .swf file with sound on each slide. I know I can export to Quicktime with sound, but I'm working with another company that only accepts a .swf files. Is this fixed in KN3? Any suggestions on