oracle10g

How can I do this dynamical update in Oracle?

时间秒杀一切 提交于 2019-12-24 22:35:33
问题 I have the model table defined like: MODEL (id NUMBER, capacity NUMBER ) and the flight table defined like: FLIGHT (flight_number NUMBER, available_seats NUMBER) I want to initialize the available_seats field in FLIGHT with the capacity number defined in MODEL each time a new row is inserted in FLIGHT table. Also I want to notify the user when the available_seats counts down to zero. How can I do this? 回答1: I would write a stored procedure called REGISTER FLIGHT, which would accept as

request.getParameter String value pass as date to java

时光怂恿深爱的人放手 提交于 2019-12-24 20:28:17
问题 In my JSP page I have a field which is date and when I getting as request.getParameter("dateVal"); gives me 15-Dec-2012 12:21. I would like to pass this value to my database procedure and insert/update into table. How can I pass the value as setDate using prepareCall to database? Thanks 回答1: First step would be using SimpleDateFormat to parse it to a fullworthy java.util.Date instance in the controller: Date date = new SimpleDateFormat("dd-MMM-yyyy HH:mm.", Locale.ENGLISH).parse(dateVal);

Oracle query to put rows at odd number adjacent to even number

只愿长相守 提交于 2019-12-24 17:42:42
问题 I need some help in formulating data in Oracle. I will give an example - I have a Table Customer with Name column. Customer Name Ashish Amit Sunny Bob. I want to get output in the format where names at odd number are adjacent to names at even number; output would be Customer Name1 Name2 Ashish Amit Sunny Bob and so on... I tried following query but it doesn't give me the required output. select name, case Mod(rownum,2) when 1 then name end col1, case Mod(rownum,2) when 0 then name end col2

ORA-00979: not a GROUP BY expression [duplicate]

梦想与她 提交于 2019-12-24 14:24:22
问题 This question already has answers here : ORA-00979 not a group by expression (8 answers) Closed 5 years ago . Why does this work SELECT DISTINCT FIRSTNAME, LASTNAME FROM books, CUSTOMERS, orders, orderitems WHERE STATE IN('FL ', 'GA') GROUP BY orders.order#, firstname, lastname HAVING SUM(retail*quantity) > 80 but when firstname, lastname is removed from group by it doesn't? ORA-00979: not a GROUP BY expression 回答1: In that case where firstname, lastname are removed from the group by , you

Oracle - Recursive query using START WITH… CONNECTED BY…?

余生长醉 提交于 2019-12-24 13:25:59
问题 Say i have the following table, using Oracle 10g ARTIFACT_LABEL | DEPENDANT_ON test1 | abc1 test1 | abc2 test1 | abc3 abc3 | xyz1 abc4 | xyz2 and i want to generate a tree structure knowing what test1 depends on, (so i want to return, abc1, abc2, abc3, xyz1 ) ive been using the following: SELECT ARTIFACT_LABEL, DEPENDANT_ON FROM DEPENDANCIES START WITH ARTIFACT_LABEL = 'test1' CONNECT BY NOCYCLE PRIOR ARTIFACT_LABEL = DEPENDANT_ON But this isnt working (it seems to just be doing a SELECT

Oracle - unique Listagg values

微笑、不失礼 提交于 2019-12-24 12:54:40
问题 I am new to using Listagg. The following script works in respect of it gives me a list of values but, the list duplicates the values. Is it possible to use Listagg to return only a unique list of values. I am using oracle 10g. select distinct ds.catnr,ds.planqty, ds.ordnr, ds.posnr, ds.segnr, listagg(case when not li.paco is null then (select unique max(li1.paco) from leos_item li1 where li.av_part_no = li1.av_part_no) end, ', ') within group (order by pd.part_no) inq_no from oes_delsegview

How to bind horizontal values of a table to a vertical values of another table in oracle database

不打扰是莪最后的温柔 提交于 2019-12-24 12:50:57
问题 i have 2 tables . The columns start with attributes are change based on department. the description of attributes are here My requirement is to get the values of each attributes with its primary key based on the department as table bellow. Honestly i am stuck on this problem in my program. I have no permission to change the tables and there is no common unique key column.i would appreciate if anyone could provide me a suggestion. 回答1: with a as ( select a.*, row_number() over (partition by

Adding constraints using subquery from other table

我们两清 提交于 2019-12-24 12:38:12
问题 I have 2 tables: MESSAGES ( ID(pk), SENDER ) RECIEVERS ( ID references MESSAGE(ID), RECIEVER, pk(ID, RECIEVER) ) Here's the deal: A message can have only one sender. DONE A message can have multiple receivers, but a receiver cannot receive the same message more than once. DONE A sender cannot send a message to himself. How do I do this part? I tried this: update table RECIEVERS add constraint "RECIEVERS_CK_SELF_SEND" ( RECIEVER not in ( select SENDER from MESSAGES where MESSAGE.ID=RECIEVER.ID

oracle external table get selected columns from the file

偶尔善良 提交于 2019-12-24 12:13:18
问题 I'm having problems with oracle external table I have a text file will 50+ unnecessary columns, Now I want to select a few columns from the text file to my external table. create table tmpdc_ticket( SERVICE_ID CHAR(144), SERVICE_TYPE CHAR(50), CUSTOMER_NAME CHAR(200), TELEPHONE_NO CHAR(144), ACCOUNT_NUMBER CHAR(144), FAULT_STATUS CHAR(50), BUSINESS_GROUP CHAR(100) ) organization external( type oracle_loader default directory sample_directory access parameters( records delimited by newline

Understanding behavior of remainder() function in Oracle

自古美人都是妖i 提交于 2019-12-24 12:13:16
问题 According to Oracle documentation for the remainder(n2,n1) function (https://docs.oracle.com/cd/B19306_01/server.102/b14200/functions133.htm), the remainder(n2,n1) function evaluates to = n2 - n1 * N where N = ROUND(n2/n1) and n1 != 0. So, I would expect remainder(10,4) to return -2 using the above documented method of calculating the remainder as shown below: REMAINDER(10,4) =10 - 4 * N where N = ROUND(10/4) =10 - 4 * 3 since ROUND(10/4) = 3 =10 - 12 =-2 However, running remainder(10,4) in