best way to write this query
HelloI have a problem and I realized a simplified version of it:
create table deals (id_prsn number, id_deal number, fragment number);
create table deal_values (id_prsn number, id_deal number, value_ number, date_ date);
insert into deals values(1,1,50);
insert into deals values(2,2,40);
insert into deals values(1,3,50);
insert into deals values(2,4,80);
insert into deals values(1,5,20);
insert into deals values(2,6,80);
insert into deal_values values(1,1,10 ,sysdate - 3);
insert into deal_values values(2,2,208, sysdate - 3);
insert into deal_values values(2,4,984, sysdate - 3);
insert into deal_values values(1,null,134,sysdate - 3);
insert into deal_values values(1,1,13, sysdate - 2);
insert into deal_values values(2,2,118, sysdate - 2);
insert into deal_values values(2,4,776, sysdate - 1);
insert into deal_values values(1,null,205,sysdate - 1);
insert into deal_values values(2,null,-5,sysdate - 1);
The id of the requirement to join these two tables based on:1.) ID_PRSN and ID_DEAL
2.) max DATE_ grouped per person and deal
(3.) in the case that ID_DEAL is defined in the AGREEMENTS, but not defined in the DEAL_VALUES table, I have to join this records to DEAL_VALUES based on the person where id_Deal is null.
Number 3 gives me headache. I realized the following query:
select *from (
select a.id_prsn,
a.id_deal,
a.fragment,
b.value_,
b.date_,
max(b.date_) over (partition by b.id_prsn, b.id_deal) max_date
from deals a
inner join deal_values b
on a.id_deal = b.id_deal or b.id_deal is null
and not exists (select 1 from deal_values
where id_prsn = a.id_prsn
and id_deal = a.id_deal)
and a.id_prsn = b.id_prsn
)
where date_ = max_Date;
It returns the correct result of he,ID_PRSN ID_DEAL FRAGMENT VALUE_ DATE_ MAX_DATE
1 1 50 13 16.10.2012 09:59:48 16.10.2012 09:59:48
1 3 50 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
1 5 20 205 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
2 2 40 118 16.10.2012 09:59:48 16.10.2012 09:59:48
2 4 80 776 17.10.2012 09:59:48 17.10.2012 09:59:48
2 6 80-5 17.10.2012 09:59:48 17.10.2012 09:59:48 OK
but the join clause:
on a.id_deal = b.id_deal or b.id_deal is null
and not exists (select 1 from deal_values
where id_prsn = a.id_prsn
and id_deal = a.id_deal)
and a.id_prsn = b.id_prsn
in fact the query much slower.I was wondering is there a different way to write this join and manage the logic.
Thanks in advance
Here's a different approach:
select * from (
select a.id_prsn, a.id_deal, a.fragment, B.value_, b.date_,
ROW_NUMBER() over(
partition by a.ID_PRSN, a.ID_DEAL
order by B.ID_DEAL nulls last, B.DATE_ desc
) RN
from DEALS a
join DEAL_VALUES B
on a.ID_PRSN = B.ID_PRSN and a.ID_DEAL = NVL(B.ID_DEAL, a.ID_DEAL)
)
where rn = 1
order by 1, 2;
"nulls last" is the default sort order; I just put that for clarity.
Published by: stew Ashton on October 18, 2012 12:58
Tags: Database
Similar Questions
-
Best way to write this calc?
All currents are RED. All others are Sparse. 'Has' members accounts. This works very well and runs quickly, but just wants to make sure that it is recommended, etc. I tried to make ElseIf instead of opening of blocks every time, but it stopped working after all that 20th. I am also uncertain on what block missing is correct.
SET AGGMISSG
UPDATECALC OFF SET;
SET CREATENONMISSINGBLK
SET CREATEBLOCKONEQ
Difficulty ({RTP_Scenario}, {RTP_Year}, 'Work', 'No_Location')Difficulty ("TPD-90000", "PRJ-90001-LTVDS', 'No_Category')
("A-65000"
If (@ISMBR ("EC-OFFICESUPP") AND @ISMBR('Jan': 'Feb') AND @ISMBR ("TwoPlusTen") AND @ISMBR (& CurrFcstYr))
"A-65000"="A-65000"->"Pre real Alloc"->"Final"->"Total departments '->' locations '->' Total Categories '->' Total Total of charges Code."
Endif)("A-65100"
If (@ISMBR ("EC-SHIPPING') AND @ISMBR ('"Jan ":" Feb"') AND @ISMBR ("TwoPlusTen") AND @ISMBR (& CurrFcstYr))
"A-65100'='A-65100"->"Pre real Alloc"->"Final"->"Total departments '->' locations '->' Total Categories '->' Total Total of loads Code";
Endif)etc...
etc...
Two things you could try
1. put all Calc in a block unique member instead of each of them having its own
("A-65000"
If (@ISMBR ("EC-OFFICESUPP") AND @ISMBR('Jan': 'Feb') AND @ISMBR ("TwoPlusTen") AND @ISMBR (& CurrFcstYr))
'A-65000'='A-65000"->" Pre Alloc real '-> 'Final'-> 'Total departments'-> 'Total locations'-> 'Total categories'-> 'the Total expenses Code ";
Endif
If (@ISMBR ("EC-SHIPPING') AND @ISMBR ('"Jan ":" Feb"') AND @ISMBR ("TwoPlusTen") AND @ISMBR (& CurrFcstYr))
'A-65100'='A-65100"->" Pre Alloc real '-> 'Final'-> 'Total departments'-> 'Total locations'-> 'Total categories'-> 'the Total expenses Code ";
Endifetc...
)
the way in which each block is visited once
2. If you want to be more weird to get rid of the if statements (if the statements are slow)
'A-65000'-> ='A-65000"->" Pre Alloc' real' Final '-> 'Total departments '->' locations '->' categories Total Total'-> "The Total expenses Code" / @ISMBR("EC-OFFICESUPP") / @ISMBR("Jan":"Feb") / @ISMBR (& CurrFcstYr);
@ismbr returns a 1 if the Member and 0 if it is not. whatever this is divided by 0 is #missing
-
Another way to write the query:
Dear Experts, I am a beginner in sql. With my knowledge, I wrote this query
but he took great moment in my database 11g
Please tell any alternative to write this query in another way to increase performance
Please find the explanation below
SELECT DISTINCT * FROM UPGRADATION r1, LOG t2, OMNIACCOUNT m1, (SELECT rid , LISTAGG(ACCOUNTNO, ',') WITHIN GROUP (ORDER BY ACCOUNTNO) AS ACCOUNTNO FROM OMNIACCOUNT GROUP BY rid) mk3, (SELECT mobileno , LISTAGG(ACCOUNTNO, ',') WITHIN GROUP (ORDER BY ACCOUNTNO) AS ACCOUNTNO FROM OMNIACCOUNT GROUP BY mobileno) mk1, (SELECT mobileno , LISTAGG(ACCOUNTNO, ',') WITHIN GROUP (ORDER BY accounttype) AS ACCOUNTTYPE FROM OMNIACCOUNT GROUP BY mobileno) mk2 WHERE t2.txnauthid = r1.txnauthid AND r1.rid = mk3.rid AND t2.txntype = '54' AND mk1.mobileno = r1.regmobileno AND t2.reqtype = '11' AND t2.dc_id IN (SELECT deliverychannel_id FROM Channel) AND t2.custbankcode = '32472' AND t2.txndatetime BETWEEN TO_DATE ('28/12/2011 12:00:00 AM', 'DD/MM/YYYY hh:mi:ss AM' ) AND TO_DATE ('28/12/2012 11:59:59 PM', 'DD/MM/YYYY hh:mi:ss PM' ) AND r1.rid = m1.rid(+) AND t2.txnstatus IN ('C', 'F', 'T') AND t2.paymentinitiator = 'C' AND mk1.mobileno = mk2.mobileno Explain Plan For the above statement : ----------------------------------- SELECT STATEMENT FIRST_ROWSCost: 16 Bytes: 4,270 Cardinality: 1 25 HASH UNIQUE Cost: 16 Bytes: 4,270 Cardinality: 1 24 NESTED LOOPS Cost: 15 Bytes: 4,270 Cardinality: 1 19 NESTED LOOPS Cost: 14 Bytes: 4,270 Cardinality: 1 13 HASH JOIN Cost: 13 Bytes: 2,268 Cardinality: 1 9 NESTED LOOPS OUTER Cost: 4 Bytes: 252 Cardinality: 1 7 NESTED LOOPS Cost: 3 Bytes: 239 Cardinality: 1 4 NESTED LOOPS Cost: 2 Bytes: 119 Cardinality: 1 2 TABLE ACCESS BY INDEX ROWID TABLE LOG Cost: 1 Bytes: 116 Cardinality: 1 1 INDEX RANGE SCAN INDEX IX_LOG Cost: 1 Cardinality: 8 3 INDEX UNIQUE SCAN INDEX (UNIQUE) PK_Channel Cost: 1 Bytes: 3 Cardinality: 1 6 TABLE ACCESS BY INDEX ROWID TABLE UPGRADATION Cost: 1 Bytes: 120 Cardinality: 1 5 INDEX RANGE SCAN INDEX IDX_REG_AUTH Cost: 1 Cardinality: 1 8 INDEX RANGE SCAN INDEX IDX_MLTN_BNK_ACCT Cost: 1 Bytes: 13 Cardinality: 1 12 VIEW Cost: 8 Bytes: 1,110,816 Cardinality: 551 11 SORT GROUP BY Cost: 8 Bytes: 16,530 Cardinality: 551 10 TABLE ACCESS FULL TABLE OMNIACCOUNT Cost: 7 Bytes: 21,210 Cardinality: 707 18 VIEW PUSHED PREDICATE Cost: 1 Bytes: 2,002 Cardinality: 1 17 FILTER 16 SORT GROUP BY Bytes: 33 Cardinality: 1 15 TABLE ACCESS BY INDEX ROWID TABLE OMNIACCOUNT Cost: 1 Bytes: 33 Cardinality: 1 14 INDEX RANGE SCAN INDEX IDX_MUL_LNKG Cost: 1 Cardinality: 1 23 VIEW PUSHED PREDICATE Cost: 1 Cardinality: 1 22 FILTER 21 SORT GROUP BY Bytes: 29 Cardinality: 1 20 INDEX RANGE SCAN INDEX IDX_MLTN_BNK_ACCT Cost: 1 Bytes: 29 Cardinality: 1
It would be best to leave the desired projection.
Probably you don't really want all columns form this query.
However, these are your join criteria:t2.txnauthid = r1.txnauthid AND r1.rid = mk3.rid AND r1.regmobileno = mk1.mobileno AND mk1.mobileno = mk2.mobileno AND r1.rid = m1.rid(+)
Maybe you can get rid of AND mk1.mobileno = mk2.mobileno
with(SELECT mobileno , LISTAGG(ACCOUNTNO, ',') WITHIN GROUP (ORDER BY ACCOUNTNO) AS ACCOUNTNO , LISTAGG(ACCOUNTNO, ',') WITHIN GROUP (ORDER BY accounttype) AS ACCOUNTTYPE FROM OMNIACCOUNT GROUP BY mobileno)
After the combination seems to be suspicious:
AND r1.rid = mk3.rid AND r1.rid = m1.rid(+)
The first limit the result on all lines with the same id in
OMNIACCOUNT and UPGRADATION
so, o see no gain from the outer join.Do you really need the listagg on all OMNIACCOUNT lines.
If this isn't the case, it would be probably better to do the listagg in the final projection.Maybe one way could be to start with OMNIACCOUNT and join outer UPGRADATION to it.
You can do the listagg at the end.Maybe something like
select * from OMNIACCOUNT m1 left outer join (Select projection goes here from log t2 join UPGRADATION r1 on r1.txnauthid = t2.txnauthid AND t2.reqtype = '11' AND t2.dc_id IN (SELECT deliverychannel_id FROM Channel) AND t2.custbankcode = '32472' AND t2.txndatetime BETWEEN TO_DATE ('28/12/2011 12:00:00 AM', 'DD/MM/YYYY hh:mi:ss AM' ) AND TO_DATE ('28/12/2012 11:59:59 PM', 'DD/MM/YYYY hh:mi:ss PM' ) AND t2.txntype = '54' AND t2.txnstatus IN ('C', 'F', 'T') AND t2.paymentinitiator = 'C' ) r1 on m1.rid=r1.rid AND r1.regmobileno = m1.mobileno
Published by: chris227 on 10.01.2013 01:45
fix -
What is the best way to read this binary file?
I wrote a program that acquires data from a card DAQmx and he writes on a binary file (attached file and photo). The data I'm acquisition comes 2.5ms, 8-channel / s for at least 5 seconds. What is the best way to read this binary file, knowing that:
-I'll need it also on the graphic (after acquisition)
-J' I need also to see these values and use them later in Matlab.
I tried the 'chain of array to worksheet', but LabView goes out of memory (even if I don't use all 8 channels, but only 1).
LabView 8.6
I think that access to data is just as fast, what happens to a TDMS file which is an index generated in the TDMS file that says 'the byte positions xxxx data written yyyy' which is the only overload for TDMS files as far as I know.
We never had issues with data storage. Data acquisition, analysis and storage with > 500 kech. / s, the questions you get are normally most of the time a result of bad programming styles.
Tone
-
Better way to write this sql?
Hi guru, I was able to get what I want, but I find there must be a better way/more efficient way to write this sql?
Database: Oracle 11g
This is the create for the test database statement:
create table sample_test (prog_id number (9) DEFAULT 0 NOT NULL, chan_rights CHAR (2) DEFAULT ' ' NOT NULL)
This is the insert statement:
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A1')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A2')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A3')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A4')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A5')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A6')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (555633, 'A7')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'A1')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'A2')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'A3')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'B1')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'B2')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'B3')
INSERT INTO sample_test (prog_id, chan_rights) VALUES (495641, 'B4')
Here's what I did to get the data:
Select distinct a.prog_id, rt_cnt, CASE
WHEN a.rt_cnt = 7
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = 'A1')
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = "A2")
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = "A3")
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = 'A4')
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = 'A5')
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = 'A6')
and there are (select 'Y' b sample_test where a.prog_id = b.prog_id and b.chan_rights = 'A7')
THEN "A_ONLY".
else 'SINGLE '.
end CHAN_GROUP
from (select prog_id, count (chan_rights) rt_cnt
of sample_test
Prog_id group) a, b sample_test
where a.prog_id = b.prog_id
That appears as follows:
PROG_ID RT_CNT CHAN_GROUP 495641 7 UNIQUE 555633 7 A_ONLY As seen:
1 / I count how many rights is available, and in this case, each program gets a "7"
Set 2 / from these data, for each programme, I try to make sure it belongs to the company chan_rights right, for example, "A_ONLY". Therefore, as shown, Prog_ID 495641 does not contain "A_ONLY" channels listed in the case statement and there is unique. "A_ONLY" should only contain A1 to A7 inclusive and nothing else.
Can I create a function that returns the value "Chan_Group", but is there a better way to rewrite the statement 'BOX' like a LOOP or something? I have millions of records to go through and someone told me that using "is" slows down the database so just thought that I could ask ahead...
Please indicate if there is a better and more efficient method to get what I need?
Thank you
John
I would do something like
select prog_id, rt_cnt, (case when rt_cnt = 7 and num_a = 7 then 'A_ONLY' else 'UNIQUE' end) chan_group from (select prog_id, count(chan_rights) rt_cnt, sum( case when chan_rights in ('A1','A2','A3','A4','A5','A6','A7') then 1 else 0 end ) num_a from sample_test group by prog_id)
View of inline, I count the number of values chan_rights, as well as the number that are in your list of A1 - A7. In the outer query, I implement the logic that checks that the two charges are 7.
Here is an example of sqlfiddle this http://www.sqlfiddle.com/#! 4/95438/2
Justin
-
Can you help me? Is there a simpler way to write this short code?
Hi, I'm quite new to coding and EDGE and think there must be a simpler way to write this? :
sym.getSymbol("USA_animation").play ();
sym.getSymbol("World_map").play ();
sym.getComposition () .getStage ().getSymbol("UK_animation").$("UK").fadeOut ();
sym.getComposition () .getStage ().getSymbol("UK_animation").$("Piechart").fadeOut ();
sym.getComposition () .getStage ().getSymbol("UK_animation").$("people").fadeOut ();
sym.getComposition () .getStage ().getSymbol("UK_animation").$("PeopleText").fadeOut ();
sym.getComposition () .getStage ().getSymbol("UK_animation").$("UKText").fadeOut ();
sym.getComposition () .getStage ().getSymbol("AUS_animation").$("AUSTRALIA").fadeOut ();
sym.getComposition () .getStage ().getSymbol("USA_animation").$("USA").show ();
sym.getComposition () .getStage ().getSymbol("USA_animation").$("USAText").show ();
Can you help me?
Obivious to increase efficiency is
var USA_animation = sym.getSymbol ("USA_animation")
USA_animation. Play();
sym.getSymbol("World_map").play ();
USA_animation.$("UK").fadeout ();
USA_animation.$("PieChart").fadeout ();
USA_animation.$("people"). fadeOut();
USA_animation.$("PeopleText").fadeout ();
USA_animation.$("UKText").fadeout ();
USA_animation.$("AUSTRALI_A").fadeout ();
USA_animation.$("USA"). Show();
USA_animation.$("USAText"). Show();
If you perform a single operation on all the symbols of the "USA_animation" child, you can also reduce somethinng as
sym.getSymbol("World_map").play ();
var USA_animation = sym.getSymbol ("USA_animation")
USA_animation. Play();
var childSymbols = USA_animation.getChildSymbols (); f
for (var i = 0; i)
childSymbols [i] .fadeOut ();
I don't know if these are the best ways, but these are in a way that I could think of.
Let us know if offer you a lot shorted way to write this
-
AS3 on Flash CC - best way to write text on a curved path? to rotate the text?
AS3 on Flash CC - best way to write text on a curved path? to rotate the text?
you need to incorporate your policy.
-
I'm moving my files to workspaces to cloud.adobe. What is the best way to achieve this?
Hi Traci,
So big that you get ready for the transition to cloud.acrobat.com! Please see that the specified item was not found. For more detailed information on downloading your files.
When you open a session workspaces, however, you will see a big red box at the bottom left. Click this box, and your files will be packed to the top for you. You will receive an email with the instructions when the packaged files are ready for you.
Best,
Sara
-
I have an After Effects project and I want to re-do edge animate. What is the best way work for this?
Hello
Sorry, but you will probably need to rebuild everything in Animate. Although their timelines are similar in some ways, there is no interoperability between After Effects and animate dashboard.
Kind regards
Joe
-
No idea how to write this query
Hi, My Data is as below
DocNum doc_date type of amount
1154 15 November 11 232501.5 invoice
200206 4 November 11 - 243672.64 credit memo
Note flow 111 5 November 555.22 11
Output must be
DocNum doc_date amount Type AmountDR AmountCR
1154 232501.5 15 November 11 Bill 232501.5
Note credit 200206 4 November 11 - 243672.64 - 243672.64
Note flow 111 5 November 555.22 11 555.22
If the amount is > 0, then it must be displayed in the value of the amount to be AmountDR
If amount < 0 then it must be displayed in the value of the sum amount CR
Can help how to write this querywith sample_table as ( select 1154 Docnum,date '2011-11-15' doc_date,232501.5 Amount,'Invoice' type from dual union all select 200206,date '2011-11-04',-243672.64,'Credit Memo' from dual union all select 111,date '2011-11-05',555.22,'Debit Memo' from dual ) select Docnum, doc_date, Amount, type, case when Amount >= 0 then Amount end AmountDR, case when Amount < 0 then Amount end AmountCR from sample_table / DOCNUM DOC_DATE AMOUNT TYPE AMOUNTDR AMOUNTCR ---------- --------- ---------- ----------- ---------- ---------- 1154 15-NOV-11 232501.5 Invoice 232501.5 200206 04-NOV-11 -243672.64 Credit Memo -243672.64 111 05-NOV-11 555.22 Debit Memo 555.22 SQL>
SY.
-
Best way to film this scene, stitch together plates or green screen?
I have a call where I walk past a player with him framed on the right of the screen, ' actor A. ' then on the shoulder 'Actor A' (on the left side of the screen) another character is in sight, "actor B." at the end of shooting the camera move to stop and I want at the speed of the actor 'A' of the ramp so that it revolves around very quickly While the 'B' actor maintains a normal speed (which is him walking toward the camera as well). Is the best way to do this shoot with two plates separate and assemble them (if if, what is the best way to assemble the shots)? Or is - this green screen actor 'A' or 'B' and add them in? Remember, the camera moves to the rear while the actor 'A' heading, when moving player 'B' is also in the shot. Ramp speed of the actor 'A' occurs once it stops (it will whisk around extremely fast), how the camera will also be stopped.
You have a few options. Usually, I start a VFX shot by the thought of the movement of the camera. If I move the camera what are the problems that will result?
According to your description, you have a dolly with two actors. Tracks camera, the first actor as the second player enters the scene, then the unit stops and the second actor continues to his notes at normal speed while the first actor is accelerating. Two shooting plates will give control the moment where the first actor, but, in view of the camera move, requires you to simulate accurately the moment where two follow-up plans so the point of view between actors is consistent. It doesn't matter if the photos are on a green background. For the view between the two actors to match the camera moves must be identical to the camera angle and the speed of follow up.
If, however, you shoot all the action in a single pass while you can use rotoscoping to separate into two pieces shooting where the camera stops moving and then adjust the time where the first actor. This works easily if you make sure that you don't move the camera at all once the track ends.
If the players do not overlap so the second option is a piece of cake because your roto can be a very simple rough mask. If the players overlap in the framework then your roto work will have to be very precise when the players overlap, and you may need to perform a few background replacement to fill in the holes.
If you decide to do with two plates, then you will probably need to track movement. stabilisation and re-synchronization of two shots to make them at the height. If the camera is moving when you accelerate the first actor, you will have to keep track of movement.
A final option is to pull the first actor on a green screen and the second player as a bottom plate and then follow and stabilize the two shots to try to combine them. Here again, if the speed and angle of the two plans that you combine are not identical or at least nearby enough that you can easily fix them you'll be in a lot of tweaking to than the shots work.
If it were my project, I shoot the two actors in a single plug and then divided take it there where should be the first actor have the speed change and make a few roto work. That seems to be the most straightforward approach.
-
What is the best way to write freehand with InDesign?
I have a Wacom and want to put some writing on my document - what is the best way to do this?
Try a pencil or pen tools or do it in Photoshop and place.
Bob
-
Best way to write the Pl/Sql
Hi all
Can someone say best written below stored proc:
procedure missing_authorized_services is
v_truncate_sql varchar2 (200);
v_sql varchar2 (2000);
BEGIN
v_truncate_sql: = "truncate table missing_authorized_services;
immediately run v_truncate_sql;
commit;
v_sql: = "INSERT into missing_authorized_services select distinct trim (service_group_Cd) as service_group_Cd, trim (service_cd) as stage_1_mg_service_request service_cd
where (service_group_cd, service_cd) not in)
Select distinct service_group_cd, stage_3_servcd_servgrp_dim service_cd)';
immediately run v_sql;
commit;
END missing_authorized_services;
/ * I do select the table and then try to insert into another table the result set * /.
Please help,
Thank you
JHello
The best way to write the PL/SQL (or any code) is by small steps.
Start with a very simple procedure that does something (anything), just enough to make sure it works.
Add a lot of statements of output so you can see what made the procedure. Don't forget to delete them after that trial is over.For example:
CREATE OR REPLACE procedure missing_authorized_services IS v_truncate_sql VARCHAR2 (200); BEGIN v_truncate_sql := 'truncate table missing_authorized_services'; dbms_output.put_line ( v_truncate_sql || ' = v_truncate_sql inside missing_authorized_services' ); END missing_authorized_services;
If you get any errors (for example, ORA-00955, because you try to give the same name to a procedure that you already use for a table), then fix the error and try again.
When he worls perfectly, then add another baby step. For example, you can add the lineEXECUTE IMMEDIATE v_truncate_sql;
and test again.
Do not use SQL dynamic (EXECUTE IMMEDIATE) unless you have to.
Is there a reason to use dynamic SQL for INSERT statements? -
Best way to present a query recordset to a remote server
Hello, everyone.
I was responsible for a project that will involve querying a table on a server, then send the data to a remote server that will take the data and insert it into another database (the two db cannot communicate directly with each other).
I've never had to do something like that before. What is the best way to get the desired results? Is it possible to "petition" (anywhere from 1 to 5 files at a time) to the remote server without incorporating WDDX?
CF9 environment, soon CF10.
V/r,
^_^
Hi, @BKBK,
Not allowed.
This is the kind of tedious, but I've worked so far is having CF1 select data from DB1, SerializeJSON data, cfhttp allows to VALIDATE data for CF2.
THEN, CF2 DeserializeJSON data in a query object and that insert into DB2.
Unless you think there is a better way to do it?
V/r,
^_^
-
Looking for a better way to write this SQL
Oracle version 11R2
Version of the OS (any)
What I try to do is write a query that finds Public synonyms without a target object. I came up with this, but I think there is a better way.
object_type is null appears to be weak. It seems that the target object must be better.Select s.owner, s.synonym_name, s.table_name, s.table_owner, s.db_link, InitCap(o.object_type) object_type from sys.DBA_SYNONYMS s, sys.DBA_OBJECTS o where s.synonym_name is not null and s.table_owner = o.owner (+) and s.table_name = o.object_name (+) and s.owner = 'PUBLIC' and object_type is null;
Your comments, observations, questions welcome.I don't know exactly what 'better' means in this context (faster, easier to read, etc.), but I tend to use a NOT EXISTS
SELECT s.* FROM dba_synonyms s WHERE owner = 'PUBLIC' AND s.db_link IS NULL AND NOT EXISTS ( SELECT 1 FROM dba_objects o WHERE o.owner = s.table_owner AND o.object_name = s.table_name )
I added the criteria DB_LINK to filter the public synonyms referring to objects in remote databases that obviously do not exist in the local DBA_OBJECTS.
Justin
Maybe you are looking for
-
What is the latest version of firefox that works with albine 0,748?
My albine worked with the last version before I upgraded to 17. I have not spared this version and I would like to return. I save firefox 9 and this is what I use now, but I think that you have a newer version that I could use.What was the version pr
-
I discovered that the IPad is largely overrated. I fought with this mini IPad for 3 days to try to play my music it used. Now I show you 3 songs together several hundred, finding good luck helps these people.
-
HP zBook Studio G3: zBook Studio G3 - DEATH BY INTEL ME FIRMWARE UPDATE
WARNING! DO NOT INSTALL THE UPDATE OF THE COMPONENT OF THE (COMPANY) INTEL MANAGEMENT ENGINE FIRMWARE! http://h20566.www2.HP.com/hpsc/SWD/public/detail?sp4ts.Oid=8934841 & swItemId = ob_159465_1 & swEnvOid = 419... Component Firmware Intel management
-
Satellite P100 no sound with Vista --> Solution!
I think that I did... After many days my TOSHIBA P100-PSPA3E works, I believe, on Vista. What should do? Start by downloading the site inf chipset from intel:http://www.Intel.com/support/chipsets/sb/CS-022034.htm Install it and then restart. Then dow
-
M177 LaserJet MFP Pro: Printer screen locked up
Machine and Control Panel powers without problem, but the screen does not respond when you try to make a selection. I turned off, unplugged, restarted, etc. Any ideas? Thank you.