oracle11g

How do you select only the maximum version of a list of documents that have different versions in SQL?

两盒软妹~` 提交于 2019-12-20 06:49:09
问题 I have a database table that looks like this: | ID | TITLE | VERSION | | 1 | file1 | 1 | | 2 | file2 | 1 | | 3 | file1 | 2 | | 4 | file2 | 2 | I need an SQL query that will return rows 3 and 4 because they are the latest versions of file1 and file 2. If I run the query on a table that looks like this: | ID | TITLE | VERSION | | 1 | file1 | 1 | | 2 | file2 | 1 | | 3 | file1 | 2 | | 4 | file2 | 2 | | 5 | file3 | 1 | It should return rows 3,4 and 5 because "file3" version1 is the latest version

Query works on Oracle 11g but fails on Oracle 8i

好久不见. 提交于 2019-12-20 06:29:25
问题 I am running this query in Oracle 11g with no problem: select (case when seqnum = 1 then '1' when seqnum = cnt then '0' end) as value1, (case when seqnum = 1 then t.BEGIN_DT when seqnum = cnt then t.END_DT end) as TIME1, t4.UNIT1 || '.SUBBATCH_TRIGGER' TAG from (select t.*, row_number() over(partition by t.BATCH_ID, t.plant_unit, t3.ID2 order by t.BEGIN_DT) as seqnum, count(*) over(partition by t.BATCH_ID, t.plant_unit, t3.ID2) as cnt from SCH2.tb_pg_unit_stap t join (select ID1,batch_id from

Need to trim blank space in oracle

允我心安 提交于 2019-12-20 06:06:08
问题 Unable to trim blank space in below data in my table. column data type is VARCHAR2(650 CHAR). I tried trim function to eliminate blank space. but that is not working for me. DATA in my table: 'xxxxxxxxxx yyyyyyyyy - 12/7/14 - 12/13/14 ' 'xxxxxxxxxx yyyyyyyyy - 12/7/14 - 12/13/14 ' 'xxxxxxxxxx yyyyyyyyy - 12/7/14 - 12/13/14 ' I want trim the data like below 'xxxxxxxxxx yyyyyyyyy - 12/7/14 - 12/13/14' 'xxxxxxxxxx yyyyyyyyy - 12/7/14 - 12/13/14' 'xxxxxxxxxx yyyyyyyyy - 12/7/14 - 12/13/14' Could

PLS-00394: Wrong number of values in the INTO list of a fetch statement

流过昼夜 提交于 2019-12-20 06:02:06
问题 This is my attempt in creating a cursor in a stored procedure --Second Stored Procedure-- CREATE OR REPLACE PROCEDURE sp_GetDiscountedRate (DiscountCode IN VARCHAR2,Percentage IN NUMBER, ReserveDate IN DATE) IS --Code declaration section-- --variables to store column values returned from select into pPassengerID VARCHAR2(10); pFirst VARCHAR2(20); pMiddle VARCHAR2(20); pLast VARCHAR2(20); pPassengerType CHAR (1); uUSMilitaryID VARCHAR (8); uMilitaryBranch VARCHAR2 (20); uMilitaryDiscountCode

How to get the most frequent value SQL

ぐ巨炮叔叔 提交于 2019-12-20 05:41:17
问题 I have a table Orders(id_trip, id_order), table Trip(id_hotel, id_bus, id_type_of_trip) and table Hotel(id_hotel, name). I would like to get name of the most frequent hotel in table Orders. SELECT hotel.name from Orders JOIN Trip on Orders.id_trip = Trip.id_hotel JOIN hotel on trip.id_hotel = hotel.id_hotel FROM (SELECT hotel.name, rank() over (order by cnt desc) rnk FROM (SELECT hotel.name, count(*) cnt FROM Orders GROUP BY hotel.name)) WHERE rnk = 1; 回答1: The "most frequently occurring

Oracle date pattern to java date pattern

 ̄綄美尐妖づ 提交于 2019-12-20 05:30:51
问题 Is there any utility that returns java.text.SimpleDateFormat pattern from Oracle to_char format pattern? create or replace type type_sample as object ( f_id number, f_name varchar2(100), f_start_date date, f_end_date date ) / SET SERVEROUTPUT ON DECLARE xmltype1 SYS.XMLType; message type_sample; BEGIN message := new type_sample(1, 'Manohar', current_date, sysdate); xmltype1 := XMLtype.createXML(message); DBMS_OUTPUT.PUT_LINE('out_errm : '|| xmltype1.getStringVal()); END; / <TYPE_SAMPLE><F_ID

Flask-sqalchemy and oracle database id not autoincrement

半城伤御伤魂 提交于 2019-12-20 04:58:26
问题 I want to make a new table in my database (Oracle 11g but the Express Edition for Ubuntu 16.04) using Python and Flask framework with the SQLAlchemy module. The first field of the table it's and ID, is an Integer field and I want it to autoincrement, but Oracle database don't support the autoincrement. I have a form to add a new comment, but when I try to add a new record it reports a error: sqlalchemy.exc.IntegrityError: (cx_Oracle.IntegrityError) ORA-01400: cannot insert NULL into ("WIKTOR"

oracle sql if condition then select statement1 else select statement2

人走茶凉 提交于 2019-12-20 04:53:52
问题 I have parameter :prmtr and what I wanted is to use a select statement based on the parameter input. I tried this: if :prmtr= 'A' then select * from tblA; else select * from tblB; end if; But it wont work. Is there some other way to do this? 回答1: You may try something like this with a CURSOR variable and PRINT command. This works in SQL* plus and in SQL developer or TOAD when run as script. VARIABLE prmtr VARCHAR2 EXEC :PRMTR := 'A' -- SET values of parameter VARIABLE x refcursor -- a cursor

Remove Unwanted/Extra Data in SQLPLUS

若如初见. 提交于 2019-12-20 04:15:55
问题 I am running a file via batch file Batch File: sqlplus admin/admin@SERVER @abc.sql > output.txt SQL File abc.sql: set PAGESIZE 1000 set LINESIZE 550 set echo off set head off set FEEDBACK OFF select * from S_ABC exit; Output.txt: Connected To: Oracle Database 11g................................ . . . DATA . . Disconnected from Oracle Database 11g ....... . . Please help me remove the extra data, in the starting and end of output.txt file. 回答1: -S seems to be what you're looking for; sqlplus

quartz 2.2.1+jboss EAP 6.4 ClassNotFoundException oracle.sql.BLOB

廉价感情. 提交于 2019-12-20 04:13:18
问题 I'm trying to build a quartz scheduler ejb app and have it deployed on JBOSS EAP 6.4. Additionally, I'm trying to do so using quartz JDBC jobstore using an Oracle 11g database. Now, the problem is that whenever I try to schedule a job, I get this exception : 18:45:01,024 ERROR [org.jboss.msc.service.fail] (ServerService Thread Pool -- 50) MSC000001: Failed to start service jboss.deployment.unit."com.hp.heimdall.jar".component.QuartzBootstraper.START: org.jboss.msc.service.StartException in