oracle10g

Is dbms_output.put() being buffered differently from dbms_output.put_line()?

淺唱寂寞╮ 提交于 2019-12-01 18:30:06
Im using Aqua Data Studio to debug a stored proc by scattering output statments throughout. I have a delete statement in the package which violate an integrity constraint: DELETE FROM x WHERE x.ID = an_x_with_children; My proc fails with an ORA-02292 on this line, as expected. I want to see the value of the an_x_with_children variable. So I wrap the line with outputs like so: dbms_output.put('Attempting to delete x: ' || an_x_with_children); DELETE FROM x WHERE x.ID = an_x_with_children; dbms_output.put(' Success'); And expect to see the message as the last thing in the messages console prior

How to resolve Oracle error ORA-01790?

可紊 提交于 2019-12-01 18:14:48
I have two select statements joined by "union". While executing that statement I've got: Error report: SQL Error: ORA-01790: expression must have same datatype as corresponding expression 01790. 00000 - "expression must have same datatype as corresponding expression" Maybe you can give me an advise on how to diagnose this problem? Without looking at your SQL, I would guess that you have columns being UNION'ed that have different data types. Here's what found: ORA-01790: expression must have same datatype as corresponding expression Cause: A SELECT list item corresponds to a SELECT list item

How to resolve Oracle error ORA-01790?

萝らか妹 提交于 2019-12-01 17:32:52
问题 I have two select statements joined by "union". While executing that statement I've got: Error report: SQL Error: ORA-01790: expression must have same datatype as corresponding expression 01790. 00000 - "expression must have same datatype as corresponding expression" Maybe you can give me an advise on how to diagnose this problem? 回答1: Without looking at your SQL, I would guess that you have columns being UNION'ed that have different data types. 回答2: Here's what found: ORA-01790: expression

ora-06553 pls-306 wrong number or types of arguments in call to 'ogc_x'

微笑、不失礼 提交于 2019-12-01 17:22:24
I´m trying a query in oracle 10g. It goes like this: SELECT * FROM h2h_reg reg, h2h_cat_estatus est WHERE reg.FECH_APLICACION = SYSDATE AND REG.ID_EST = EST.ID_ESTATUS AND est.tipo_estatus = "X"; So it runs smootly, but when I try it adding a group by: SELECT reg.id_arch, reg.id_prod FROM h2h_reg reg, h2h_cat_estatus est WHERE reg.FECH_APLICACION = SYSDATE AND reg.id_est = est.id_estatus AND EST.TIPO_ESTATUS = "X" GROUP BY reg.id_arch, reg.id_prod; I get the next message: ora-06553 pls-306 wrong number or types of arguments in call to 'ogc_x' Does anyone knows what´s wrong in my query? you've

ora-06553 pls-306 wrong number or types of arguments in call to 'ogc_x'

ぐ巨炮叔叔 提交于 2019-12-01 16:29:53
问题 I´m trying a query in oracle 10g. It goes like this: SELECT * FROM h2h_reg reg, h2h_cat_estatus est WHERE reg.FECH_APLICACION = SYSDATE AND REG.ID_EST = EST.ID_ESTATUS AND est.tipo_estatus = "X"; So it runs smootly, but when I try it adding a group by: SELECT reg.id_arch, reg.id_prod FROM h2h_reg reg, h2h_cat_estatus est WHERE reg.FECH_APLICACION = SYSDATE AND reg.id_est = est.id_estatus AND EST.TIPO_ESTATUS = "X" GROUP BY reg.id_arch, reg.id_prod; I get the next message: ora-06553 pls-306

Oracle: Concat with delimiter, but only if both operands are NOT NULL

一世执手 提交于 2019-12-01 16:02:05
I want to select a concatenation of a couple of fields, but with a separator between them. The separator should only be there if both operands are not null. So for a record with a='foo', b=NULL, c='bar' , I want to get the result abc='foo;bar' (not 'foo;;bar' ). I would like to have a function like concat_sep(a, b, ';') that only adds the ';' inbetween if both a and b are not null. Of course, I can use nvl2 like this: select a, b, c, substr(abc, 1, length(abc) - 1) as abc from (select a, b, c, nvl2(a, a || ';', '') || nvl2(b, b || ';', '') || nvl2(c, c || ';', '') as abc from Table1) But as

Mutating Table in Oracle 11 caused by a function

拈花ヽ惹草 提交于 2019-12-01 15:11:47
We've recently upgraded from Oracle 10 to Oracle 11.2. After upgrading, I started seeing a mutating table error caused by a function rather than a trigger (which I've never come across before). It's old code that worked in prior versions of Oracle. Here's a scenario that will cause the error: create table mutate ( x NUMBER, y NUMBER ); insert into mutate (x, y) values (1,2); insert into mutate (x, y) values (3,4); I've created two rows. Now, I'll double my rows by calling this statement: insert into mutate (x, y) select x + 1, y + 1 from mutate; This isn't strictly necessary to duplicate the

Oracle: Concat with delimiter, but only if both operands are NOT NULL

我怕爱的太早我们不能终老 提交于 2019-12-01 14:55:36
问题 I want to select a concatenation of a couple of fields, but with a separator between them. The separator should only be there if both operands are not null. So for a record with a='foo', b=NULL, c='bar' , I want to get the result abc='foo;bar' (not 'foo;;bar' ). I would like to have a function like concat_sep(a, b, ';') that only adds the ';' inbetween if both a and b are not null. Of course, I can use nvl2 like this: select a, b, c, substr(abc, 1, length(abc) - 1) as abc from (select a, b, c

Can you help me write a procedure in Oracle to spool data from a table to a CSV file?

最后都变了- 提交于 2019-12-01 14:29:57
I am writing a procedure to create a CSV file with the data in an Oracle table. I used "spool filename;" but an error is coming. Can I use spool in PL/SQL? I think that there are better ways to implement this on Oracle 10g/11g, but this should work fine on Oracle 9i or higher: CREATE OR REPLACE PROCEDURE prc_file_mult_column_generate( p_file_dir VARCHAR2, -- mandatory (Oracle directory name) p_file_name VARCHAR2, -- mandatory p_sql_query VARCHAR2, -- Multiple column SQL SELECT statement that needs to be executed and processed p_delimiter CHAR -- column delimiter ) AS l_cursor_handle INTEGER; l

a Rollup query with some logical netting using Oracle SQL

笑着哭i 提交于 2019-12-01 13:33:26
I have a table "AuctionResults" like below Auction Action Shares ProfitperShare ------------------------------------------- Round1 BUY 6 200 Round2 BUY 5 100 Round2 SELL -2 50 Round3 SELL -5 80 Now I need to aggregate results by every auction with BUYS after netting out SELLS in subsequent rounds on a "First Come First Net basis" so in Round1 I bought 6 Shares and then sold 2 in Round2 and rest "4" in Round3 with a total NET profit of 6 * 200-2 * 50-4 * 80 = 780 and in Round2 I bought 5 shares and sold "1" in Round3(because earlier "4" belonged to Round1) with a NET Profit of 5 * 100-1 * 80 =