oracle10g

Parameter variable schema oracle

徘徊边缘 提交于 2019-12-23 05:34:10
问题 I'm newbie using Oracle. I have a question: in SQL Server, we can use: DECLARE DBNAME1 VARCHAR(20) DECLARE DBNAME2 VARCHAR(20) SET @DBNAME1 ='TEST_DB' SET @DBNAME2 ='TEST_DB2' INSERT INTO @DBNAME1.TABLECORE SELECT * FROM @DBNAME2.TABLENONCORE T What is the equivalent of this script in if @DBNAME == Schema in Oracle? 回答1: We can manage it but creating db link on dbname2 : create public database link dbname2 connect to myschema using 'abc-scan.mycompany.com.tr:1521/dbname2.mycompany.com.tr';

How to find groups of sequential integers in Oracle?

匆匆过客 提交于 2019-12-23 05:33:05
问题 I am using oracle 10g. My (simplified) table definition is CREATE TABLE Student ("Rno" INT PRIMARY KEY) ; Which contains the following rows | RNO | |-----| | 1 | | 2 | | 3 | | 6 | | 8 | | 9 | | 12 | | 13 | | 14 | | 18 | How can I produce the following result set? | RESULT | |------------------------| | 1-3, 6, 8-9, 12-14, 18 | 回答1: You can use SELECT LISTAGG("Txt", ', ') WITHIN GROUP (ORDER BY "Rno") "Result" FROM (SELECT CASE WHEN MIN("Rno") = MAX("Rno") THEN CAST(MIN("Rno") AS VARCHAR2(11))

ORA-00936 When using date function in the oracle select statement

落花浮王杯 提交于 2019-12-23 04:29:00
问题 I have a query that I'm trying to aggregate data based on hours between two unix timestamps in Oracle. Hardest part is that I get error'd out with " ORA-00936: missing expression " error even I don't see anything wrong in the query. Need some expert advice here. Below is the query - Query - select DATE(FROM_UNIXTIME(C.DATETIMEORIGINATION)) the_date, HOUR(FROM_UNIXTIME(C.DATETIMEORIGINATION)) the_hour, count(c.RECORD_ID) the_count FROM TABLE_A C WHERE C.DATETIMEORIGINATION between 1380033019

BULK COLLECT LIMIT in EXECUTE IMMEDIATE

亡梦爱人 提交于 2019-12-23 03:55:12
问题 Is it possible to put a limit in a bulk collect using execute immediate? I have below script but I am getting error when using a LIMIT. declare v_query varchar2(3000); begin v_query := 'select 1 from dual' -- this is just a sample query. execute immediate v_query bulk collect into table1 --table type end; If limit is not possible with my code, is there any work around? Thanks! 回答1: It seems that EXECUTE IMMEDIATE syntax doesn't allow for LIMIT in bulk collect clause http://docs.oracle.com/cd

Why does my oracle statement run differently on a windows database than linux?

核能气质少年 提交于 2019-12-23 03:12:31
问题 I don't know where to begin to debug this. Some developers have been writing some pl/sql code locally on their Windows machines that complete fine using Oracle 10.2.0.1.0 - 64bit. When it gets to production, which is Red Hat 5.3 and running 10.2.0.2.0, it gives me this error: ORA-00904: "S"."BARSTREAMREFERENCEID": invalid identifier Here is the gist of the code that is working in Windows: EXECUTE IMMEDIATE(' update candyman.CANDY_REFERENCES s set ( s.flavour, s.taste, s.colour, s

Logging Oracle Java Stored Procedure using Java Logging API (java.util.logging )

霸气de小男生 提交于 2019-12-23 02:47:11
问题 I've developed a new Java(1.4) Stored Procedure in Oracle (10g). I've never done this before, I usually keep Java and the DB separated but this was a requisite. So I developed a Java code that can be deployed in Tomcat as well as a Stored Procedure in Oracle. For this I used the Java Logging API. I can execute the stored procedure in Oracle, but I can't find the logs. I would like to know what should I do in order to print the logs, it can be to Oracle logs or trc files, or even, if possible,

How to get record count using reference cursor in oracle10g

青春壹個敷衍的年華 提交于 2019-12-23 02:45:43
问题 I want to know how we can get record count using reference cursor in oracle10g. 回答1: After you fetched the rows you can use cursorname %rowcount to get the amount of records you fetched. 回答2: You cannot. You can only count the rows while you fetch them from the cursor. A cursor is like a stream, and Oracle does not know how much rows are in there until it has read them all (which happens as you fetch rows). 来源: https://stackoverflow.com/questions/1062142/how-to-get-record-count-using

Bulk extraction of Oracle BLOBS into files - advice/tuning help needed

≡放荡痞女 提交于 2019-12-22 17:52:19
问题 I am working on a project that needs migration of existing Oracle blobs into files. The environment to read from is a shared Oracle 10gR2 server. Currently I have a script using UTL_FILE. However, the process is pretty slow. It takes around 3 hours to extract 25 GB of sample data. The actual data to be moved is in the order of 1 TB. I need help/advice in tuning this significantly. Here is my process: Open a cursor to fetch the list of blob ids and names Start a loop to go thru each blob

How to recursively compute ratio of remaining amounts based on rounded values from preceding rows?

帅比萌擦擦* 提交于 2019-12-22 17:47:14
问题 I need to split 1 amount into 2 fields . I know the total sums of the resulting fields = the ratio to split the first row, but i need to round the resulting sums and only then compute the ratio for next row (so the total sum of the rounded values will be correct). How can i write this algorithm in Oracle 10g PL/SQL? I need to test some migrated data. Here is what i came up with (so far): with temp as ( select 1 id, 200 amount, 642 total_a from dual union all select 2, 200, 642 from dual union

How to use a nested table in a cursor

拈花ヽ惹草 提交于 2019-12-22 13:56:19
问题 CREATE PROCEDURE( p_cur OUT a_cur) IS type rec is record( a varchar2(2), b number, c number); type tab is table of rec; tab1 tab:=tab(); begin tab1.extend; tab1(tab1.last).a:='as'; tab1(tab1.last).b:=2; tab1(tab1.last).c:=3; tab1.extend; tab1(tab1.last).a:='jj'; tab1(tab1.last).b:=2; tab1(tab1.last).c:=3; --??--- end; I have created a nested table here tab1 ,but my issue is that i want to use this nested table in a cursor and want to return whole records using this nested table ,limitation is