ASKER
Well, this is a pretty weird limitation of that application. I would ask for a fix for it instead of trying to fiddle in the actual packages.Yes I agree. It's a situation where the output gets shared with multiple agencies. Some agencies have limitations. I honestly don't know much more beyond that.
ASKER
ASKER
create or replace procedure quick_test(cur_item1_out out sys_refcursor)
is
begin
open cur_item1_out for select 'Hello' bob from dual;
end;
/
variable mycur refcursor
exec quick_test(:mycur);
print mycur;
ASKER
VARCHAR2: Variable-length character string
and
CHAR: Fixed-length character data
declare
var1 varchar2(32000) := 'A';
var2 char(32000) := 'A';
begin
dbms_output.put_line('var1 length: ' || length(var1));
dbms_output.put_line('var2 length: ' || length(var2));
end;
/
CREATE VIEW viewName AS
SELECT field1, field2, ... FROM (
SELECT field1, field2, ...,
ROW_NUMBER() OVER(
PARTITION BY pk_id ORDER BY pk_id DESC
) rn
FROM tableName
)
WHERE rn =< 1000;
"ORDER BY pk_id DESC" - defines which first 1000 rows will be included.How it's sent? ummm does MSMQ mean anything to you? That's what they use and that is where the limitation is.Where is MSMQ used? Who is responsible for it? These people need to implement a store and forward like system before MSMQ.
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
ASKER
select * from (WITH nq AS
(select mytable.idno as idno
from owner.view_person@sid mytable
WHERE mytable.idno is not null
AND mytable.FIRSTNAME LIKE 'J%'
AND (mytable.C_NAME LIKE 'DOE%' or mytable.C_SOUNDEX LIKE 'D000%')
)
)
, dq as
(
-- subquery here getting person data based on "nq.idno" match
)
--subquery getting additional person data based on "nq.idno" match
union all
--subquery getting yet more person data based on "nq.idno" match
)
order by SEARCH_ORDER asc, (UTL_MATCH.JARO_WINKLER_SIMILARITY(LASTNAME, upper('DOE')) + UTL_MATCH.JARO_WINKLER_SIMILARITY(FIRSTNAME, upper('JOHN'))) DESC;
select *, row_number() over (order by SEARCH_ORDER asc) as ROWNUM from (WITH nq AS
(select mytable.idno as idno
from owner.view_person@sid mytable
WHERE mytable.idno is not null
AND mytable.FIRSTNAME LIKE 'J%'
AND (mytable.C_NAME LIKE 'DOE%' or mytable.C_SOUNDEX LIKE 'D000%')
)
)
, dq as
(
-- subquery here getting person data based on "nq.idno" match
)
--subquery getting additional person data based on "nq.idno" match
union all
--subquery getting yet more person data based on "nq.idno" match
)
order by SEARCH_ORDER asc, (UTL_MATCH.JARO_WINKLER_SIMILARITY(LASTNAME, upper('DOE')) + UTL_MATCH.JARO_WINKLER_SIMILARITY(FIRSTNAME, upper('JOHN'))) DESC;
select * from (
with cte as (
select 'Hello' bob from dual
)
select * from cte
);
with cte as (
select 'Hello' bob from dual
)
select * from cte
--set up some dummy data
create table tab1(col1 char(1), col2 char(1));
insert into tab1 select dbms_random.string('a',1), dbms_random.string('a',1) from dual connect by level <= 1000;
commit;
select * from (
with cte as (
select col1, col2 from tab1
)
select col1, col2 from cte
)
order by col1;
with cte as (
select col1, col2 from tab1
),
cte_final as (
select col1, col2, row_number() over(order by col1) rn
from cte
)
select col1, col2
from cte_final
where rn between 10 and 20
;
ASKER
ASKER
So, you magically decide that 1,000 rows is a "batch" and the query as it is now returns 3,000 rows. The app needs to make 3 calls to the procedure to get ALL the rows.
ASKER
ASKER
create table names(first_name varchar2(50), last_name varchar2(50));
insert into names values...<whatever sample data you want to provide>
...
, newCTE as (
select CNTQRYTYPE,
SEARCH_ORDER,
FIRSTNAME,
LASTNAME,
PIN,
DOB,
SEX_CODE,
RACE_CODE,
row_number() over(order by LASTNAME,FIRSTNAME,D_DATE_OF_BIRTH) as RN
FROM JK
)
select distinct CNTQRYTYPE,
SEARCH_ORDER,
FIRSTNAME,
LASTNAME,
PIN,
DOB,
SEX_CODE,
RACE_CODE
from newCTE where rn between 1 and 500
(em.C_NAME LIKE 'SMITH%' or em.C_SOUNDEX LIKE 'D000%')
Retain the first letter of the string
ASKER
ASKER
with params as (
select
'J%' p_first_name,
'DEW%' p_last_name,
'08071933' p_dob
from dual
)
select
case when em.d_date_of_birth = to_date(p_dob,'MMDDYYYY') then 'NAME_RACE_SEX_DOB' else 'NAME_RACE_SEX' end AS CNTQRYTYPE,
case when em.d_date_of_birth = to_date(p_dob,'MMDDYYYY') then '3' else '4' end AS SEARCH_ORDER,
replace (em.FIRSTNAME, chr(39), '') AS FIRSTNAME,
replace (em.MIDDLENAME, chr(39), '') AS MIDDLENAME,
replace (em.LASTNAME, chr(39), '') AS LASTNAME,
em.i_spn_pin AS PIN,
em.D_DATE_OF_BIRTH AS DOB,
em.C_GENDER_CD AS SEX_CODE,
em.C_RACE_CD AS RACE_CODE
from test_table em
cross join params
WHERE em.i_spn_pin is not null
AND em.FIRSTNAME LIKE p_first_name
AND (em.C_NAME LIKE p_last_name or em.C_SOUNDEX LIKE soundex(p_last_name) || '%')
;
ASKER
I understand why it's in there. James Thyme has the same i_spn_pin as the James Dew.I didn't notice that. But it makes sense. The output is correct then.
If a name and DOB matches in both NQ and JK, why return them both?
For example the first row has 'S530 B430 O416'. You never look for the O416?
I'm going to take a leap of faith and assume that if a row gets BOTH a search_order of '3' and '4', you want '3' instead of '4'.
ASKER
ASKER
select * from (WITH nql as (select em.i_spn_pin as spn
from myschema.view_persons@DBLINK em
WHERE em.i_spn_pin is not null
AND em.FIRSTNAME LIKE 'P%'
AND (em.C_NAME LIKE 'SMITH%' or em.C_SOUNDEX LIKE 'S530%')
ORDER BY (UTL_MATCH.JARO_WINKLER_SIMILARITY(LASTNAME, upper('SMITH')) + UTL_MATCH.JARO_WINKLER_SIMILARITY(FIRSTNAME, upper('BLUTO'))) DESC
)
, nq as (
select spn from nql where rownum <= 2000
)
,dq as (select em.i_spn_pin as spn
from myschema.view_persons@DBLINK em
WHERE em.i_spn_pin is not null
AND em.FIRSTNAME LIKE 'P%'
AND (em.C_NAME LIKE 'SMITH%' or em.C_SOUNDEX LIKE 'S530%')
AND em.d_date_of_birth = to_date('01201965','MMDDYYYY')
)
select distinct 'NAME_RACE_SEX' AS CNTQRYTYPE,
'4' AS SEARCH_ORDER,
replace (em.FIRSTNAME, chr(39), '') AS FIRSTNAME,
replace (em.MIDDLENAME, chr(39), '') AS MIDDLENAME,
replace (em.LASTNAME, chr(39), '') AS LASTNAME,
em.i_spn_pin AS PIN,
em.D_DATE_OF_BIRTH AS DOB,
em.C_GENDER_CD AS SEX_CODE,
em.C_RACE_CD AS RACE_CODE
FROM myschema.view_persons@DBLINK em
,nq
WHERE em.c_spn = 'Y'
AND em.c_allow_search = 'Y'
AND em.I_SPN_PIN = nq.spn
UNION ALL
select distinct 'NAME_RACE_SEX_DOB' AS CNTQRYTYPE,
'3' AS SEARCH_ORDER,
replace (em.FIRSTNAME, chr(39), '') AS FIRSTNAME,
replace (em.MIDDLENAME, chr(39), '') AS MIDDLENAME,
replace (em.LASTNAME, chr(39), '') AS LASTNAME,
em.i_spn_pin AS PIN,
em.D_DATE_OF_BIRTH AS DOB,
em.C_GENDER_CD AS SEX_CODE,
em.C_RACE_CD AS RACE_CODE
FROM myschema.view_persons@DBLINK em
,dq
WHERE em.c_spn = 'Y'
AND em.c_allow_search = 'Y'
AND em.I_SPN_PIN = dq.spn
)
ORDER BY SEARCH_ORDER ASC, (UTL_MATCH.JARO_WINKLER_SIMILARITY(LASTNAME, upper('SMITH')) + UTL_MATCH.JARO_WINKLER_SIMILARITY(FIRSTNAME, upper('BLUTO'))) DESC
ASKER
CNTQRYTYPE S FIRSTNAME MIDDLENAME LASTNAME PIN DOB S R
----------------- - ---------- ---------- ---------- ---------- --------- - -
NAME_RACE_SEX_DOB 3 JAMES TIBERIUS THYME 57713 07-AUG-44 M W
with params as (
select
'J' p_first_name,
'DEW' p_last_name,
'08071933' p_dob
from dual
),
all_names as (
select distinct
max(case when
em.FIRSTNAME LIKE p_first_name || '%' and (em.C_NAME LIKE p_last_name || '%' or em.C_SOUNDEX LIKE soundex(p_last_name) || '%')
then 'Y'
end) over(partition by i_spn_pin) name_match,
case when em.d_date_of_birth = to_date(p_dob,'MMDDYYYY') then 'Y' else 'N' end AS dob_match,
utl_match.jaro_winkler_similarity(upper(lastname), upper(p_last_name)) last_jaro_sim,
utl_match.jaro_winkler_similarity(upper(firstname), upper(p_first_name)) first_jaro_sim,
replace(em.FIRSTNAME, chr(39), '') AS FIRSTNAME,
replace(em.MIDDLENAME, chr(39), '') AS MIDDLENAME,
replace(em.LASTNAME, chr(39), '') AS LASTNAME,
em.i_spn_pin AS PIN,
em.D_DATE_OF_BIRTH AS DOB,
em.C_GENDER_CD AS SEX_CODE,
em.C_RACE_CD AS RACE_CODE
from test_table em
cross join params
WHERE em.i_spn_pin is not null
),
score_names as (
select
case when dob_match='Y' then 'NAME_RACE_SEX_DOB' else 'NAME_RACE_SEX' end AS CNTQRYTYPE,
name_match,
dob_match,
firstname,
middlename,
lastname,
pin,
dob,
sex_code,
race_code,
last_jaro_sim + first_jaro_sim name_score,
row_number() over(partition by name_match order by last_jaro_sim + first_jaro_sim desc) name_rn
from all_names
)
select *
from score_names
where
name_match='Y' and (name_rn<2000 or dob_match='Y')
order by name_score desc
;
ASKER
ASKER
Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.
TRUSTED BY
I'm not aware of a database setting. The only option is imho to add ROWNUM predicate to the outer SELECT statements.
Well, this is a pretty weird limitation of that application. I would ask for a fix for it instead of trying to fiddle in the actual packages.