Need help in restricting a result set from a UNION in MERGE
Hello,
Would really appreciate if anybody could help me out with the issue I am facing with the below statements (I am new to Oracle ):
merge into table_name_1 p
using
select p_key, value_1, value_2
from some_tables
UNION
select p_key, value_1, value_2
from some_tables
UNION
)t
on (p.p_key = t.p_key)
when matched then
update table_name_1 with value_1 and value_2
when not matched then
insert table_name_1 with p_key, value_1, value_2;
Now, the union of all those selects gives me distinct values and it works most of the times but when I get values like below, the merge fails:
p_key-----value_1-----value_2
100-----25-----50
100-----NULL-----50
I browsed the net and understood the reason behind this: the result set becomes ambiguous and merge doesn't know which row to insert first and which one to update.
Now, my requirement is: I could have any of the below scenario/result sets from the union and I need only 1 row per p_key -
result_set_1
p_key-----value_1-----value_2
100-----25-----50 ***************need this row
100-----NULL-----50
100-----NULL-----NULL
result_set_2
p_key-----value_1-----value_2
100-----25-----NULL ***************need this row
100-----NULL-----NULL
result_set_3
p_key-----value_1-----value_2
100-----25-----NULL ***************need this row (p_key = 100)
100-----NULL-----NULL
200-----NULL-----75 ***************need this row (p_key = 200)
200-----NULL-----NULL
300-----90-----95 ***************need this row (p_key = 300)
So, I basically need a way to restrict the values that I will get from the UNION of all those selects to fit the requirement above, hope I was able to explain the issue I am facing.
Any help would be greatly appreciated.
Thanks,
Dpunk
In all cases the goal is to find an order by value that will make the row you want be first.
The query I gave is calculating a priority for each row by adding up values showing whether each column is null or not null. The case statements check whether each column is null and need to be added up to give a total priority value.
Value_1 Value_2 Priority
Not Null Not Null 2 + 1 = 3
Not Null Null 2 + 0 = 2
Null Not Null 0 + 1 = 1
Null Null 0 + 0 = 0
The priority value ends up being a bitmap showing whether each value is null or not null. I think that reflects my mathematics background.
Another way of getting the same result (suggested to me by your asking why it needs the "+") would be to use two CASE expressions as separate order by items:
select p_key, value_1, value_2 from
(select p_key, value_1, value_2, row_number() over
(partition by p_key
order by case when value_1 is null then 0 else 1 end DESC,
case when value_2 is null then 0 else 1 end DESC
) as rn
from (your UNION query here)
where rn = 1
A third way is to use a more complex case statement:
select p_key, value_1, value_2 from
(select p_key, value_1, value_2, row_number() over
(partition by p_key
order by case when value_1 is NOT null and value_2 is NOT null then 1
when value_1 is NOT null and value_2 is null then 2
when value_1 is null and value_2 is NOT null then 3
when value_1 is null and value_2 is null then 4
end ASC
) as rn
from (your UNION query here)
where rn = 1
Similar Messages
-
Performance to fetch result set from stored procedure.
I read some of related threads, but couldn't find any good suggestions about the performance issue to fetch the result set from a stored procedure.
Here is my case:
I have a stored procedure which will return 2,030,000 rows. When I run the select part only in the dbartisan, it takes about 3 minutes, so I know it's not query problem. But when I call the stored procedure in DBArtisan in following way:
declare cr SYS_REFCURSOR;
firstname char(20);
lastname char(20);
street char(40);
city char(20);
STATE varchar2(2);
begin DISPLAY_ADDRESS(cr);
DBMS_OUTPUT.ENABLE(null);
LOOP
FETCH cr INTO firstname,lastname,street, city, state;
EXIT WHEN cr%NOTFOUND;
DBMS_OUTPUT.PUT_LINE( firstname||','|| lastname||','|| street||',' ||city||',' ||STATE);
END LOOP;
CLOSE cr;
end;
It will take about 100 minutes. When I used DBI fetchrow_array in perl code, it took about same amount of time. However, same stored procedure in sybase without using cursor, and same perl code, it only takes 12 minutes to display all results. We assume oracle has better performance. So what could be the problem here?
The perl code:
my $dbh = DBI->connect($databaseserver, $dbuser, $dbpassword,
{ 'AutoCommit' => 0,'RaiseError' => 1, 'PrintError' => 0 })
or die "couldn't connect to database: " . DBI->errstr;
open OUTPUTFILE, ">$temp_output_path";
my $rc;
my $sql="BEGIN DISPLAY_ADDRESS(:rc); END;";
my $sth = $dbh->prepare($sql) or die "Couldn't prepare statement: " . $dbh->errstr;
$sth->bind_param_inout(':rc', \$rc, 0, { ora_type=> ORA_RSET });
$sth->execute() or die "Couldn't execute statement: " . $sth->errstr;
while($address_info=$rc->fetchrow_arrayref()){
my ($firstname, $lastname, $street, $city, $STATE) = @$address_info;
print OUTPUTFILE $firstname."|".$lastname."|".$street."|".$city."|".$STATE;
$dbh->commit();
$dbh->disconnect();
close OUTPUTFILE;
Thanks!
rulinThanks for you reply!
1) The stored procedure has head
CREATE OR REPLACE PROCEDURE X_OWNER.DISPLAY_ADDRESS
cv_1 IN OUT SYS_REFCURSOR
AS
err_msg VARCHAR2(100);
BEGIN
--Adaptive Server has expanded all '*' elements in the following statement
OPEN cv_1 FOR
Select ...
commit;
EXCEPTION
WHEN OTHERS THEN
err_msg := SQLERRM;
dbms_output.put_line (err_msg);
ROLLBACK;
END;
If I only run select .. in DBArtisan, it display all 2030,000 rows in 3:44 minutes
2) But when call stored procedure, it will take 80-100 minutes .
3) The stored procedure is translated from sybase using migration tools, it's very simple, in sybase it just
CREATE PROCEDURE X_OWNER.DISPLAY_ADDRESS
AS
BEGIN
select ..
The select part is exact same.
4) The perl code is almost exact same, except the query sql:
sybase verson: my $sql ="exec DISPLAY_ADDRESS";
and no need bind the cursor parameter.
This is batch job, we create a file with all information, and ftp to clients everynight.
Thanks!
Rulin -
JDBC Result Set from Non-Database Source
In Java, is it possible to create a result set from a non-database data source?, for example an XML file, text file, vectors, java beans
We have a Swing application that currently makes direct JDBC calls to the DB2 database for creating result sets. We want to replace JDBC calls with calls to web service, but want to still create result sets on the client, so the replacement of the datasource from database to web service call is transparent to the rest of the code.In Java, is it possible to create a result set from a
non-database data source?, Yes.
for example an XML file,
text file, vectors, java beans
We have a Swing application that currently makes
direct JDBC calls to the DB2 database for creating
result sets. We want to replace JDBC calls with calls
to web service, but want to still create result sets
on the client, so the replacement of the datasource
from database to web service call is transparent to
the rest of the code.You might want to think carefully about what you are doing.
It is fairly easy, although somewhat tedious (many methods,) to create a new type of ResultSet.
But if the above application is doing SQL via statements and expecting the result via a ResultSet then you are not just creating a ResultSet but an entire driver and one that will have to deal with SQL as well. And if you have to handle the SQL itself that means you will probably need a parser and interpreter. -
Need help trying to transfer my information from one iphone to another
need help trying to transfer my information from one iphone to another
If you are restoring from an icloud backup you are going to have to erase a content and setting and while in the setup prompts you will get the option to restore from an icloud back...that's the only time you will get the option to restore from an icloud back and that's during setup
-
It is required to get the result set from the last query.
I need this SP to return the result set from the last query.
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
alter proc spQ_GetASCBillingRateIDs2
@ScheduleID CHAR(15),
@startdate smalldatetime,
@enddate smalldatetime
as
set nocount on
truncate table tbltmpgroup
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tbltmptbltest]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[tbltmptbltest]
exec sp_CreateTblTmpGroup
insert into tbltmpgroup
SELECT DISTINCT
case when pd.billparent = 'N' then org.eligibleorgid
else isnull(af.parentid, org.eligibleorgid) end as billorgid,
pd.individualbill , pd.cobrabill, pd.billparent,
org.eligibleorgid, org.polid, org.orgpolicyid,
pp.planid, pp.rateid,
ps.ascinvoicedate,
case when ps.ascclaimfromdate > @startdate then ps.ascclaimfromdate
else @startdate end as premiumrundayFrom,
case when ps.ascclaimtodate < @enddate then ps.ascclaimtodate
else @enddate end as premiumrundayTo,
fts.effdate, fts.termdate,
case when fts.effdate > @startdate then fts.EffDate
else @startdate end as ascStartDate,
case when fts.termdate < @enddate then fts.termdate
else @enddate end as ascEndDate
FROM premiumschedule ps (nolock)
inner join orgpolicy org (nolock)
on org.ascinvoicerungroup between ps.premiumrundayfrom and ps.premiumrundayto
inner join FundingTypeStatus fts
on fts.orgpolicyid = org.orgpolicyid
and fts.fundtype = 'ASC'
and ((fts.effdate between @startdate and @enddate)
or (fts.termdate between @startdate and @enddate)
or (fts.effdate < @startdate and fts.termdate > @enddate))
inner join eligibilityorg o (nolock)
on org.eligibleorgid = o.eligibleorgid
inner join policydef pd (nolock)
on pd.polid = org.polid
inner join policyplans pp (nolock)
on pp.polid = org.polid
inner join program p (nolock)
on pd.programid = p.programid
left join orgaffiliation af with (nolock)
on org.eligibleorgid = af.childid
WHERE ps.premiumscheduleid = @ScheduleID
AND org.orgpolicyid <> ''
go
SELECT DISTINCT z.rateid, e.enrollid, z.ascstartdate, z.ascenddate
into tbltmptbltest FROM enrollment E (nolock)
inner join tbltmpgroup z
on e.rateid = z.rateid
go
CREATE UNIQUE CLUSTERED INDEX IDXTempTable ON tbltmptbltest(enrollid)
create index IDXTemptableDates on tbltmptbltest(ascstartdate,ascenddate)
go
select distinct t.*
from tbltmpgroup t
where rateid in (
select distinct t.rateid from VW_ASC_Billing)
order by billorgid
set nocount off
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GOPlease post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules (you have no idea).
Temporal data should use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect.
What you did post is bad SQL.
The prefix “tbl-” is a design flaw called tibbling and we do not do it. We seldom use temp tables in RDBMS; it is how magnetic tape file programmers fake scratch tapes.
If the schema is correct, then SELECT DISTINCT is almost never used.
Your “bill_parent” looks like a assembly language bit flag; we never use those flags in SQL.
“Funding_Type_Status” is an absurd name for a table. A status is a state of being, not an entity. A type is an attribute property. So this table ought to be column that is either a “funding_type” or “funding_status” (with the time period for the state of being
shown in other columns). But this hybrid is not possible in a valid data model.
Want to try again, with DDL and some specs?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
I Need Help to Access The Source Code From A Form to Know the Calculation Formula
Hi,
I Need Help to Access The Source Code From A Form to Know the Calculation Formula. The application is a windows form application that is linked to SQL Server 2008. In one of the application forms it generates an invoice and does some calculations. I just
need to know where behind that form is the code that's doing the calculations to generate the invoice, I just need to get into the formula that's doing these calculations.
Thank you so much.Hi,
Thanks for the reply. This is a view and [AmountDue] is supposed to be [CurrentDueAmount] + [PastDueAmount] - [PaidAmount]. The view is not calculating [PaidAmount] right . Below is the complete code of the view. Do you see anything wrong in the code ?
Thanks.
SELECT [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
[iff].[FacilityFeeID], [LoanID] = NULL, [isi].[PortfolioID], [isi].[Portfolio],
[PaymentType] = [isis_fee].[SectionType], [Name]
= [iff].[Name], [ReceivedAmount], [dates].[CurrentDueAmount],
[PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount],
0) > 0 THEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0)
WHEN ISNULL([ReceivedAmount], 0)
< 0 THEN /* We bring past due to zero and
apply reset to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0)
< 0 THEN 0 ELSE [pastdue].[PastDueFeeAmount]
+ ISNULL([ReceivedAmount], 0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND
[pastdue].[PastDueFeeAmount] < 0 THEN 0 ELSE
[pastdue].[PastDueFeeAmount] END, [PaidAmount] = CASE WHEN ISNULL([ReceivedAmount], 0)
< 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [pastdue].[PastDueFeeAmount] + ISNULL([ReceivedAmount], 0)
< 0 THEN - ([pastdue].[PastDueFeeAmount]
+ ISNULL([ReceivedAmount], 0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND
[pastdue].[PastDueFeeAmount] < 0 THEN - [pastdue].[PastDueFeeAmount]
ELSE 0 END, [AmountDue] = [unpaid].[UnpaidFeeAmount], [ID] = [iff].[FacilityFeeID]
FROM [dbo].[INV_SubInvoice] isi JOIN
[dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
= [ii].[ID] JOIN
[dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
JOIN
[dbo].[INV_FacilityFee] iff ON [if].[ID] = [iff].[INV_FacilityID]
JOIN
(SELECT [sis_fee].[ID],
[sis_fee].[SectionTypeCode], [SectionType] = [st_fee].[Name], [sis_fee].[INV_FacilityFeeID]
FROM
[dbo].[INV_SubInvoiceSection] sis_fee JOIN
[dbo].[INV_SectionType] st_fee ON [sis_fee].[SectionTypeCode] = [st_fee].[Code]
WHERE [INV_FacilityFeeID]
IS NOT NULL AND [StatusCode] = 'BILL') isis_fee ON [iff].[ID] = [isis_fee].[INV_FacilityFeeID] JOIN
(SELECT [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]),
[AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedFeeAmount]),
[ReceivedAmount] = SUM([iffa].[ReceivedFeeAmount])
FROM
[dbo].[INV_FacilityFeeAccrual] iffa
GROUP BY [iffa].[SectionID])
dates ON [isis_fee].[ID] = [dates].[SectionID] LEFT JOIN
(SELECT *
FROM
[dbo].[INV_FacilityFeeAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND
[dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
LEFT JOIN
(SELECT [SectionID],
[PastDueFeeAmount] = SUM([PastDueFeeAmount])
FROM
[dbo].[INV_FacilityFeeAccrual]
GROUP BY [SectionID]) pastdue
ON [dates].[SectionID] = [pastdue].[SectionID]
UNION
SELECT [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
[FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio],
[PaymentType] = [isis_loan].[SectionType], [Name]
= [il].[Name], [ReceivedAmount], [CurrentDueAmount], [PastDueAmount] = CASE WHEN ISNULL([ReceivedAmount],
0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount],
0) WHEN ISNULL([ReceivedAmount], 0)
< 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0)
< 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND
[PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
END,
[PaidAmount] = CASE WHEN [isis_loan].[SectionTypeCode]
= 'LOAN_PRIN' THEN 0 ELSE CASE WHEN ISNULL([ReceivedAmount], 0)
< 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0)
< 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND
[PastDueAmount] < 0 THEN - [PastDueAmount]
ELSE 0 END END,
[AmountDue] = CASE WHEN [isis_loan].[SectionTypeCode]
= 'LOAN_PRIN' THEN [CurrentDueAmount] ELSE [unpaid].[AmountDue] END, [ID] = [il].[LoanID]
FROM [dbo].[INV_SubInvoice] isi JOIN
[dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
= [ii].[ID] JOIN
[dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
JOIN
[dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
JOIN
(SELECT [sis_loan].[ID],
[sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
FROM
[dbo].[INV_SubInvoiceSection] sis_loan JOIN
[dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
WHERE [INV_LoanID]
IS NOT NULL AND [StatusCode] = 'BILL') isis_loan ON [il].[ID] = [isis_loan].[INV_LoanID] JOIN
(SELECT [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]),
[AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[ExpectedPrincipalAmount]),
[ReceivedAmount] = SUM([ReceivedPrincipalAmount])
FROM
[dbo].[INV_LoanPrincipalAmortization] iffa
GROUP BY [iffa].[SectionID]
UNION
SELECT [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]),
[AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]),
[ReceivedAmount] = SUM([ReceivedInterestAmount])
FROM
[dbo].[INV_LoanCashInterestAccrual] iffa
GROUP BY [iffa].[SectionID]
UNION
SELECT [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]),
[AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]),
[ReceivedAmount] = SUM([ReceivedInterestAmount])
FROM
[dbo].[INV_LoanPIKInterestAccrual] iffa
GROUP BY [iffa].[SectionID])
dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
(SELECT [AmountDue]
= [UnpaidPrincipalAmount], [SectionID], [AccrualDeterminationDate]
FROM
[dbo].[INV_LoanPrincipalAmortization]
UNION
SELECT [AmountDue]
= [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
FROM
[dbo].[INV_LoanCashInterestAccrual]
UNION
SELECT [AmountDue]
= [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
FROM
[dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND
[dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
LEFT JOIN
(SELECT [PastDueAmount]
= SUM([PastDuePrincipalAmount]), [SectionID]
FROM
[dbo].[INV_LoanPrincipalAmortization]
GROUP BY [SectionID]
UNION
SELECT [PastDueAmount]
= SUM([PastDueInterestAmount]), [SectionID]
FROM
[dbo].[INV_LoanCashInterestAccrual]
GROUP BY [SectionID]
UNION
SELECT [PastDueAmount]
= SUM([PastDueInterestAmount]), [SectionID]
FROM
[dbo].[INV_LoanPIKInterestAccrual]
GROUP BY [SectionID]) pastdue
ON [dates].[SectionID] = [pastdue].[SectionID]
UNION
SELECT [isi].[InvoiceID], [ii].[DueDate], [SubInvoiceID] = [isi].[ID], [INV_FacilityID] = [if].[ID], [if].[FacilityID],
[FacilityFeeID] = NULL, [il].[LoanID], [isi].[PortfolioID], [isi].[Portfolio],
[PaymentType] = 'PIK Interest Applied', [Name]
= [il].[Name], [ReceivedAmount], [CurrentDueAmount] = - [dates].[CurrentDueAmount],
[PastDueAmount] = - CASE WHEN ISNULL([ReceivedAmount],
0) > 0 THEN [PastDueAmount] + ISNULL([ReceivedAmount], 0) WHEN ISNULL([ReceivedAmount], 0)
< 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0)
< 0 THEN 0 ELSE [PastDueAmount] + ISNULL([ReceivedAmount],
0) END WHEN ISNULL([ReceivedAmount], 0) = 0 AND
[PastDueAmount] < 0 THEN 0 ELSE [PastDueAmount]
END, [PaidAmount] = - CASE WHEN ISNULL([ReceivedAmount], 0)
< 0 THEN /* We bring past due to zero and
apply rest to current. */ CASE WHEN [PastDueAmount] + ISNULL([ReceivedAmount], 0)
< 0 THEN - ([PastDueAmount] + ISNULL([ReceivedAmount],
0)) ELSE 0 END WHEN ISNULL([ReceivedAmount], 0) = 0 AND
[PastDueAmount] < 0 THEN - [PastDueAmount]
ELSE 0 END, [AmountDue] = - [AmountDue], [ID] = [il].[LoanID]
FROM [dbo].[INV_SubInvoice] isi JOIN
[dbo].[INV_Invoice] ii ON [isi].[InvoiceID]
= [ii].[ID] JOIN
[dbo].[INV_Facility] [if] ON [isi].[ID] = [if].[SubInvoiceID]
JOIN
[dbo].[INV_Loan] il ON [if].[ID] = [il].[INV_FacilityID]
JOIN
(SELECT [sis_loan].[ID],
[sis_loan].[SectionTypeCode], [SectionType] = [st_loan].[Name], [sis_loan].[INV_LoanID]
FROM
[dbo].[INV_SubInvoiceSection] sis_loan JOIN
[dbo].[INV_SectionType] st_loan ON [sis_loan].[SectionTypeCode] = [st_loan].[Code]
WHERE [INV_LoanID]
IS NOT NULL AND [StatusCode] = 'BILL' AND [sis_loan].[SectionTypeCode] = 'LOAN_INT_PIK') isis_loan ON
[il].[ID] = [isis_loan].[INV_LoanID] JOIN
(SELECT [iffa].[SectionID],
[AccrualDeterminationDateMax] = MAX([iffa].[AccrualDeterminationDate]),
[AccrualDeterminationDateMin] = MIN([iffa].[AccrualDeterminationDate]), [CurrentDueAmount] = SUM([iffa].[AccruedInterestAmount]),
[ReceivedAmount] = SUM([ReceivedInterestAmount])
FROM
[dbo].[INV_LoanPIKInterestAccrual] iffa
GROUP BY [iffa].[SectionID])
dates ON [isis_loan].[ID] = [dates].[SectionID] LEFT JOIN
(SELECT [AmountDue]
= [UnpaidInterestAmount], [SectionID], [AccrualDeterminationDate]
FROM
[dbo].[INV_LoanPIKInterestAccrual]) unpaid ON [dates].[SectionID] = [unpaid].[SectionID] AND
[dates].[AccrualDeterminationDateMax] = [unpaid].[AccrualDeterminationDate]
LEFT JOIN
(SELECT [PastDueAmount]
= SUM([PastDueInterestAmount]), [SectionID]
FROM
[dbo].[INV_LoanPIKInterestAccrual]
GROUP BY [SectionID]) pastdue
ON [dates].[SectionID] = [pastdue].[SectionID] -
I need help with controlling two .swf's from third.
Hi, thanks for reading!
I need help with controlling two .swf's from third.
I have a problem where I need to use a corporate designed
.swf in a digital signage solution, but have been told by the legal
department that it can not be modified in any way, I also can't
have the source file yada yada. I pulled the .swfs from their
website and I decompiled them to see what I was up against.
The main swf that I need to control is HCIC.swf and the
problem is it starts w/ a preloader, which after loading stops on a
frame that requires user input (button press) on a play button,
before the movie will proceed and play through.
What I have done so far is to create a container swf,
HCIC_container.swf that will act as Target for the HCIC.swf, and
allow me to send actionscript to the file I'm not allowed to
modify.
I managed to get that done with the help of someone on
another forum. It was my hope that the following script would just
start HCIC.swf at a frame past the preloader and play button, and
just play through.
var container:MovieClip = createEmptyMovieClip("container",
getNextHighestDepth());
var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(this);
mcLoader.loadClip("MCIC.swf", container);
function onLoadInit(mc:MovieClip) {
mc.gotoAndPlay(14);
But unfortunately it didn't solve my problem. Because there
is a media-controller.swf, that is being loaded by HCIC.swf that
has the controls including the play button to start HCIC.swf.
Here's a link to a .zip file with all 3 .swf files, and all 3
.fla files.
http://www.axiscc.com/temp/HCIC.zip
What I need to do is automatically start the HCIC.swf file
bypassing the pre-loader and play button without editing it or the
media-controller.swf in anyway. So all the scripting needs to be
done in HCIC_container.swf.
I know this is confusing, and its difficult to explain, but
if you look at the files it should make sense.
ActionScripting is far from my strong point, so I'm
definitely over my head here.
Thanks for your help.Got my solution on another forum.
http://www.actionscript.org/forums/showthread.php3?t=146827 -
NEED HELP! - Installing Camera raw presets from USB Stick
NEED HELP! -installing Camera raw presets from USB Stick.
I am attempting to install the Camera Raw Presets.
It says to put them into User Name/Library/Application Support/Adobe/CameraRaw/Settings...
When I get to CameraRaw the ONLY folders in there are CameraProfiles & Lens Profiles.
I have searched everywhere looking for a CameraRaw-Settings folder and cannot find one.
I have latest version of CameraRaw installed and still no settings folder.
I even attempted to find it by looking in camera raw where it has saved the custom settings I made as presets and it shows that they are saved but will not show me where.
I am using CS5 specifically Photoshop v12.0.4 and Bridge. I have Lightroom 4. I have iMac OS 10.7.3
Do I need to reinstall Camera Raw and how do you do that?
Will I then lose my presets that I made in CameraRaw?
Thanks for your helpHere is a note from the ACR 7.1 beta release. http://labs.adobe.com/technologies/cameraraw7-1/?tabID=details
Perhaps this answers question.
Frequently Asked Questions
Why is it no longer required to place the plug-in file in the specified directory on my hard drive?
The Camera Raw update process has grown to include lens profile and camera profile files which are easiest to install via a single installer process instead of updating several different directories manually. -
How to export result set from mysql query browser to .sql in oracle
Hi folks:
I was trying to export result set from MySql query browser to Oracle. I could able to do
File->Export Result Set-> Excel format...
What I am trying to get is .sql file so that I can run it as a script in my oracle db. Is there any way we can get .sql file with inserts and delimeters ....?
Did you guys get my question.?
Please throw some light on this....
Could be very appreciable ....
Thanks
Sudhir NaiduHi
Create a sql statement which generates the insert statements.
Something like this:
select 'insert into table1 (column1, column2, column3) values (' ||
column1 || ', ' || column2 || ', ' || column3 || ');' from table 1;
The || sign is the string concatenation sign in Oracle, replace it the appropriate sign in MySql. Export the result set of this query into a file, and you can run it in a SqlPlus.
Ott Karesz
http://www.trendo-kft.hu -
I lost my ipod I really need help to find it. Im from other country and i cant buy another one. Is not connected to internet
There is nothing anyone can do.
Sorry.
You will have to keep looking for it -
Getting result set from stored procedures in database controls in weblogic
I am calling a stored procedure from database control which actually returns a result set
when i call the stored procedure like
* @jc:sql statement="call PROC4()"
ResultSet sampleProc() throws SQLException;
it gives me exception saying
"weblogic.jws.control.ControlException: Method sampleProc is DML but does not return void or int"
I would appreciate any help
Thanks,
UmaThanks for you reply!
1) The stored procedure has head
CREATE OR REPLACE PROCEDURE X_OWNER.DISPLAY_ADDRESS
cv_1 IN OUT SYS_REFCURSOR
AS
err_msg VARCHAR2(100);
BEGIN
--Adaptive Server has expanded all '*' elements in the following statement
OPEN cv_1 FOR
Select ...
commit;
EXCEPTION
WHEN OTHERS THEN
err_msg := SQLERRM;
dbms_output.put_line (err_msg);
ROLLBACK;
END;
If I only run select .. in DBArtisan, it display all 2030,000 rows in 3:44 minutes
2) But when call stored procedure, it will take 80-100 minutes .
3) The stored procedure is translated from sybase using migration tools, it's very simple, in sybase it just
CREATE PROCEDURE X_OWNER.DISPLAY_ADDRESS
AS
BEGIN
select ..
The select part is exact same.
4) The perl code is almost exact same, except the query sql:
sybase verson: my $sql ="exec DISPLAY_ADDRESS";
and no need bind the cursor parameter.
This is batch job, we create a file with all information, and ftp to clients everynight.
Thanks!
Rulin -
Returning result sets from PL/SQL procedure to client app.
I was wondering if its possible in Oracle PL/SQL to DECLARE, OPEN a cursor and exit
the procedure without closing the cursor
and then retrieve the resultset from
the client.
Pl let me know..
nullYes, you need to use one OUT parameter in your PL/SQL procedure
to pass the cursor variable to
Java code. You can also return that as a return variable of
PL/SQL function. Get the cursor variable from the resultset using
Types.CURSOR data type and then proceed as usual.
Enrique (guest) wrote:
: Thank you Rajib for your prompt reply. I have been programming
a
: lot in Transact SQL( MSSQL ), but I am new to Oracle and I need
: to migrate MSSQL procedures to Oracle. I will try to use the
: refCursors. One more question, how do I pass the cursors back?
: With OUT parameters? In MSSQL you do not need to specify OUT
: parameters if you are returning a result set.
: Once Again,
: Thank you
: Rajib (guest) wrote:
: : You can return a variable of refcursor type from your PL/SQL
: : procedure (PL/SQL 2.3 or higher) to Java code. Oracle JDBC
has
: a
: : refcursor data type. Now you can use this cursor as a
: resultset.
: : Enrique (guest) wrote:
: : : Hi All,
: : : I am trying to write some store procedures( PL/SQL )
: : that
: : : will select rows from my tables, and then pass then back to
: my
: : : JDBC application as result sets....Does anyone know how can
I
: : do
: : : that? Do I need to use output parameters? Or Return
: functions?
: : : Any help or hint wourl be be gladly appreciate it.
: : : Enrique
: : : Thank you.
null -
Error in result set from join query
I get a SQL exception from the JDBC thin driver when I make a getXXX( "string" ) call on a result set object when the query is a join. Aliases don't seem to help.
Below is the stack trace.
Anybody have any ideas?
matt
ResultSet.findColumn
java.sql.SQLException: Invalid column name: get_column_index
at oracle.jdbc.dbaccess.DBError.check_error(DBError.java:427)
at oracle.jdbc.driver.OracleStatement.get_column_index(OracleStatement.java, Compiled Code)
at oracle.jdbc.driver.OracleResultSet.findColumn(OracleResultSet.java:680)
at person.PersonMgr.getForEdit(PersonMgr.java:114)
at person.PersonMgr.getForView(PersonMgr.java:168)
at person.PersonMgr.getPersonForView(PersonMgr.java:164)
at nwsession.NWSession.login(NWSession.java:224)
at jsp.dologin._jspService(dologin.java:241)
at com.livesoftware.jsp.HttpJSPServlet.service(HttpJSPServlet.java:31)
at com.livesoftware.jsp.JSPServlet.service(JSPServlet.java:129)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:840)
at com.livesoftware.jrun.JRun.runServlet(JRun.java, Compiled Code)
at com.livesoftware.jrun.JRunGeneric.handleConnection(JRunGeneric.java:116)
at com.livesoftware.jrun.service.proxy.JRunProxyServiceHandler.handleRequest(JRunProxyServiceHandler.java, Compiled Code)
at com.livesoftware.jrun.service.ThreadConfigHandler.run(ThreadConfigHandler.java, Compiled Code)Your reference to NS.REQDATE is too deep. Oracle will only allow you to reference a column from the main query one level deep.
I think you can just change that query into this:
(Select AVG(((cpath.REQUESTDATETIME)- NS.REQDATE)*1440) AvgTime
FROM usersessiondetails cpath
Where cpath.Userkey=(Select Userkey from ods_user where userid=NS.UserId and namespace=NS.Namespace)
and cpath.acctnum=aCCTNUM
and cpath.transactionname IN (AUTH_LOGOFF' )
and cpath.REQUESTDATETIME = NS.REQDATE )You do not need the extra query level to do the AVG. -
ABAP routine - looping a result set from table.
I am trying to access a table and pass the resulting rows to an internal table.
However, before passing, I need to do some data manipulation on one of the columns of the table and then pass it.
If I didn't have to do this, I could have just said
INTO CORRESPONDING FIELDS OF TABLE
But since I have do data manipulation, I cannot do this. This is what I am doing now.
SELECT * FROM /BI0/QEMPLOYEE WHERE JOB = '1234' AND DATETO = '99991231'.
MOVE /BI0/QEMPLOYEE-EMPLOYEE TO INT_EMP-EMPN.
MOVE /BI0/QEMPLOYEE-JOB TO STR1.
STR2 = STR1 + 0(4)
SEARCH STR2 FOR ' ' STARTING AT 1 ENDING AT 1.
IF SY-SUBRC EQ 0.
REPLACE ' ' WITH '0' INTO STR2.
ENDIF.
MOVE STR2 TO INT_EMP-FAC.
But this will move only one row. How can I move all the rows? Is there a loop that I can use? I can see a loop for internal tables but I need to loop the result set and then send it. I posted this question twice but haven't gotten the right answer.
Thanks.Hi,
Are you trying to write the code in Update Routine or a Start Routine.?
If you want to update all the records, you can use the start routine.
So you need to use a loop for doing all the records.
If you are using a Update routine then you dont have to use the loop.
But here I recommend the Start Routine is the best choice.
Here is a document which can be helpful for you:
http://bluestonestep.com/component/option,com_docman/task,doc_download/gid,13/
Happy Tony -
So I have a chunk of data that only resides in Oracle. So I need to capture that information from Oracle. Now before you get over zealous, I did try with an OPENQUERY and it took FOREVER! And I don't know why the OPENQUERY took FOREVER but if I run the same
query directly against Oracle it runs very quickly...like 20 seconds.
So now I'm wondering...can I build a dataset in my SSRS Report that uses an Oracle Data source and an Oracle Stored Procedure in its Dataset that I'll create to aggregate this subset of data and then utilize its result set back in my main reporting
Dataset that will utilize SQL Server? And how can I do that? Can I make my main Dataset reference, say, a #TemporaryTable that is created from my Oracle Dataset in its
I'll continue to Google a few things as I await your review and hopefully a reply.
Thanks in advance for your help.Hi ITBobbyP,
According to your description you want to use data from a Oracle data source into a DataSet which retrieving data from SQL Server. Right?
In Reporting Services, we can have multiple data sources in one project pointing to different database. And we can use separated dataset to retrieve data from different data source. However, it's not supported to combine the two datasets together
directly. We can only use Lookup(), LookupSet() function to combine fields from different dataset into one tablix when there are common columns between two datasets. This is the only way to make tow result sets together in SSRS.
Reference:
Lookup Function (Report Builder and SSRS)
LookupSet Function (Report Builder and SSRS)
Best Regards,
Simon Hou
TechNet Community Support
Maybe you are looking for
-
My MacBook Pro (purchased in 2011) is taking 10 minutes to boot-up. It's also taking much longer to open files. I have 650 GB out of 700 GB left on my machine so it's not that I've overloaded the memory. Is anyone else having this problem?
-
Requirement of an alternative material
Hi, i have a requirement for a none stock material NLAG. Normaly such materials doesnt allow stock. I want to have something as an alternative materialnr which should be used for stock postings. That means i have several "none stock materials" which
-
Is there a SEARCH feature in Calendar?
I used the search feature to look for past events and appointments in my previous smartphone - is there a way to search for them in the iPhone? I don't see a "find" button anywhere...
-
Antivirus scan implementation for WebCenter Space/UCM upload document
Hi all, I am trying to find some information how to implement the anti-virus scanning engine in integrated Oracle Content Manager (UCM) in WebCenter Spaces. More specifically, when a user uploading a document in the Document Manager portlet by clicki
-
"Other" login option disappears/reappears. Need help preventing this!
I administer a Mac lab with 20 old 10.4.11 Macs. There are a variety of login options available on startup, most for specific grades in our school. One catchall login option is "Other". Once "Other" is selected, students have to enter their networ