oracle-sqldeveloper

Order by listagg is not ascending according the list data

巧了我就是萌 提交于 2019-12-13 04:28:54
问题 i have problem how to ascending the data according the list. For example, i have a table field names mhn.kod_urusan. i want to show the result according the list that i type.The problem is the data not follow what i type in the list. "and mhn.kod_urusan in ('PBPTG','PBMT')" This is my query:- select LISTAGG (upper(aa.kod_urusan), ', ') within Group (order by aa.kod_urusan asc) as daerah from (select distinct mhn.kod_urusan,kc.nama nm from mohon mhn, kod_urusan ku, kod_caw kc where mhn.kod

Syntax error when trying to insert multiple rows in SQL?

人盡茶涼 提交于 2019-12-13 04:25:03
问题 I am trying to store multiple values into a table with two columns in a single command. Here is my command, INSERT INTO CATEGORY VALUES('BUS','BUSINESS'), ('CHN', 'CHILDREN'), ('COK', 'COOKING'), ('COM', 'COMPUTER'), ('FAL', 'FAMILY LIFE'), ('FIT', 'FITNESS'), ('SEH', 'SELF HELP'), ('LIT', 'LITERATURE'); I get a red underline after my first pair of values where I have the comma. What am I doing wrong? 回答1: I would start by listing columns: INSERT INTO CATEGORY (<colname1>, <colname2) VALUES (

TimeZone Time/Date Formats with Oracle and .NET

佐手、 提交于 2019-12-13 03:59:20
问题 I am new to Oracle and hope someone can clarify this scenario for me. I have written a very large query that returns a set of dates with it (Oracle 10g). In SQL Developer, these dates appear in DD-MON-YY format (ex: '12-MAY-12'). The field's data type in SQL Developer shows it is a Date type, and the Simple radio button is checked. When I run this query in SQL Developer, I get a date that looks like this: 11-MAY-12 I use this query in an assembly that is part of a C# web service. Someone on

Query date and specific time in the where clause 3

雨燕双飞 提交于 2019-12-13 03:46:22
问题 How can I get 3rd shift data from the where clause. I'm using current date, but even with what I don't get any resutls. I'm looking to see 3rd shift sale from time range 9pm to 5am ( Next Day ). SELECT WORK_CENTER, SUM(SALES) AS SALES FROM ZME_SALES WHERE DATE_TIME_START >=sys_extract_utc(cast(trunc(current_date) + 21/24 as time stamp with time zone)) AND DATE_TIME_START < sys_extract_utc(cast(trunc(current_date)+1 + 5/24 as timestamp with time zone)) Here's my expected results. SHIFT WORK

SQL Developer Special Chars

孤人 提交于 2019-12-13 03:24:12
问题 I am having problems with an Oracle Database and the ASCII char encoding. I'm trying to make Update sentences on Varchar2() columns with strings that contains special characters like á, é, í, ó, ú, (spanish) etc. Each time i recover the data from that column, as for example, instead of seeing 'ó', i got '髇' or '髇'. I'm writing Update sentences like: UPDATE TABLE_1 SET DESCRIPTION = 'THIS IS A TEXT WITH SPECIAL CHAR ó ÉND' WHERE ID = '1'; and when i do: SELECT ID ||' | '|| DESCRIPTION FROM

how select max(salary) of employee each department with employee_id and emp_name

白昼怎懂夜的黑 提交于 2019-12-13 03:21:48
问题 I want to select emp_id,department_id,max(salary) each department but I use group by department_id and it has error ora-00979 3 column is in the same table(employees) How can I fix it select department_id, employee_id as "ID",first_name || ' ' || last_name as "Name",max(salary)as "SALARY" from EMPLOYEES group by department_id order by department_id; 回答1: You can use keep : select department_id, max(employee_id) keep (dense_rank first order by salary desc) as "ID", max(first_name || ' ' ||

Can I write the stored procedure with table as output parameter as a single query in Oracle?

混江龙づ霸主 提交于 2019-12-13 02:00:23
问题 I have a C# method which takes a SQL string statement and saves the data into xml format. public XmlDocument GetDBRequestXml(String sql) { } I have a stored procedure with output parameter as table. Is there any way to pass this stored procedure as an executable single SQL statement in the above C# method? Can somebody please help me on this!!! create or replace PACKAGE BODY EMPLOYEE_DETAILS AS PROCEDURE GET_EMPLOYEES( EMP_DEPT_ID EMPLOYEES.DEPARTMENT_ID%TYPE, EMP_SALARY employees.salary%TYPE

Can I use UTILS in Oracle?

耗尽温柔 提交于 2019-12-12 21:26:50
问题 I want to ask if I can use the following in Oracle: UTILS.CONVERT_TO_VARCHAR2 for instance: SELECT insertData, UTILS.CONVERT_TO_VARCHAR2(insertData,10,p_style=>104) insert_short FROM students If it is not possible to use UTILS package, so which alternative I can use? 回答1: Basically, yes. My guess is that you've taken some SQL Server T-SQL and run it through the Oracle SQL Developer Translator ( Tools - Migration - Scratch Editor ) and this is what came out the other side. UTILS is a package

plsql remote debug breakpoints not working

自古美人都是妖i 提交于 2019-12-12 21:15:10
问题 I have a weird situation with debugging pl sql code. I set sql developer to listen for debug connections. In java code I attach debugger with following code: CallableStatement cstmt = null; try { cstmt = getConnection().prepareCall("begin DBMS_DEBUG_JDWP.CONNECT_TCP( '10.1.1.17', 4000); end;"); cstmt.execute(); } catch (SQLException e) { e.printStackTrace(); } finally { closeStatement(cstmt); } Debugger connects successfully, i.e. I can see in sql developer in Run Manager that connection

Use of single quote and double 'single quote' in PL/SQL block

混江龙づ霸主 提交于 2019-12-12 19:42:35
问题 Here is a block of code which needs to be executed: DECLARE STR CLOB; BEGIN STR := ' CREATE TABLE TNAME AS SELECT ... FROM INPUT_TABLE IP WHERE ((IP.DATE_FIELD = TO_DATE('12.08.2013', 'DD.MM.sYYYY'))) ' ; EXECUTE IMMEDIATE (STR); END; This block is formed in java code. On execution, this throws exception org.springframework.jdbc.BadSqlGrammarException . But when i change TO_DATE('12.08.2013', 'DD.MM.sYYYY') to TO_DATE(''12.08.2013'', ''DD.MM.sYYYY'') it executes successfully. Here are my