Select and update in same instruction
Can i select and update a column in table by one query only
I donot want to execute two queries one for updation and one for retrieval
e.g. instead of UPDATE t1 set val=val+1 and then SELECT val from t1;
i wanna have a single query (compliant to mysql and ORACLE)
because when i passa query UPDATE t1 set val=val+1; SELECT val from t1; on the command prompt is is fine but when i do so through jdbc it gives me errror
please help
Why would a stored procedure change anything?
The stored procedure would have the UPDATE ... ; SELECT sequence in it.
Which results in the same "work" the database has to do, compared to sending the two statements via JDBC.
The only thing that a stored procedure would save, is the second JDBC call, but I doubt that this makes a big difference (provided this is not done in a loop. Then I'd retrieve the new values in one statement after all the updates have been committed)
So I would simply do Statement statement = connection.createStatement();
int rows = statement.executeUpdate("UPDATE ....");
ResultSet rs = statement.executeQuery("SELECT ... ");
String val = null;
if (rs.next()) val = rs.getString(1);
rs.close();The code for the stored procedure would look very similar to this with the disadvantage that that you have to maintain it for every DBMS that has to be supported.
Similar Messages
-
Can I use a select and update statement in a single jsp file?
I want to update the BUY table everytime I would add a SELL transaction.....I want to minus the stocks that I sold to those that Ive bought before.....
note: I used a seperate table in BUY and SELL transaction
After I Have added a transaction, I want to update the buy table. This is my problem, can I used both SELECT and UPDATE statement at the same time in a single jsp file for example like this:
select * from test, test1;
update test
set total_shares=total_shares-Stotal;
where stock_code=Scode AND name_broker=Sbroker;
Can i have both of these statements in the same jsp file in oder to update the buy table?
Or can anyone suggest how can process that update?THANKS!
--------------------Can i have both of these statements in the same jsp file in oder to update the buy table?Yes. But wouldn't it have been easier just to try it?
-
JDBC Sender - Different number of records selected and updated.
Hi people,
We have a JDBC -> Abap proxy scenario. The JDBC sender is pooling an Oracle database to retrieve data from a table X, each 30 minutes. The select and update statements in jdbc sender are below
SELECT FIELD1, FIELD2, FIELD3 FROM MY_TABLE WHERE STATUS = 1
UPDATE MY_TABLE SET STATUS = 2 WHERE STATUS = 1
Sometimes the message sent to Abap proxy has, for example, 400 records. Looking at runtime workbench, message monitoring, for the same message there is a log like this
Channel SENDER_JDBC_CHANNEL: Query executed successfully. Start update
Channel SENDER_JDBC_CHANNEL: 510 row(s) updated successfully
Someone has already experienced something like this? How can I handle this to guarantee to update only those read records?
regards.
robertiHi All,
Even we are facing the same problem.
In our scenario, receiver is SAPR3. (IDOC)
Will this parameter serialization work in our case?
1. SELECT XBLNR, WERKS, MATNR, MDV01, BACKFLQUANT, STATUS, SAPTIMESTAMP, PITSTIMESTAMP, PMTIMESTAMP, BATCH FROM PMBPITS.PITS_UNITY WHERE STATUS = '01' and rownum<200 .
2. UPDATE PMBPITS.PITS_UNITY SET STATUS = '02' , SAPTIMESTAMP = sysdate WHERE STATUS = '01' and rownum<200 ( currently the value is rownum < 5 )
Thanks!!
Regards
Gouri -
Select and update rownum sender jdbc
Dear all
i am using PI 7.31 sender jdbc adapter.
table(TB_AA) has 10000 row with pi_stat = 'R' and then sender jdbc adapter tried 10 row in using rownum every 120 second and update same rownum
but result of select query and udpate query were different. not same record update for selecting data.
co_cd, memid is PK.
select co_cd , mem_id, reg_n FROM TB_AA where PI_STAT = 'R' AND rownum <= 10
update TB_AA set PI_STAT = 'S', where PI_STAT = 'R' and rownum <= 10
query is wrong? , what is correct update query with several PK ?Hi Arten Solohin.
co_cd, memid is Primary Key.
select co_cd , mem_id, reg_n FROM TB_AA where PI_STAT = 'R' AND rownum <= 10
update TB_AA set PI_STAT = 'S', where PI_STAT = 'R' and rownum <= 10
could you make your query with above my query ? because i am confusing ORDER BY <your unique id_field> AND LINE_ID ....
will be highly appreciated in advance
thanks you very much. -
Insert a field and update the same row.
Hi,
I am inserting a value in a row.
And later within a cursor loop I am trying to update the same row. But it is not working....
CREATE OR REPLACE procedure Del_Note_stage
Is
v_delNote Delivery_Note.Delivery_Note_id%type;
Cursor C1 is Select Heading_Name,File_Data from Sqlload_Stage;
Begin
dbms_output.put_line('i am here a ');
Select Delivery_Note_Id_Seq.nextval into v_delNote from dual;
Insert into DELIVERY_NOTE_STAGING(Delivery_Note_ID,LUT,LUB,PROCESSED) Values(v_delNote,sysdate,'Config','N');
commit;
dbms_output.put_line('i am here b'||v_delNote);
For sqlload_rec in C1
Loop
dbms_output.put_line(sqlload_rec.Heading_Name);
dbms_output.put_line('Del Note Id is :'||v_delNote);
update DELIVERY_NOTE_STAGING set deployed_by='TOM' where delivery_note_id=v_delNote;
End loop;
End;But it is not working....Why not?
Please read: http://tkyte.blogspot.com/2005/06/how-to-ask-questions.html
Why are you updating after inserting?
Just add deployed_by to the insert statement, or use a default value for that column.
Also you don't need to select your Delivery_Note_Id_Seq.nextval from dual, just use it in your insert statement.
Something like:
Insert into DELIVERY_NOTE_STAGING(Delivery_Note_ID,LUT,LUB,PROCESSED,deployed_by )
Values( Delivery_Note_Id_Seq.nextval,sysdate,'Config','N', 'TOM' /*or USER*/); -
Select and update with lock exclusive
Hello Everybody
In our application we have a table autonum to handle unique keys for all other tables.
In Autonum we have a column "SUCHBEGRIFF" char(40) unique KEY and a column "WERT" fixed(10,0).
Suchbegriff has values like Rechnungsnr,Auftragsnr,Bestellnr ...
Example:
Befor inserting a record into table rechnungen we do:
Select wert from autonun where suchbegriff = "Rechnungsnr" with lock exclusive.
l_rechnrneu = wert + 1
update autonum set wert = ?l_rechnrneu where suchbegriff = "Rechnungsnr"
commit
(then l_rechnrneu is used for an insert into rechnungen command)
This technic works for all tables (250) in our application.
We have about 400 concurrent users working with maxdb 7.6 via odbc 7.6
No problems since 2 years!
Now we start some backgroundjobs from an xp-workstation.
We have scheduled 5 jobs, starting every 5 minutes, same time.(Same user,same odbc-connection)
Each job inserts records into a table joblogs and therefore needs a unique JOBLOGNR from autonum.
Now we run into problems 2 or 3 times a day?
<Sometimes the backgound jobs are running (waiting?) without inserting a record into joblogs (deadlock?)
And more worse:
Sometimes the insert into joblogs failes with "duplicate key" ??
We don't know where to begin? Maxdb Problem ? Workstation problem?
Any help welcomed
Best regards
Albert> >Gosh - that's information overloading at it's best...
> We call this needed information.
> What does our SAP-System? We have 1 mandt,60 accounting areas and about 200 werks!
> Of course SAP uses internal unique keys for all tables, but we configured different "number intervals" for each werks.
With "information overloading" I was referring to the multiple meanings you encode in just one column (your "rechnungs-no").
SAP tables do not have this.
As you wrote, there is "MANDT", "BUKRS", "WERKS" ... and the primary key is defined over all relevant columns.
There is no primary key column where all the different meanings are concatenated together.
So there aren't any surrogate keys here (a.k.a. AUTOID) used here - (ok except the infamous DDLOG sequence...).
> >What do you do, when the value of an invoice has to be changed? Update the primary key of the table?
> Update rechnungen set amount = xyz,...... where rechnungnr = nnn
> We never change rechnungsnr,if the invoice was wrong we produce a credit for it and then write a new invoice
So, you could use a sequence here instead as well.
> > We don't use rollback when fetching logids from autonum.
> >So what do you do, when connection fails, the database crashes or the client application hits an error?
> >You use rollback. There is no way to avoid it.
> >Your application gets a "duplicate key" error - the database performs a rollback of your last action. What does your application do then? Commit?
> Sorry, i meant that we do not do rollbacks over 2 or 3 inserts or updates in different tables.
> SQL-Command,On error = messagebox,errorlog,quit
You don't handle the fetching of the new number in the same transaction as the actual insert of your application data in the same transaction?
> >What isolation level do you use?
> We use DATABASE ISOLATION LEVEL 0
Hmm... did you read the documentation on SQL Locks?
[Internals Course - SQL Locks|http://maxdb.sap.com/training/internals_7.6/locking_EN_76.pdf] :
"Isolation level 0 does not offer any protection against access anomalies."
Basically it might have happened that the same number is read twice.
Perhaps the application is not always requiring locks when reading data from this table?
> After connecting to the database via odbc we do
> =SQLSETPROP(verbindungsnr,"Transactions",2)
> 2 = Transaction processing is handled manually through SQLCOMMIT( ) and SQLROLLBACK( ). Read/write.
> =SQLSETPROP(verbindungsnr,"DisconnectRollback",.T.)
>
>
> So normal select commands are fired without a following commit.
> Insert and update commands are fired with a following commit command.
> Selects from autonum are fired with "look exclusive"
Please be more detailed here.
What is the exact sequence of actions here?
1. Fetch number from number table and update number table.
2. COMMIT
3. Insert new application data with the just fetched number.
4. COMMIT
or
1. Fetch number from number table and update number table.
2. Insert new application data with the just fetched number.
3. COMMIT
And what does your application do with its data when a rollback occurs?
Is it guaranteed that all variables are reset?
> Nevertheless you dislike our design, do you think it would be better (quicker,safer...) to use an internal databases procedure to get
> the next speaking number for a given "suchbegriff" from our autonum table? (no translation of the sql-command every time)
No, currently we don't know what is causing the problem, so we cannot tell whether such a change would help. In fact, right now it would make things more complicated because we would less understand, what's happening here.
Concerning your design: it's not about "liking" or "not liking it".
I just pointed out some problems that result from the design as it is.
> select wert into :neuerwert FROM "BWPROGI"."AUTONUM" WHERE upper(suchbegriff) = upper(:suchkey) WITH LOCK EXCLUSIVE;
> update "BWPROGI"."AUTONUM" set wert = wert + 1 WHERE upper(suchbegriff) = upper(:suchkey) ;
> SET neuerwert = neuerwert + 1;
> end;
1. The WHERE clause UPPER(suchbegriff) = UPPER(...) is the best way to disable the efficient use of any index structure. Better make sure that your data is in the right format in the table when you enter it and then look it up without the UPPER() conversion.
2. I wouldn't perform the increment two times.
Get the current value into your variable, increment this variable, set the current value in the table to the variable.
> A char(10) return value would be nice and i don't know wether this would be the quicker way.
Why should it? You would have to convert it first - that's additional work.
Anyhow, to move ahead with your duplicate keys problem, you may perform a vtrace with the "stop on error" option.
As your error is a duplicate key on a primary key constraint you should set "stop on error" to the error code "200".
The next time your application hits the error, the vtrace automatically stops and we could examine what happened before.
See [MaxDB database trace|https://wiki.sdn.sap.com/wiki/x/2yg] for details on how to activate the trace.
When the error occurs next time and you caught it in the vtrace we can take a look at it.
regards,
Lars -
Controversy between SELECT and UPDATE
I have 2 queries one with SELECT and the other with UPDATE. The WHERE clause in both the queries are exactly same. When I do the SELECT I am getting a row and when I do the UPDATE I am not getting any rows. The following are the queries and descriptions of the tables involved. I tried executing these 2 queries many times and no difference.
SQL> SELECT * FROM Fraud_30_Day_Summ S1
2 WHERE s1.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
3 AND s1.Fraud_Category_Cd = 'CPI'
4 AND s1.On_Off_Net_Ind = 'Y'
5 AND s1.Threshold_ind = 'Y'
6 AND (s1.Icon_Ind IS NULL OR s1.Icon_Ind <> 'N' )
7 AND (
8 ( s1.Call_Cnt * .5 <=
9 ( SELECT SUM(s2.Call_Cnt)
10 FROM Fraud_CPCS_Call_Detail s2
11 WHERE s2.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
12 AND s2.Component_Group_Cd = s1.Component_Group_Cd
13 AND s2.Component_Grp_Val = s1.Component_Grp_Val
14 AND s2.Call_type_cd = s1.Call_type_cd
15 AND s2.On_Off_Net_Ind = 'Y'
16 AND EXISTS
17 (
18 SELECT s3.ROWID
19 FROM Threshold_Element_Value s3
20 WHERE s3.Threshold_Element_Val = s2.icon_country_cd
21 AND s3.Threshold_Id = '405') ) ) );
DISCONNECT_DT FRAUD_CATEGORY_CD ON_OFF_NET_IND COMPONENT_GRP_VAL COMPONENT_GROUP_CD CALL_CNT CALL_DUR_VAL ICON_IND CELLULAR_IND CUST_SPECIFIC_IND THRESHOLD_IND LAST_USED_IND CALL_TYPE_CD
10/1/2008 CPI Y 234546575678 CP 3 2474 Y
Y C
SQL> Update Fraud_30_Day_Summ s1 SET s1.Icon_Ind = 'N'
2 WHERE s1.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
3 AND s1.Fraud_Category_Cd = 'CPI'
4 AND s1.On_Off_Net_Ind = 'Y'
5 AND s1.Threshold_ind = 'Y'
6 AND (s1.Icon_Ind IS NULL OR s1.Icon_Ind <> 'N' )
7 AND (
8 ( s1.Call_Cnt * .5 <=
9 ( SELECT SUM(s2.Call_Cnt)
10 FROM Fraud_CPCS_Call_Detail s2
11 WHERE s2.Disconnect_Dt = TO_DATE('01-OCT-2008','DD-MON-YYYY')
12 AND s2.Component_Group_Cd = s1.Component_Group_Cd
13 AND s2.Component_Grp_Val = s1.Component_Grp_Val
14 AND s2.Call_type_cd = s1.Call_type_cd
15 AND s2.On_Off_Net_Ind = 'Y'
16 AND EXISTS
17 (
18 SELECT s3.ROWID
19 FROM Threshold_Element_Value s3
20 WHERE s3.Threshold_Element_Val = s2.icon_country_cd
21 AND s3.Threshold_Id = '405') ) ) );
0 rows updated.
DESC FRAUDCPCS_CALL_DETAIL_
RECORD_ID{ }NUMBER(5,0)
ORIG_BILL_FILE_ID{ }NUMBER(10,0)
RECORD_SEQ { }NUMBER(10,0)
BILLING_CYCL_ID { }NUMBER(5,0)
CUSTOMER_ACCT_ID { } NUMBER(10,0)
OCCR_NO { }NUMBER(10,0)
FRAUD_CATEGORY_CD{ } NOT NULL{ } VARCHAR2(3)
CALL_TYPE_CD { } NOT NULL { } VARCHAR2(1)
ORIG_TERM_NPA_NXX_CD{ } VARCHAR2(6)
COMPONENT_GROUP_CD { } NOT NULL{ } VARCHAR2(2)
COMPONENT_GRP_VAL{ } NOT NULL{ } VARCHAR2(26)
ORIGINATING_DT { } NOT NULL{ } DATE
ORIGINATING_TIME_VAL{ } NOT NULL { } NUMBER(10,0)
DISCONNECT_DT { } NOT NULL{ } DATE
DISCONNECT_TIME_VAL { } NOT NULL{ } NUMBER(10,0)
ORIG_STATE_CD { } VARCHAR2(2)
TERM_STATE_CD { } VARCHAR2(2)
CALL_DUR_VAL { } NOT NULL { } FLOAT(12)
PRCMP_ID{ } NUMBER(5,0)
ORIG_COUNTRY_CD{ } VARCHAR2(3)
TERM_COUNTRY_CD { } VARCHAR2(3)
ORIG_CITY_CD { } VARCHAR2(15)
TERM_CITY_CD { } VARCHAR2(15)
GSA_ORIG_JURISD_ID{ } NUMBER(10,0)
GSA_TERM_JURISD_ID { } NUMBER(10,0)
USAGE_CATEGORY_CD{ } VARCHAR2(8)
CALLING_NO { }VARCHAR2(16)
CALLED_NO { } VARCHAR2(20)
USAGE_TYP{ } VARCHAR2(35)
INTERNATIONAL_CALL_TYP{ } VARCHAR2(20)
VOICE_MAIL_IND { } VARCHAR2(1)
DIR_ASST_IND { } VARCHAR2(1)
CALL_FWD_IND { } VARCHAR2(1)
ROAMING_IND{ } VARCHAR2(1)
CALL_TO_OHSA_IND { }VARCHAR2(1)
MOBILE_TO_MOBILE_IND { }VARCHAR2(1)
ON_OFF_NET_IND { } NOT NULL{ } VARCHAR2(1)
DESTINATION_TXT { } VARCHAR2(14)
CALL_CNT { } FLOAT(12)
ICON_COUNTRY_CD{ } VARCHAR2(3)
DESC FRAUD30_DAY_SUMM_
DISCONNECT_DT { } NOT NULL{ } DATE
FRAUD_CATEGORY_CD { } NOT NULL{ } VARCHAR2(3)
ON_OFF_NET_IND { } NOT NULL{ } VARCHAR2(1)
COMPONENT_GRP_VAL { } VARCHAR2(26)
COMPONENT_GROUP_CD { } NOT NULL { } VARCHAR2(2)
CALL_CNT { } NOT NULL { }FLOAT(12)
CALL_DUR_VAL{ } NOT NULL{ } FLOAT(12)
ICON_IND { } VARCHAR2(1)
CELLULAR_IND{ } VARCHAR2(1)
CUST_SPECIFIC_IND{ } VARCHAR2(1)
THRESHOLD_IND { } VARCHAR2(1)
LAST_USED_IND { }VARCHAR2(1)
CALL_TYPE_CD { }NOT NULL{ } VARCHAR2(1)
DESC THRESHOLDELEMENT_VALUE_
THRESHOLD_ID { } NOT NULL { } NUMBER(5,0)
THRESHOLD_ELEMENT_VAL { } NOT NULL { }VARCHAR2(18)
Edited by: user10568649 on Nov 8, 2008 11:27 AM
Edited by: user10568649 on Nov 8, 2008 12:44 PMWould it be possible to edit your post to remove all the extra carriage returns? Having two blank lines between every line of code & results is making it somewhat difficult to follow.
While you are editing the post, it would also be helpful if you could enclose the code & results in the \ tag in order to preserve white space.
Justin -
How multiple users can open and update it same time in Sharepoint 2010, excel file
we are using SharePoint 2010, multiple users can open and update the file at same time in SharePoint, I have searched a lot and
read it, some suggestions were can create the file as share work book and then save on Share point and other were its supported only with Office web Apps, Excel Web App, we don't have office Web apps or excel web app, is there any other suggestion,
any help will be great, thanks in advanceHi,
You need office web apps for co-authoring, see Software version requirements for co-authoring in SharePoint 2013 and SharePoint Online section in below link -
http://technet.microsoft.com/en-us/library/ff718249(v=office.15).aspx
and
http://office.microsoft.com/en-us/sharepoint-foundation-help/document-collaboration-and-co-authoring-HA102772333.aspx
Edit: Link for SP 2010
http://technet.microsoft.com/en-us/library/ff718249(v=office.14).aspx
Hope this helps!
Ram - SharePoint Architect
Blog - SharePointDeveloper.in
Please vote or mark your question answered, if my reply helps you -
Combine select and update into single statement,without bind-variable
I have a problem, that I think is not possible to solve the way I want to, but I just wanted to check before leaving the idea...
I am looking for a way to combine the select and the update statement into one single statement. This is what I wan't to achive: select some data, and update the data selected before returning them.
On this site http://www.psoug.org/reference/update.html I see that the following are possible:
var bnd1 NUMBER
var bnd2 VARCHAR2(30)
var bnd3 NUMBER
UPDATE employees
SET job_id ='SA_MAN', salary = salary + 1000,
department_id = 140
WHERE last_name = 'Jones'
RETURNING salary*0.25, last_name, department_id
INTO :bnd1, :bnd2, :bnd3;
I need to have this as a single statement, and cannot use bind-variables. So I was hoping that something like this could be possible:
UPDATE customer c
SET c.HAS_CREDIT ='1'
WHERE c.HAS_CREDIT = '0'
RETURNING c.CUSTOMER_NO, c.FIRSTNAME, c.LASTNAME
where c.HAS_CREDIT = '1'
But this doesn't compile, complaining of missing into (ORA-00925: missing INTO keyword). And even though I would like this to be possible because this would solve my current problem, I think it would be very confusing. For instance; would the where clause of the returning part be operating after the update or before?
Any comments or suggestions on how to get it work in a single statement, or should I just leave this path straight away?Hi,
RETURNING only works with bind variables, see
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/returninginto_clause.htm#sthref3006
The real problem is that the form of RETURNING clause with bind variables is only valid for single row update or insert statements.
To update (or insert) multiple rows and return the data, you will need to use
RETURNING BULK COLLECT INTO clause. See
http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2236
Cheers,
Colin -
Select and update leave request data - oracle !!
Dears,
We have a very important presentation here to one of our stakeholders and he is interested to see how to submit and update leave requests using Adobe LiveCycle Workspace.
I have a simple PDF form where the user can choose to submit new leave or update an existing one, if the user choses to update an existing leave he will enter the leave start date and press on a button to retrieve this leave information form the database ( select * from leaves where leave_date=’the entered date’ and requestor=’requestor name’) as requestor name and entered date are variables in the PDF, And then he can update the start date or leave duration and submit his request after updating this record in the database.
Will you please help me how to do that knowing my PDF contains a digital signature and the data saved in a document variable?
The connection with oracle created by updating the adobe-ds.xml file in “C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\deploy” and deploying the ojdbc14.jar in “C:\Adobe\Adobe LiveCycle ES2\jboss\server\lc_turnkey\lib”.
Database is oracle10.2.0.1.0
Adobe LiveCycle Workbench ES2
Version: 9.5.0.0.20100908.1.247189
Many thanks in advanced,
Mohammed Al-MoslehI solved updating single row issue and retrieving single row from data base issue too ...
I need an example, that shows us how to retrieve multiple records from a database, we did this, and DISPLAY, we couldn't, the results in a table within a pdf.
the data stored in XML after using Query Multi Rows in XML Activity in Workbench...
Can any one Help me how to Disply this XML in a table ?? -
Possible? two users/computers to share and update the same calendar?
We would like to have two people update the same calendar. How is this possible? Subscribers can't update?
ThanksIn short it isn't possible (currently). Subscribers cannot edit a calendar they subscribe to - it is read-only.
See this thread for more detail: http://discussions.apple.com/thread.jspa?threadID=705054&tstart=45 -
Selecting and Updating in SQL 2005
I have a situation where I need to select some records from a table. This select query will run again after a certain amount of time. I dont want the second execution of the query to select the records that were selected in the first run. So, what I want is that as soon as I run the first run (or the subsequent runs) and I get the resultset I need to update a flag (which is a column in that table) for all the entries selected in the result set so that next time I run that query, I wont get the same records again.
hamburger wrote:
I have a situation where I need to select some records from a table. This select query will run again after a certain amount of time. I dont want the second execution of the query to select the records that were selected in the first run. So, what I want is that as soon as I run the first run (or the subsequent runs) and I get the resultset I need to update a flag (which is a column in that table) for all the entries selected in the result set so that next time I run that query, I wont get the same records again.Presumably this is for a process and not a GUI.
Write a stored proc that does the following.
1. Create a transaction.
2. Make a timestamp
3. Update the records that have NOT been previously selected using the timestamp from 2.
4. Select the records using the timestamp.
5. Commit the transaction.
6. Return the selected records - including the timestamp as part of each record.
That last little bit, the timestamp, allows the possibility of logging to a file or back to the database that indicates that a particular block has completed (maybe a status is set.) That way if the process fails there is some way to find the records that were not processed. -
8.0.2 Insert and Update on same page?
With 8.0.2 is it possible to have an update and insert on the
same page?On Fri, 19 Jan 2007 08:34:35 -0600, Lee
<[email protected]>
wrote:
>Did you have to tweak the code to get them to work
together (changing
>function names) or did they work automatically?
>
>Perhaps it's just what I am trying to do with the page. I
have two forms
>and depending on which they need, either the update is
used or the
>insert is used.
>
>Does this still sound like it should work?
Reply in the App Dev forum.
Steve
steve at flyingtigerwebdesign dot com -
Combine and simplify SELECT and UPDATE sql query
foreach (BidList t in bidList)
query = "SELECT operator_id, plot_id, status FROM booking " +
"WHERE status='open' AND postcode='" + _plot + "' AND operator_id='0'" +
"ORDER BY datetime ASC;" +
"UPDATE booking SET operator_id='" + t.OperatorId + "', status='allocated' " +
"WHERE (plot_id=" + t.PlotId + " AND operator_id='0' AND status='open') LIMIT 1;";
dbObject.InsertBooking(query);
I am cleaning up my code, and came across the above SQL query. Before I make use of SQL parameters, I wanted to ask if it is possible to combine them, and if so, how?Consider making a single long query using ‘;’ as a separator:
query = "";
foreach (BidList t in bidList)
query += "UPDATE . . . ; ";
dbObject.InsertBooking(query);
Use StringBuilder for more improvements. -
Compare and update the same Column
Hi ,
SQL> select * from
v$version;
BANNER
Oracle Database 10g Express
Edition Release 10.2.0.1.0 - Product
PL/SQL Release 10.2.0.1.0 -
Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows:
Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 -
Production
I am having an issue in Updating the column in a Table.......
What i am trying to do is ...Compare 2 column and then update one of the compared column....
Table 1 Name: TEST1 _
bq. LNID \\ NEW_AN8 \\ OLD_AN8 \\ OLD_DESC \\ 2 \\ 123002 \\ 100001 \\ C2370 \\ 125846 \\ 100001 CS24 \\ 123024 \\ 100028 \\ C2392 \\ 125868 \\ 100028 CS25 \\ 123025 \\ 100036 C2393 \\ 125869 \\ 100036 CS26 123026 \\ 100116 \\ C2394 \\ 125870 \\ 100116 \\ CS
TEST2_
SZAN8 SZAN82 SZAN86 SZAT1
123,002 100,001 100,001 C
125,846 100,001 100,001 CS
123,024 100,028 100,028 C
125,868 100,028 100,028 CS
125,869 100,036 100,036 CS
123,025 100,036 100,036 C
125,870 100,116 100,116 CS
123,026 100,116 100,116 C
I wanted to update SZAN82 of TEST2 table..... based on the SZAT1 value ...
I shud be able to pick the CS type record first then the C type record and the SZAN82 value and check whether it is present in the TEST1 table if it present then I shud update the AN82 value,,
UPDATE LPLSCHEMA.LPL_F0101Z2_CUSTOMER C SET (SZAN82)=
(SELECT NEW_AN8 FROM LPL_CROSS_CUSTOMER B,LPL_F0101Z2_CUSTOMER C WHERE C.SZAT1='CS' AND B.OLD_DESC='CS'and C.szan82=B.old_an8);
I tried like tis .... i got an Error sub query more than one rows ...
Thanks in Advance !!
Ananda
Edited by: Ananda on Jan 2, 2009 6:30 PM
Edited by: Ananda on Jan 2, 2009 6:30 PM
Edited by: Ananda on Jan 2, 2009 6:34 PM
Edited by: Ananda on Jan 2, 2009 6:37 PMOr:
UPDATE LPLSCHEMA.LPL_F0101Z2_CUSTOMER C
SET SZAN82 = (
SELECT NEW_AN8
FROM LPL_CROSS_CUSTOMER B
WHERE C.SZAT1='CS'
AND B.OLD_DESC='CS'
AND C.szan82=B.old_an8
WHERE (SZAT1,szan82) IN (
SELECT 'CS',
old_an8
FROM LPL_CROSS_CUSTOMER B
WHERE B.OLD_DESC='CS'
);Or, depending on your version and table structure:
UPDATE (
SELECT C.SZAN82,
B.NEW_AN8
FROM LPL_CROSS_CUSTOMER B,
LPL_F0101Z2_CUSTOMER c
WHERE C.SZAT1='CS'
AND B.OLD_DESC='CS'
AND C.szan82=B.old_an8
SET SZAN82 = NEW_AN8
/SY.
Maybe you are looking for
-
How to color a particular cell in ALV.
hi, I have a requirement where i need to select a particular cell of a column in ALV and upon selection , i need to change the color of the selected cell. I choose the color from the dropdown toolbar created by me. plz help, thanks.
-
In need of system disks for HD repair
The machine's been a little slow lately, so I randomly decided to "verify disk" in disk utility and got this response: Verifying volume "Macintosh HD" Checking HFS Plus volume. Checking Extents Overflow file. Checking Catalog file. Checking multi-lin
-
When I use the URL hypertext function and type in mailto:<email address> and save it as a pdf. When bringing the pdf up in a smart phone and tapping on the link, it will bring up email to that person. Is there a FrameMaker version that also does this
-
What type of DVD format is recommended for recording a project from Final Cut Express? DVD-R or DVD+R?
-
Return to depot - original order from third party location to customer
Hi, A return order has been configured for materials which have originally gone from third party location to customer location. During return process however the material is coming back to the depot, not the third party location. Now while trying to