sql - Query returns 1 row but throws error for more -


i have weird problem.

i have following query :

dbms_output.put_line('prefix : ' || prefix || 'vendor id :' || vendor_id);  select  r.rate  rate rates r r.quality = 0 , r.vendor_id = vendor_id , r.prefix = prefix , r.direction = 'out' , r.calendar_value = 0 , (sysdate-(1/24/60) >= r.effective_date_from  , sysdate-(1/24/60)  < nvl(r.effective_date_to, sysdate)); 

now rate,vendor_id , prefix 3 variables, 3 numbers. query in stored procedure, , right before query output both vars, prints prefix : 5 vendor id : 361

and query falls on ora-01422: exact fetch returns more requested number of rows

the thing is, if copy/paste query separate sql query outside procedure 5 , 361, 1 row.

does know why happen? i'm on oracle 11g

i'd bet have duplicates in input. consider following data:

create table rates (pk number not null primary key, rate number,    quality number, vendor_id number, prefix number,   direction varchar2(30), calendar_value number,    effective_date_from date, effective_date_to date);        insert rates values(1, 2, 0, 361, 5, 'out', 0,    to_date('2013-04-25 13:40:00', 'yyyy-mm-dd hh24:mi:ss'),    to_date('2013-04-25 13:45:00', 'yyyy-mm-dd hh24:mi:ss'));  insert rates values(2, 3, 0, 361, 5, 'out', 0,    to_date('2013-04-25 13:45:00', 'yyyy-mm-dd hh24:mi:ss'),    to_date('2013-04-25 13:46:00', 'yyyy-mm-dd hh24:mi:ss'));  insert rates values(3, 4, 0, 361, 5, 'out', 0,    to_date('2013-04-25 13:45:30', 'yyyy-mm-dd hh24:mi:ss'),    null); 

(note overlap between rows 2 , 3).

given data, query return

  • 1 row if run between 13:45:00 , 13:45:30
  • 2 rows if run between 13:45:30 , 13:46:00
  • 1 row afterwards

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -