oracle11g

MAX(DATE) - SQL ORACLE

主宰稳场 提交于 2019-12-22 04:28:11
问题 I want to select only the latest membership_id from table user_payments of the user with the user_id equal to 1. This is how the table user_payment looks like: PAYM_ID USER_ID MEMBSHIP_ID PAYM_DATE ---------- ---------- ----------- ------------------------------- 1 1 1 18-DEC-09 12.00.00.000000000 AM 2 1 2 18-DEC-10 12.00.00.000000000 AM 3 1 2 18-DEC-11 12.00.00.000000000 AM 4 2 3 17-MAR-11 12.00.00.000000000 AM 5 3 3 18-JUN-12 12.00.00.000000000 AM 6 4 2 17-FEB-12 12.00.00.000000000 AM 7 5 2

Trigger for only changed values

会有一股神秘感。 提交于 2019-12-22 03:24:22
问题 Say we have 3 records in table: orig_tab --------------------------------------------- | PK | Name | Address | Postal Code | --------------------------------------------- | 1 | AA | Street1 | 11111 | | 2 | BB | Street2 | 22222 | | 3 | CC | Street3 | 33333 | --------------------------------------------- Now the data is changed: --------------------------------------------- | PK | Name | Address | Postal Code | --------------------------------------------- | 1 | AA | Street1 | 11111 | | 2 | BB

How to set default value for column of new created table from select statement in 11g

二次信任 提交于 2019-12-22 01:26:01
问题 I create a table in Oracle 11g with the default value for one of the columns. Syntax is: create table xyz(emp number,ename varchar2(100),salary number default 0); This created successfully. For some reasons I need to create another table with same old table structure and data. So I created a new table with name abc as create table abc as select * from xyz. Here "abc" created successfully with same structure and data as old table xyz . But for the column "salary" in old table "xyz" default

Change Oracle SQL Query Text before submission [closed]

与世无争的帅哥 提交于 2019-12-21 21:43:00
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Is there a advanced oracle feature to modify the SQL Query just before it is submitted to oracle? Or may be modify the result set? Based on certain condition? Like may be based on the name of the process that

How to pass a variable from a Windows Batch File to SQL*Plus

北城以北 提交于 2019-12-21 21:35:07
问题 I want to pass a variable from a Windows Batch File to SQLPLUS, while displaying sql result batch variable should print along with the sql result. Result should be stored in csv file. How can I do that. This is possible in Unix(shell script) how can I do that in Windows(batch script). 回答1: I want to pass a variable from a Windows Batch File to SQLPLUS Just pass it as an argument to the SQL script. And use substitution variables in the same order that of the arguments list &1 &2... For example

Returning a recordset from Oracle to .Net using an Oracle function that takes arguments

倾然丶 夕夏残阳落幕 提交于 2019-12-21 21:34:18
问题 I currently have the following funciton in an oracle database that returns a concatenated string seperated by pipes. It's a legacy application that is being updated to use .net 3.5. The exiisting application concatenates the returned result set into a VARCHAR2 data type. What I want to do is return the entire result set back to my .net client. The MS SQL equivalent of what I'm trying to accomplish is a simple "SELECT * FROM TBL WHERE id = @id" I'm not use to some of the concepts Oracle uses.

Oracle data source connection pooling not working used with Spring and JDBCTemplate

非 Y 不嫁゛ 提交于 2019-12-21 20:28:29
问题 Question: Lot of active unclosed physical connections with database even with connection pooling. Can someone tell me why is it so? I configured the connection pool settings using oracle.jdbc.pool.OracleDataSource . However it seems the physical connections are not getting closed after use. I thought, Since it is connection pooling, the connections will be reused from the pool, so so many physical connections will not be made, but thats not what is happening now! There are 100+ active

pragma autonomous_transaction in a trigger

巧了我就是萌 提交于 2019-12-21 17:52:28
问题 I have written a trigger on one table which deletes data from other table upon a condition. The trigger has pragma autonomous_transaction, and trigger works as intended. However, I do wonder if there can be any problems in future, say if data is inserted by multiple users/sources at the same time etc...Any suggestions? Source table t1: -------------------------------------------- | user_id | auth_name1 | auth_name2 | data | -------------------------------------------- | 1 | Name1 | Name2 | d1

Querying Oracle TIMESTAMP WITH TIMEZONE

此生再无相见时 提交于 2019-12-21 17:11:33
问题 I have a column in an Oracle DB table that is of type TIMESTAMP(6) WITH TIME ZONE . There are data rows with data from different timezones, some UTC, some in other timezone offsets. Is there a way I can query the Oracle table so that the results always come back as UTC, with the appropriate time shifting being done? Is there something that can be done on the query itself, or perhaps altering the session somehow? I've tried altering the session timezone to Utc, but this seems to only impact

Materialized view fast refresh with HAVING clause?

懵懂的女人 提交于 2019-12-21 14:02:34
问题 On Oracle 11g I'm trying to create a materialized view with FAST REFRESH ON COMMIT that contains a HAVING clause. The Database Data Warehousing Guide says: General Restrictions on Fast Refresh The defining query of the materialized view is restricted as follows: It cannot contain a HAVING clause with a subquery. But if I add HAVING count(*)>1 (note: no subquery) to an otherwise working materialized view, I get this error: ORA-12054: cannot set the ON COMMIT refresh attribute for the