oracle11g

Dynamic pivot in oracle sql - Procedure

坚强是说给别人听的谎言 提交于 2020-01-11 11:19:12
问题 I got a solution to dynamic pivot from this post . Now I want to implement the below statements in an oracle procedure. clear columns COLUMN temp_in_statement new_value str_in_statement SELECT DISTINCT LISTAGG('''' || myLetter || ''' AS ' || myLetter,',') WITHIN GROUP (ORDER BY myLetter) AS temp_in_statement FROM (SELECT DISTINCT myLetter FROM myTable); SELECT * FROM (SELECT myNumber, myLetter, myValue FROM myTable) PIVOT (Sum(myValue) AS val FOR myLetter IN (&str_in_statement)); Thanks in

Dynamic pivot in oracle sql - Procedure

你。 提交于 2020-01-11 11:19:11
问题 I got a solution to dynamic pivot from this post . Now I want to implement the below statements in an oracle procedure. clear columns COLUMN temp_in_statement new_value str_in_statement SELECT DISTINCT LISTAGG('''' || myLetter || ''' AS ' || myLetter,',') WITHIN GROUP (ORDER BY myLetter) AS temp_in_statement FROM (SELECT DISTINCT myLetter FROM myTable); SELECT * FROM (SELECT myNumber, myLetter, myValue FROM myTable) PIVOT (Sum(myValue) AS val FOR myLetter IN (&str_in_statement)); Thanks in

How do I login to 'xe' connection in Oracle 11g with java code?

风格不统一 提交于 2020-01-11 10:46:46
问题 I want to make java code that does only this: Login to the 'xe' connection in Oracle 11g database. That's all. How can do it ? EDIT: yes, i was using JDBC, but unable to login to that connection. My url is jdbc:oracle:thin:@//localhost:1521/xe , username = sys and password = 123456 for the xe or sys connection. Then why can't i login to that connection ? EDIT: I am very sorry, I forgot to add that I see another error besides the 1st one, i.e. SQLException: ORA-28009: connection as SYS should

how to implement like operator in prepared statement? [duplicate]

╄→гoц情女王★ 提交于 2020-01-11 10:44:24
问题 This question already has an answer here : Use of LIKE clause in sql prepared statement, spring, SimpleJDBCTemplate (1 answer) Closed 3 years ago . ps=con.prepareStatement("select * from REGISTER inner join ORGAN on REGISTER.PATIENTID=ORGAN.PATIENTID where ORGAN.ORGAN LIKE ?"); ps.setString(1,"'%"+o.getOrgan()+"%'"); I executed the query in SQL Developer which works fine, but in DAO class it is not returning any result set. 回答1: Use ps.setString(1, "%" + o.getOrgan() + "%"); Note the absence

Top n distinct values of one column in Oracle

烂漫一生 提交于 2020-01-11 10:37:42
问题 I'm using a query where a part of it gets the top 3 of a certain column. It creates a distinct subquery of the column, limited by 3 number of rows, and then filters those rows to the main query to do the top 3. WITH subquery AS ( SELECT col FROM ( SELECT DISTINCT col FROM tbl ) WHERE ROWNUM <= 3 ) SELECT col FROM tbl WHERE tbl.col = subquery.col So the original table is like this: col ----- a a a b b b c d d e f f f f And the query returns the top 3 of the column (not the top 3 rows which

Build numbers table on the fly in Oracle

陌路散爱 提交于 2020-01-11 10:34:06
问题 How do I return a rowset consisting of the last four years based on the current date? If this query runs on 12/31/2010 it should return: 2007 2008 2009 2010 But if it is run on 1/1/2011 it should return: 2008 2009 2010 2011 Here's what I started with, two queries that return the starting year. I prefer the second as converting to string feels a bit dirty to me. SELECT TO_CHAR(TRUNC(sysdate, 'YY') - INTERVAL '3' YEAR, 'YYYY') FROM DUAL; SELECT EXTRACT (YEAR FROM sysdate) - 3 FROM DUAL; But I

Lat Lon Distance Calculation query in Oracle

*爱你&永不变心* 提交于 2020-01-11 07:07:20
问题 I have a Oracle 11g DB. I store Latitude and Longitudes (for lets say stores or shops). Now i need a query which will calculate the distance between the shops and my location(which i will provide in the query). I have done this earlier in MySQL, but in Oracle there is no Radians function. So i need work aronud in Oracle SQL. Help Appreciated. Thank You. 回答1: Create a function that converts degrees to radians: CREATE OR REPLACE FUNCTION degree_to_radian(p_degree IN NUMBER) RETURN NUMBER IS

Exception on importing Blob image into ms Access report

我们两清 提交于 2020-01-11 07:05:09
问题 In an Access 2013 Report I connect to an Oracle DB View via a Linked Table. One View field is of type BLOB and holds images that have been previously stored there. In my Access Report the linked table has a field (named BILD_INHALT) of type "OLE Object" that maps to the BLOB field in Oracle DB. In the report view, I created an "Image" field (named MST_Image) has to load the image and it is initialized in the following way: If Len(RS![BILD_INHALT]) > 0 Then Me.MST_Image.PictureData = RS![BILD

Unable to create the django_migrations table (ORA-02000: missing ALWAYS keyword)

隐身守侯 提交于 2020-01-11 05:54:42
问题 I'm starting a project in Django-2.0.1 with a database Oracle 11g, and when I run $python manage.py migrate, I get the error django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table (ORA-02000: missing ALWAYS keyword). You can see the full stack below: Traceback (most recent call last): File "/Users/user/anaconda3/lib/python3.6/site-packages/django/db/backends/utils.py", line 83, in _execute return self.cursor.execute(sql) File "/Users/user

How to extract data from a SAP ABAP system?

 ̄綄美尐妖づ 提交于 2020-01-11 05:26:45
问题 I need to extract data from a SAP ABAP system in a format that can then be loaded into an Oracle database (xlsx,csv,dmp.. etc) Once the data is extracted I'll use Pentaho to upload it into the Oracle database. Is there a way to extract the data from SAP? I will also need to automate it (the extraction) but that is not too much of a problem right now, I can figure/worry about that part later. If it is not possible to do so, an explanation why would be helpful! 回答1: You have a number of options