Need help in writing an update statement
Hi,
my requirement is as follows..
I have a simple table with just three fields in it
Field_1 Field_2 Field_3
A 1 2
A 0 5
A 2 1
A 3 4
B 1 3
C 2 3
given a value of field_1 i need to select a row that has min(field_2)
in this case the 2nd row from the above table if the value given is "A".
any help will be greatly appreciated.
thanks.
Your subject says "update" but your requirement was a "select" statement.
Don't say I never give any options:
sql>select * from x;
F FIELD_2 FIELD_3
A 1 2
A 0 5
A 2 1
A 3 4
B 1 3
C 2 3
6 rows selected.
sql>select *
2 from x t1
3 where field_1 = 'A'
4 and field_2 = (select min(t2.field_2)
5 from x t2
6 where t2.field_1 = t1.field_1
7 group by t2.field_1);
F FIELD_2 FIELD_3
A 0 5
1 row selected.
sql>select *
2 from x
3 where (field_1, field_2) in (select field_1, min(field_2)
4 from x
5 where field_1 = 'A'
6 group by field_1);
F FIELD_2 FIELD_3
A 0 5
1 row selected.
sql>select field_1, field_2, field_3
2 from (select x.*, row_number() over (order by field_2) rn
3 from x
4 where field_1 = 'A')
5 where rn = 1;
F FIELD_2 FIELD_3
A 0 5
1 row selected.
sql>select *
2 from (select *
3 from x
4 where field_1 = 'A'
5 order by field_2)
6 where rownum = 1;
F FIELD_2 FIELD_3
A 0 5
1 row selected.
Similar Messages
-
Need help in writing data from JSP to excel
Hi ,
I need help in writing the data from JSP to excel.I somehow able to retrieve the data into excel but unable to get the required format.
For eg: The amount should be displayed in 0.00 format .when i am exporting it to excel it is displaying as 0 :( .
I am using the following code in JSP.
"out.print(amt + '\t');"
Would like to know if there is any otherway where in i can get my requirement.
Thanks
TomHi,
Try using format part of the JSTL tag libs.
Syntax :
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<fmt:formatNumber value="40" pattern="$#,##0.00"/>
I need help in writing the data from JSP to excel.I
somehow able to retrieve the data into excelHow do u convert the jsp to excel?
One way to convert the jsp page to excel, is to render it as an excel appl instead of html. Set the content type of the response to application/ms-excel.
response.setContentType("application/ms-excel")Hope this Helps.... -
Need help for writing extract program
hi
i need help for writing extract program to retriew data from legacy system.
i already developed bdc programs for me31k and me21.
my requirement is to write extract program s for those t.codes.
to retriew data from legacy system and stored in flat file.i need help with a java program. it is a program that allows the user to enter a student's GPA, number of extracurricular activities, and number of service activities. The user can not enter a gpa above 4.0 or below 0. The user can not enter a negative number for the number of both activities. If the student meets the following criteria: 1) GPA of 3.8 or above and at least one extracurricular activity and one service activity, 2) GPA below 3.8 but at least 3.4 and a total of at least three extracurricular and service activities, 3) GPA below 3.4 but at least 3.0 and at least two extracurricular activities and three service activities, the message "Scholarship candidate" should display. If the student does not meet the criteria above, then the message"not a candidate" should display. Can you help me, please?
You haven't posted ANY 'java program' for us to help with.
The forum is NOT a coding service. It is to help you with YOUR code.
Post the code you have written and SHOW us (don't just tell us) how you compile it and execute it and the results you get. Then we can help you with any problems you are are having.
If you need help understanding just what the program should be doing you need to ask your instructor to clarify the assignment. -
Hi i need help on BAPI to Update the ADRT & ADR6 tables
hi,
i need help on BAPI to Update the ADRT & ADR6 tables
these are the fields to be updated
ADRT-Remark Table
ADR6-SMTP_ADDR
ADR6-DFT_RECEIV
Please guide me what parameters to be passed to update
ADR6 & ADRT tablesLook at this function Group
<b>BUBA_3 SAP BP: External BAPI Function Modules </b>
BAPI_BUPA_ADDRESS_ADD SAP BP, BAPI: Add Address
BAPI_BUPA_ADDRESS_CHANGE SAP BP, BAPI: Change Address
BAPI_BUPA_ADDRESS_GET_NUMBERS SAP BP, BAPI: Read Address Numbers
BAPI_BUPA_ADDRESS_GETDETAIL SAP BP, BAPI: Read Address
BAPI_BUPA_ADDRESS_REMOVE SAP BP, BAPI: Delete Address
BAPI_BUPA_ADDRESSES_GET SAP BP, BAPI: Determine All Addresses
BAPI_BUPR_CONTP_ADDR_ADD SAP BP, BAPI: Add Contact Person Relationship Address
BAPI_BUPR_CONTP_ADDR_CHANGE SAP BP, BAPI: Change Contact Person Relationship Address
BAPI_BUPR_CONTP_ADDR_GETDETAIL SAP BP, BAPI: Read Contact Person Relationship Addresses
BAPI_BUPR_CONTP_ADDR_REMOVE SAP BP, BAPI: Delete Contact Person Relationship Address
BAPI_BUPR_CONTP_ADDRESSES_GET SAP BP, BAPI: Read Contact Person Relationship Addresses
BAPI_BUPR_EMPLO_ADDR_ADD SAP BP, BAPI: Add Employee Relationship Address
BAPI_BUPR_EMPLO_ADDR_CHANGE SAP BP, BAPI: Change Employee Relationship Address
BAPI_BUPR_EMPLO_ADDR_GETDETAIL SAP BP, BAPI: Read Employee Relationship Address
BAPI_BUPR_EMPLO_ADDR_REMOVE SAP BP, BAPI: Delete Employee Relationship Address
BAPI_BUPR_EMPLO_ADDRESSES_GET SAP BP, BAPI: Read Contact Person Relationship Addresses
Look also at OSS <a href="https://service.sap.com/sap/support/notes/306275">Note 306275 - Transferring address data</a>
Regards -
Hi, I need help on how to update software for my ipad1, can someone help me?
The iPad 1 can not be upgraded beyond 5.1.1. If you haven't upgraded to iOS 5.1.1, see the info below.
If your iDevice is using a version of iOS lower than 5, you will need to use iTunes on your syncing computer to perform the upgrade. Use the Apple link below as a guide for the upgrade.
http://support.apple.com/kb/HT4972
Also read the instructions from the section entitled "Update your device using iTunes" at the link below.
http://support.apple.com/kb/HT4623
Information regarding transferring purchases from your iDevice to iTunes on your syncing computer can be found at the link below.
http://support.apple.com/kb/ht1848 -
Need help in writing a vbscript
Hi,
I need help in wring a vbscript. I have serached for the vbscript on the net, but could not find any.
I need to add a file to an msi using vbscript. - That's the requirement.
For this I have done the following with the help of vbscript.
1. With the insert statement I inserted a new copmonent in the FeatureComponent Table.
2. Now the next thing I did is, I inserted a new row in the File table using insert statement again. The file is uncompressed.
3. Since the file is a non-version file I also added a row in the MSIFileHash table.
4. Also, now added the Component in the component table.
After doing this I am able to see the chnages in the mst, however whrn I try to install it I get an error 2725 (Invalid database tables).
Can somebody please post a vbscript which can add a file to an msi?Hi All,
Thanks for all your responses.
Yes, It is not so easy. I never said it was. Thanks for pointing out Orca. We use Orca on a daily basis.
What exactly I am looking at, is this.
We have some standard applications which needs to be repackaged every month. The repackaging process is same and does not change at least for these packages. So I was actually looking at automating these things.
What I did so far.
First we have created an object for Windows installer. I have then taken a copy of the original msi and then opened the database of this temporary msi database in transact mode. Once the database is opened we can use select, insert, update
and delete statements to update the database.
I could successfully add a registry to the msi. The component was also added successfully to the component table. I also could make changes to the Property table.
The tricky part comes with the addition of file to the file table.
The addition of file requires the following steps.
1. Add a new row to the file table. This can be done with the Insert statement.
2. We then need to associate the file to a new component or any other component already existing in the msi. In my case I am creating a new component.
3. We then have to associate this components to a feature in the FeatureComponents table.
4. Since the file I am adding is a non-versioned file, a new row also has to be added to the MSIFILEHASH table.
I could see the changes that I have done using the mst. But when I try to install the msi with the mst, I get the error 2725. I checked everything. All the other steps except for the file addition works fine.
To check whether I am indeed right, I have did this.
Skipped the file addition part to the msi. Every other change that I make works and I am able to install the msi with the mst successfully.
For obvious security reasons I will not be able to share the vbscript with you. If you guys think, that this is not a right forum for this question, please let me know the right forum. I have been stuck with this issue from the past 6 months. Any help would
really be appreciated. -
Writing an update statement in oracle forms 9i
Hi ,
I have a problem situation in which
I am fetching values from a cursor and a recod group into two data block items text box and combo box respectively .
Both the data is fetched from different tables .
Now based on the selection from combo box I have to update the selected value in another table by writing an update statemet .
I have created a button and on the trigger event of when button pressed I wrote a simple update statement but it's not working that way .
Kindly help me how to write manual update statements in oracle forms 9i
I can't used the update buil in of forms as I want to update in a table which is not mentioned in the property pallete of data block
please helpI just wrote a procedure
PROCEDURE update_current IS
BEGIN
update table abc set xculumn= :block_name.item_name2 where ycolumn = :block_name.item_name1 ;
commit;
and I called the procedure from a when button pressed trigger
it gave an error invalid identifier abc ( which is table name)
pls help
I am trying to do it with form_ddl(update_query)
but here I am facing another problem
I have update_query = 'update table abc set xculumn= ' || :block_name.item_name2 || 'where ycolumn = '||:block_name.item_name1
now since xculumn and y column are varchar type so I suppose while preparing the query I have to concatenate single quotes ( ' ) at the start and end
but i am facing problems in doing so
please tell me an alternative way or how to concatenate single quotes in the above update_query variable -
Help with parsing an UPDATE statement
I am stuck and need help! The teacher has not gone over parsing with us
and it is not on his scheduled topics list. But, I am a person that likes to
scope out and learn new things. For our final project, we have to allow
updates, delete and inserts into the 5 main tables of the Premiere Products
database. I have done everything except for the updates. I can achieve
the updates of the entities by pretty much hardcoding them and that is
okay by the teacher, but I want to learn about parsing because Barbara
from this site mentioned this to me.
This is what I was able to write and I am getting errors:
CREATE OR REPLACE PROCEDURE updatecust_proc (
v_cust_num IN customera.cust_num%TYPE,
v_attributetoupdate VARCHAR2 ,
v_updatedvalue VARCHAR2 )
AS
e_invalidcustnum_error EXCEPTION;
BEGIN
v_isvalidcustnum := iscust(v_cust_num);
IF (v_isvalidcustnum = FALSE) THEN
RAISE e_invalidcustnum_error;
END IF;
PARSE(
'UPDATE customer
SET' | | v_attributetoupdate | | '=' | | v_updatedvalue | |
'WHERE cust_num =' | | v_cust_num
END;
EXCEPTION
WHEN e_invalidcustnum_error THEN
DBMS_OUTPUT.PUT_LINE('Cannot be updated. Invalid customer number');
END;
Any help would be useful. I went to the Oracle help site but their examples are a little too complicated for me to understand, plus, I am not using any C code.
Thanks in advance!
BobNow we are getting somewhere. Identifier 'PARSE' must be declared.
I again used the 'Search' link just above the forum posts and entered 'dbms_sql.parse' and got a short list of hits (as I suggested in my previous reply).
There is one with Barbara's name on it. It shows exactly how to do what you are trying to do. In particular note her code:
DBMS_SQL.PARSE
(cursor_name,
'UPDATE client SET '
| | v_column
| | ' = ' | | '''' | | v_new_data | | ''''
| | ' WHERE account_id = '
| | v_account_id,
DBMS_SQL.NATIVE);
Compare her PARSE statement to yours and you will see some major differences. The PARSE procedure is defined in the DBMS_SQL package and must be reference by DBMS_SQL.PARSE as Barbara shows.
In addition to dynamic SQL using the DBMS_SQL package Oracle 8i also supports the EXEC IMMEDIATE statement.
All of Oracle's documentation is available online via the 'Documentation' link on the left side of the OTN home page.
The 'Supplied PL/SQL Packages Reference' has a chapter for each package (including DBMS_SQL) and describes the procedures/functions in the package and how to use them.
The 'Application Developers Guide - Fundamentals' has chapters on 'processing SQL statements' and 'dynamic SQL' that go into some detail on performing dynamic sql.
Yes, Barbara's code uses a CURSOR. The DBMS_SQl package requires it and so does your code. Almost all SQL uses a CURSOR either implicitly or explicitly.
My comments are not, and were not, directed at you personally so I hope you don't take them that way.
Your latest reply has a lot of useful information in it.
1. 19/1 PLS-00201: identifier 'PARSE' must be declared. This is the explicit error message we need to help someone. We don't have to guess which error they are talking about. We can look it up in the MESSAGES manual if necessary. When someone says 'I get an error', or 'I get a PARSE error' we can only guess which error they are talking about.
In your reply you state that you looked at Barbara's code, she uses a cursor and you don't need a cursor. That is very useful information to someone trying to help you because it tells us two things: you are trying to find the answer for yourself (a lot of people just want someone to write the code for them) and it shows that you haven't made the connection between Barbara's example (which shows EXACTLY what you need to do) and your own code.
This is a public forum and I have found it useful to keep repeating certain suggestions.
For whatever reason many people still do not seem to realize that:
1. ALL of Oracle's documentation is available on-line via the 'Documentation' link on the left side of the OTN main page.
2. You can purchase (for about $50) a CD-ROM that has all of the Oracle documentation on it in both PDF and HTML format.
3. The 'search' link just above each discussion forum allows one to search any or all forums for topics, users, etc.
The above resources should be used by everyone.
Good luck!
null -
HELP! With parsing Update statement
I am stuck and need help! The teacher has not gone over parsing with us and it is not on his scheduled topics list. But, I am a person that likes to scope out and learn new things. For our final project, we have to allow updates, delete and inserts into the 5 main tables of the Premiere Products database. I have done everything except for the updates. I can achieve the updates of the entities by pretty much hardcoding them and that is okay by the teacher, but I want to learn about parsing because Barbara from this site mentioned this to me.
This is what I was able to write and I am getting errors:
CREATE OR REPLACE PROCEDURE updatecust_proc (
v_cust_num IN customera.cust_num%TYPE,
v_attributetoupdate VARCHAR2 ,
v_updatedvalue VARCHAR2 )
AS
e_invalidcustnum_error EXCEPTION;
BEGIN
v_isvalidcustnum := iscust(v_cust_num);
IF (v_isvalidcustnum = FALSE) THEN
RAISE e_invalidcustnum_error;
END IF;
PARSE(
'UPDATE customer
SET' | | v_attributetoupdate | | '=' | | v_updatedvalue | |
'WHERE cust_num =' | | v_cust_num
END;
EXCEPTION
WHEN e_invalidcustnum_error THEN
DBMS_OUTPUT.PUT_LINE('Cannot be updated. Invalid customer number');
END;
Any help would be useful. I went to the Oracle help site but their examples are a little too complicated for me to understand, plus, I am not using any C code.
Thanks in advance!
BobI will try putting in spaces to the areas that you mentioned to me. Thanks!
I will try to explain the function just in case some other poeple don't understand what I am trying to do.
This procedure is supposed to update the CUSTOMER entity. This entity has 7 attributes and I don't want to write out 7 UPDATE statements to changes a value. Instead, I want the name of the attribute to be passed to the proceudre so that the UPDATE statement can know which attribute to use. Barbara mentioned something about parsing and I attempted to try it out, but I am getting errors. Can someone help me with the procedure. BTW, function iscust() returns TRUE if the customer number is valid, otherwise, it returns false.
Thanks,
Bob -
Hi,
Please help in writing a UDF for these fields in mapping, which I need for the object Iu2019m doing currently.
The fields are like this:
1) batch_no = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/5000)+1",
2) lot_id = "TRUNC((GetMaxObjid('x_txn_sap_parts')-POWER(2,28))/500)+1",
3) How to use JDBC connection factory class in the UDF.
Some logic I can provide which I know i.e. Power (2, 28) means 2 to the power of 28 (2 multiplied 28 times), Trunc means truncate, X_TXN_SAP_Parts is a database table.The Target fields are Batch_no, lot_id & Objid.Actually, objid is mapped initially to a source field i.e. Object ID and in this function it is only being used for the calculation of the batch_no.
Thanks in Advance,
Sreedhar.Hi,
Following with my query I've tried to use this code but still I'm unable to execute the mapping.
import java.util.*;
import com.sap.aii.mapping.lookup.*;
import com.sap.aii.mapping.lookup.*;
DataBaseAccessor accessor = null;
DataBaseResult JDBCOutPayload = null;
String BusinessSystem="clarify_dev_bizsys";
//give your business system having channel name
String CommunicationChannel="JDBC_TO_CDEV";
//give your channel name
String InputPayload= " select X_TXN_PRE_SITE_XFACE.nextval from dual;";
//give your sql query
try {
Channel channel =
LookupService.getChannel(BusinessSystem,CommunicationChannel);
accessor = LookupService.getDataBaseAccessor(channel);
DataBaseResult resultSet = accessor.execute(InputPayload);
for(Iterator rows = resultSet.getRows();rows.hasNext();){
Map rowMap = (Map)rows.next();
Object cValue = rowMap.get("batchno");
//field name of field required , as in database
catch (Exception e) {}
finally {
if (accessor != null)
accessor.close();
result.addValue((String)cValue);
--> I don't know what are the parameters to be used and how to be used in the UDF because this is the first time I'm writing a UDF.
--> The problem in using this query is that both OBJID & BatchNo. are on the target side and the value for the OBJID is retrieved by a SELECT query from the database.
Kindly help me how to resolve this query of mine.
Thanks in Advance.
Sreedhar. -
Need help with writing a query with dynamic FROM clause
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'Simply sticking the later query in the first query does not work.
Any pointers will be appreciated.
Thanks
rogers42Hi,
rogers42 wrote:
Hi Folks,
I need help with an query that should generate the "FROM" clause dynamically.
My main query is as follows
select DT_SKEY, count(*)
from *???*
where DT_SKEY between 20110601 and 20110719
group by DT_SKEY
having count(*) = 0
order by 1; The "from" clause of the above query should be generated as below
select 'Schema_Name'||'.'||TABLE_NAME
from dba_tables
where OWNER = 'Schema_Name'
Remember that anything inside quotes is case-sensitive. Is the owner really "Schema_Name" with a capital S and a capital N, and 8 lower-case letters?
Simply sticking the later query in the first query does not work.Right; the table name must be given when you compile the query. It's not an expression that you can generate in the query itself.
Any pointers will be appreciated.In SQL*Plus, you can do something like the query bleow.
Say you want to count the rows in scott.emp, but you're not certain that the name is emp; it could be emp_2011 or emp_august, or anything else that starts with e. (And the name could change every day, so you can't just look it up now and hard-code it in a query that you want to run in the future.)
Typically, how dynamic SQL works is that some code (such as a preliminary query) gets some of the information you need to write the query first, and you use that information in a SQL statement that is compiled and run after that. For example:
-- Preliminary Query:
COLUMN my_table_name_col NEW_VALUE my_table_name
SELECT table_name AS my_table_name_col
FROM all_tables
WHERE owner = 'SCOTT'
AND table_name LIKE 'E%';
-- Main Query:
SELECT COUNT (*) AS cnt
FROM scott.&my_table_name
;This assumes that the preliminary query will find exactly one row; that is, it assumes that SCOTT has exactly one table whose name starts with E. Could you have 0 tables in the schema, or more than 1? If so, what results would you want? Give a concrete example, preferably suing commonly available tables (like those in the SCOTT schema) so that the poepl who want to help you can re-create the problem and test their ideas.
Edited by: Frank Kulash on Aug 11, 2011 2:30 PM -
Need helping in writing query for finding percentage of duration
Can any one please help in writing query for this.
The table is like this :-
ID Region Month Duration
I1 R1 Jan 80
I2 R2 Jan 70
I3 R1 Jan 70
I4 R3 Jan 40
I5 R1 Feb 80
I6 R2 Feb 30
I7 R3 Mar 100
I want to write a query to find
% of duration for each and every region against each and every month.
Please help in solving this query. I am in urgent need of this.
Thanks in advance.I also have to do in MS Access 2003You also have to ask into an other forum since here it's an Oracle forum, to try to find Oracle solution.
Nicolas. -
NEED HELP WITH IOS 6 UPDATE!!! PLEASE.
I have an 8GB iPhone. The iOS 6 update says that I need 2.4GB available to update. I deleted all of my apps, 200 pictures out of 400 plus videos. It says only 5.1GB are used but it won't let me update the iOS 6. Help me please?
jayfram wrote:
I am having the exact same problem. Can't upgrade via the phone, even with a wifi connection - says I need 2.4 gb of storage, although the software is only 500 mb. I'm not about to delete everything on my phone just to update the OS.
So plug the phone into the computer that it normally syncs with and update via iTunes. -
i need help to update my ipod touch 2.2.1 somebody can help me
What is the model number on the back?
What is the shape of the antennae cover and compare it with:
Identifying iPod models
"The iPod touch (2nd generation) can be distinguished from previous iPod touch models by its contoured design and oval shaped antennae cover in the back upper left corner." -
Need help. Activation after update iOS 5.1 is not working!!
Need Help in activating my iphone 4 after update iOS 5.1. My phone was been neverlock and i used its before update without any activations. After update i can't turn on my phone!!! On the display have message "SIM not valid. Only compatible SIM cards from a supported carrier may be used to activate iPhone. Please insert the SIM card that came with your iPhone or visit a supported carrier's store to receive replacement SIM card". But i haven't any sim cards. Only the sim card from my operator "Kyivstar" (Ukraine)... What should i do?!
p.s.: sorry for my bad english, but i live in Ukraine, and we haven't autorized service center of Apple in our country. help me please.You have been using a phone that has been hacked to allow it to be used on your network. Upgrading your phone's software has relocked your phone to the original carrier.
You will not be able to use your phone again unless the ORIGINAL carrier offers unlocking. Many don't, and many who DO offer unlocking, will not unlock unless the phone has active service with the carrier in the appropriate country.
You will need to find out who the carrier your phone is locked to is, and see if that carrier unlocks the phone. It is very likely you will need to buy a new phone.
Maybe you are looking for
-
Problems to download folios in the content viewer and in the app viewer
Hi there!! I am having a problem and want to know if somebody can help me. Since a few days, in 9 folios whose particular being very heavy (170-350 MB) can not be updated on the Ipad. On our test Ipads appears a message that the server is not respond
-
Hi, I'm trying to create and start a JCoIDoc.Server on a Web Application Server 700 system. Because I could not find the required classes in the trfc.jar archive on the server I downloaded and packaged the required java connector classes sapidoc.jar
-
Commission Agent in Sales Order
D/ Friends, 1. Pl advice how to configure Commission Agent (Forwarding Agent) in the Sales Order. 2. Weu2019ve to give commission to the Agent, so which condition type shd be used for that purpose & how Commission Agent will get credited with the com
-
IPod Video Software 1.2 - Speaker Option - Jobs Said "Is Already Out"
In the recent Jobs Keynote of the Mac Mini Intel and iPod Hifi etc. Jobs said that the update to add speaker option to video ipod menus is already out, but when you go to http://www.apple.com/ipod/download it is still 1.1, updater 2006-01-10 iPod Vid
-
Is possible to make LIRC control thunar? (like the arrow keys do: move from 1 file to the next). I also want the back button to up 1 directory. I would also like to make one of my remote buttons send "alt tab". thanks in advance Last edited by Dethre