oracle11g

Returning a table from an Oracle function

假如想象 提交于 2019-12-18 08:59:11
问题 I've looked at many solutions here to try to solve this and they have gotten pretty far but now I'm in the weeds on some errors that I can#t seem to get past. I am on Oracle 11g. I need a function to return a record set (table). Here is the code I'm using: CREATE TYPE T_TABLE IS OBJECT ( Field1 int , Field2 int ); CREATE TYPE T_TABLE_COLL IS TABLE OF T_TABLE; CREATE OR REPLACE FUNCTION FN_MyFunction RETURN T_TABLE_COLL IS BEGIN FOR I IN (SELECT Field1, Field2 FROM Table1) LOOP IF I.Field1 = 1

“Not a valid month” on an INSERT statement

馋奶兔 提交于 2019-12-18 08:57:16
问题 I have an sql statement: Insert into MYSCHEMA.TABLE1 (ID,MY_DATE) values (167600,to_timestamp('15-APR-14 01.36.58.803000000 PM','DD-MON-RR HH.MI.SS.FF AM')); As I read this format is correct (as described here) but oracle returns an error SQL Error: ORA-01843: not a valid month . Any idea how to solve this problem? I use Oracle Database 11b Express Edition. 回答1: Unless you have a trigger on the table that is setting a date or timestamp column, which would give some indication in the full

removing milliseconds from a oracle tmstmp field

一个人想着一个人 提交于 2019-12-18 08:14:09
问题 I have a TIMESTAMP(6) field in Oracle and I need to remove the millisecond component from the time. For example I have 10/20/2014 10:34:06.356000 AM and I would like to remove the milliseconds so that I have 10/20/2014 10:34:06 AM Do you know the best way to do this? Thank you! 回答1: How about this? select cast(col as timestamp(0)) EDIT: The easiest way to avoid rounding is to use trunc() or to subtract half a second: select cast(col - 0.5/(24*60*60) as timestamp(0)) 回答2: try this SELECT TO

Use Plink to execute command (Oracle SQL query) on remote server over SSH

让人想犯罪 __ 提交于 2019-12-18 07:24:42
问题 Currently I'm doing this: start putty.exe , input remote server IS and select SSH login, then input server username and password. Then I have to enter sqlplus to enter into database, next I put database user and password and run select query. Get output logs on my PC. I want to automate the process using Plink or any other tool. 回答1: As you already know, you can use plink (from PuTTY package) to automate remote command execution. The plink has the command-line switch -m , that you use to

Getting “cx_Oracle.DatabaseError: DPI-1050: Oracle Client library must be at version 11.2 or higher” error

和自甴很熟 提交于 2019-12-18 07:24:33
问题 I am trying to use pycharm(3.3) to access my Oracle SQL(11.2.0) using the below codes but getting error with below details. Code used: import cx_Oracle connection = cx_Oracle.connect('uname/pwd@14@server') Error received cx_Oracle.DatabaseError: DPI-1050: Oracle Client library must be at version 11.2 or higher 回答1: I had an issue very similar to yours. I was able to solve it by using a different connection method: my_dsn = cx_Oracle.makedsn("host",port,sid="sid") connection = cx_Oracle

Repeating values in a column

ⅰ亾dé卋堺 提交于 2019-12-18 07:23:18
问题 I have the following values in a column which are separated by comma. BHOP23,BHOP23,BHOP24 I would like to know whether values are repeating in a column. How can I do this? 回答1: Oracle Setup : CREATE TABLE your_table ( your_list_column ) AS SELECT 'a,a,b,c,d' FROM DUAL UNION ALL -- duplicates both at head SELECT 'a,b,a,c,d' FROM DUAL UNION ALL -- duplicates at head and middle SELECT 'a,b,c,d,a' FROM DUAL UNION ALL -- duplicates at head and tail SELECT 'a,b,b,c,d' FROM DUAL UNION ALL --

ORA-00600 When running ALTER command?

谁说胖子不能爱 提交于 2019-12-18 07:08:44
问题 I am running this command on a table : ALTER TABLE testTable ADD column1 NUMBER(1) DEFAULT 0 NOT NULL; And i keep getting this error: Error report: SQL Error: ORA-00600: internal error code, arguments: [kkpoffoc], [], [], [], [], [], [], [], [], [], [], [] 00600. 00000 - "internal error code, arguments: [%s], [%s], [%s], [%s], [%s], [%s], [%s], [%s]" *Cause: This is the generic internal error number for Oracle program exceptions. This indicates that a process has encountered an exceptional

ORACLE/SQL: wm_concat & order by

眉间皱痕 提交于 2019-12-18 06:58:13
问题 I'm using oracle 11 (not sure about the exact version, but since LISTAGG doesn't work, I suppose it's not release 2) through ODBC and crystal reports 2008. Here is the problem I have: Here's a table: TABLE ODB.TASK_CARD_CONTROL ------------------------------------------ task_card control_category code ------------------------------------------ 1 zone 17 1 zone 33 1 zone 21 2 zone 18 2 zone 05 3 zone 55 3 zone 32 3 zone 72 I'm using the WM_CONCAT function to obtain something like this: task

Change separator of WM_CONCAT function of Oracle 11gR2

一世执手 提交于 2019-12-18 06:08:31
问题 Normally, WM_CONCAT is an aggregate function that return values from table separated by comma like here. Suppose I have a table foo like this: col_id | col_text 111 | This 111 | is 111 | a 111 | test. If I use this query: SELECT CAST(WM_CONCAT(col_text) AS VARCHAR2(100)), col_id FROM foo the result would be This, is, a, test. Is it possible to change the separator( ',' ) to other characters like '.' or '|' of the WM_CONCAT() function? Or create a user defined function that can be executed

Listagg function and ORA-01489: result of string concatenation is too long

一曲冷凌霜 提交于 2019-12-18 04:41:19
问题 When i run the following query: Select tm.product_id, listagg(tm.book_id || '(' || tm.score || ')',',') within group (order by tm.product_id) as matches from tl_product_match tm where tm.book_id is not null group by tm.product_id Oracle returns the following error: ORA-01489: result of string concatenation is too long I know that the reason it is failing is that the listagg function is trying to concatenate a the values which are greater than 4000 characters which is not supported. I have