oracle9i

Return Message of Error code in Oracle Stored Proc

冷暖自知 提交于 2019-12-06 08:25:43
问题 The below procedure (in Oracle 11g release 1) accepts a sql as a parameter & returns its return code. Returns 0 if success Returns 1 if no update or no delete performs Returns actual error code in case of failure. How can I change below procedure to return me another out param say "return_message" which will contain short description of oracle internal error message? In case of success, it should say "success" and in case no delete/updates performed, it should say "nochange" CREATE OR REPLACE

Remove all characters after a specific character in PL/SQL

巧了我就是萌 提交于 2019-12-06 03:10:38
问题 How do I get a substring from this example value: john.abc_1234 I want it to return john.abc .So basically we need to remove all the information after _ . More examples: 1234_abc 回答1: You can use SUBSTR and INSTR : select substr('john.abc_1234', 1, instr('john.abc_1234', '_') -1) from dual Warning: This is only guaranteed to work if your string actually has an underscore in it Update Additionally, if you are running from Oracle 10g on, you could take the Regex path, which would more

Finding the datatype of a cursor or table column in a block

夙愿已清 提交于 2019-12-05 18:42:59
Is is possible to find out the datatype of a column of a cursor or variable within block without using system tables? While I understand that I can use the system tables to find out this information it would be a lot slower. Something like, declare my_column_data_type varchar2(30); begin my_column_data_type := all_tables.table_name%type; dbms_output.put_line(my_column_data_type); end; I can't find any way of doing it without resorting to dbms_sql , which would be overkill for my eventual purpose. But, Oracle already has all the information to hand. If I were to try to assign a varchar2 to a

Specify IBatis query timeout

不打扰是莪最后的温柔 提交于 2019-12-05 18:22:41
There is a way to specify IBatis query timeout using oracle jdbc and Java? Thanks From the iBatis manual : in the <settings> element : defaultStatementTimeout (iBATIS versions 2.2.0 and later) This setting is an integer value that will be applied as the JDBC query timeout for all statements. This value can be overridden with the “statement” attribute of any mapped statement. If not specified, no query timeout will be set unless specified on the “statement” attribute of a mapped statement. The specified value is the number of seconds the driver will wait for a statement to finish. Note that not

Single SQL SELECT Returning multiple rows from one table row

℡╲_俬逩灬. 提交于 2019-12-05 07:47:50
We have a table which is of the form: ID,Value1,Value2,Value3 1,2,3,4 We need to transform this into. ID,Name,Value 1,'Value1',2 1,'Value2',3 1,'Value3',4 Is there a clever way of doing this in one SELECT statement (i.e without UNIONs)? The column names Value1,Value2 and Value3 are fixed and constant. The database is oracle 9i. This works on Oracle 10g: select id, 'Value' || n as name, case n when 1 then value1 when 2 then value2 when 3 then value3 end as value from (select rownum n from (select 1 from dual connect by level <= 3)) ofs, t I think Oracle 9i had recursive queries? Anyway, I'm

Convert columns to rows in SQL [duplicate]

杀马特。学长 韩版系。学妹 提交于 2019-12-05 02:49:41
This question already has answers here : Oracle SQL pivot query (2 answers) Closed last year . I need to write a query which takes rows and converts it into columns - here's my table: Count fname lname id ----------------------------- 1 abc def 20 2 pqr 20 3 abc xyz 20 4 xyz xyz 20 1 abc def 21 1 pqr xyz 22 2 abc abc 22 This is the output I'm trying to produce: id fname lname fname lname fname lname fname lname ------------------------------------------------------------- 20 abc def pqr NULL abc xyz xyz xyz 21 abc def NULL NULL NULL NULL NULL NULL 22 abc abc NULL NULL NULL NULL NULL NULL The

count number of rows that occur for each date in column date range

六月ゝ 毕业季﹏ 提交于 2019-12-04 17:49:06
I have a table with data such as below Group Start Date End Date A 01/01/01 01/03/01 A 01/01/01 01/02/01 A 01/03/01 01/04/01 B 01/01/01 01/01/01 ETC I am looking to produce a view that gives a count for each day, like this Group Date Count A 01/01/01 2 A 01/02/01 2 A 01/03/01 2 A 01/04/01 1 B 01/01/01 1 I am using Oracle 9 and am at a total loss on what how to handle this and am looking for any idea to get me started. Note: Generating a table to hold the dates is not practical because I final product has to break down to the minute. Typically I solve this kind of problem with a numbers table:

Is there another command for wm_concat in oracle 9i?

冷暖自知 提交于 2019-12-04 15:52:39
I have a table containing dept id, employee names and date of joining. I want to get a list of all the employees who joined on a given day in a given dept. wm_concat is not working. Iswanto San According to this , WM_CONCAT is not supported. WM_CONCAT is an undocumented function and as such is not supported by Oracle for user applications You can use a user defined aggregate function described in that link. Try wmsys.wm_concat (10g+) or listagg (11g+) Florin Ghita See the String Aggregation Techniques page. For 9i, you can declare a UDAG function as in the page cited: CREATE OR REPLACE TYPE t

Return Message of Error code in Oracle Stored Proc

流过昼夜 提交于 2019-12-04 14:22:43
The below procedure (in Oracle 11g release 1) accepts a sql as a parameter & returns its return code. Returns 0 if success Returns 1 if no update or no delete performs Returns actual error code in case of failure. How can I change below procedure to return me another out param say "return_message" which will contain short description of oracle internal error message? In case of success, it should say "success" and in case no delete/updates performed, it should say "nochange" CREATE OR REPLACE PROCEDURE "demo"."run_demo"(v_sql IN VARCHAR2, return_code OUT number) AS i number; BEGIN return_code

Using distinct on a column and doing order by on another column gives an error

纵饮孤独 提交于 2019-12-04 10:31:30
问题 I have a table: abc_test with columns n_num, k_str. This query doesnt work: select distinct(n_num) from abc_test order by(k_str) But this one works: select n_num from abc_test order by(k_str) How do DISTINCT and ORDER BY keywords work internally that output of both the queries is changed? 回答1: As far as i understood from your question . distinct :- means select a distinct(all selected values should be unique). order By :- simply means to order the selected rows as per your requirement . The