Need help with PL/SQL code
Hi I am writing this code in pl/SQL:create or replace
PROCEDURE 'TESTPRI '.
(NUMBER pCYC_DT)
AS
vTGT_TABL VARCHAR2 (25);
vSTG_TABL varchar2 (30);
vsql varchar2 (200);
BEGIN
vTGT_TABL: = 'TESTTABL ';
vSTG_TABL: = vTGT_TABL | » _'|| pCYC_DT;
vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;
EXECUTE IMMEDIATE vsql;
RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;
COMMIT;
-IMMEDIATE 'TRUNCATE TABLE ' | vSTG_TABL;
END TESTPRI;
When executing this procedure it gives me following error:
ORA-03290: Invalid command truncate - lack of key word TABLE or CLUSTER
ORA-06512: at "DBR. TESTPRI', line 11
ORA-06512: at line 6
But I think that the TRUNCATE TABLE statement is correct. Is there a problem with the variable?
Any help would be appreciated.
Thank you.
vsql: = 'TRUNCATE TABLE ' | vTGT_TABL;
You need space after the TABLE
vsql:= 'TRUNCATE TABLE ' ||vTGT_TABL ;
EXECUTE IMMEDIATE vsql;
RUN IMMEDIATELY "INSERT" | vTGT_TABL | ' SELECT * FROM '. vSTG_TABL;
Sapce here after INTO, before SELECT and FROM
EXECUTE IMMEDIATE 'INSERT INTO '|| vTGT_TABL||' SELECT * FROM '|| vSTG_TABL;
Tags: Database
Similar Questions
-
Hello
I have a data in table (raj_table) with columns (char11) raj_id, raj_number (varchar2 (15)), raj_format (NUMBER), Primary_ID (identity with the values of the primary key column)
Primary_ID raj_id Raj_number Raj_format
1 raj rajvend 1
2 raj rajvend 1
3 raj rajvendor1 2
4 raj rajvendor1 2
5 raj rajvendor1 2
6 raj rajvendor2 3
I used under SQL to get query output as below, but has not achieved the required result:
Select client_id vendor_number, vendor_format, primary_id, row_number() on sl_no (client_id partition, primary_id, vendor_format order of client_id primary_id, vendor_format, vendor_number, vendor_number)
from raj_table by sl_no asc
SL_NO raj_id raj_number raj_format primary_id
1 1 raj rajvendor 1
1 2 raj rajvendor 1
2 3 raj rajvendor1 2
2 4 raj rajvendor1 2
2 5 raj rajvendor1 2
3 6 raj rajvendor2 3
I need help with a SQL query to get the result as above without using the group by clause. I want to bring together the combination of separate line of the three columns (raj_id, raj_number, raj_format) and add a unique serial number for each online game (SL_NO column below). So, above there are 3 unique set of (raj_id, raj_number, raj_format) I can get in a group by clause, but I can not add prmiary_id, SL_NO values if I group by clause. I used the analytical functions like row_number() but no luck. Need solution for this.
with t as)
Select 'raj' raj_id, 'rajvend' raj_number, 1 raj_format, 1 primary_id Union double all the
Select option 2, 'raj', 'rajvend', 1 double Union all
Select 3, 'raj', 'rajvendor1', 2 double Union all
Select 4, 'raj', 'rajvendor1', 2 double Union all
Select 5, 'raj', 'rajvendor1', 2 double Union all
Select 6, 'raj', 'rajvendor2', 3 double
)
Select dense_rank() over (order of raj_id, raj_number, raj_format) sl_no,
t.*
t
order by primary_id
/
PRIMARY_ID RAJ RAJ_NUMBER RAJ_FORMAT SL_NO
---------- ---------- --- ---------- ----------
1 1 raj rajvend 1
1 2 raj rajvend 1
2 3 raj rajvendor1 2
2 4 raj rajvendor1 2
2 5 raj rajvendor1 2
3 6 raj rajvendor2 36 selected lines.
SQL >
SY.
-
Need help with query SQL Inline views + Group
Hello gurus,
I would really appreciate your time and effort on this application. I have the following data set.
Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 20.00 *---19
1234567 11223 - 05/07/2008 - 44345563 -a--10,00---19 ofbad quality adjustment
7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
Please ignore '-' added for clarity
I'm writing a paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, aggregate query Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Type, Invoice_Number, Vendor_Number. When there are no more records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date---description---Invoice_Number---Invoice_Type---Paid_Amount---Vendor_Number
1234567 11223 - 05/07/2008 -paid for cleaning- 44345563-I-* 10.00 *---19
7654321 11223 - 05/07/2008 - setting the last billing cycle - 23543556 - A - 50.00 - 19
4653456 11223 - 05/07/2008 - paid for cleaning - 35654765 - I - 30, 00-19
Here's my query. I'm a little lost.
Select b., A.sequence_id, A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
de)
Select sequence_id, check_number, check_date, invoice_number, sum (paid_amount) sum, vendor_number
of the INVOICE
Sequence_id group check_date, check_number, invoice_number, vendor_number
) A, B OF INVOICE
where A.sequence_id = B.sequence_id
Thank you
NickIt seems that this is a duplicate thread - correct me if I am wrong in this case->
Need help with query SQL Inline views + Group
Kind regards.
LOULOU.
-
Need help with PL/SQL query complex
I need help with a query that need access to data from 3 tables. That's what I did
I created 3 tables
CREATE TABLE post_table
(
post_id varchar (20),
datepost DATE,
KEY (post_id) elementary SCHOOL
) ;
CREATE TABLE topic
(
TOPIC_ID varchar (20),
name varchar (20),
PRIMARY KEY (topic_id)
);
CREATE TABLE blogpost_table
(
TOPIC_ID varchar (20),
post_id varchar (20),
PRIMARY KEY (topic_id, post_id);
FOREIGN KEY (topic_id) REFERENCES topic (topic_id) ON DELETE CASCADE,
FOREIGN KEY (post_id) REFERENCES post_table (post_id) ON DELETE CASCADE
);
Now, I inserted a few values in these tables as
INSERT INTO post_table VALUES ('p1', to_date ('2009-09-14 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p2', to_date ('2009-07-18 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p3', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p4', to_date ('2009-03-11 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p5', to_date ('2009-07-13 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p6', to_date ('2009-06-12 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO post_table VALUES ('p7', to_date ('2009-07-11 18:00 "," MM/DD/YYYY mi:ss'));))
INSERT INTO VALUES subject ("t1", "baseball");
INSERT INTO category VALUES ('t2', 'football');
INSERT INTO blogpost_table VALUES ("t1", "p1");
INSERT INTO blogpost_table VALUES ('t1', 'p3');
INSERT INTO blogpost_table VALUES ("t1", "p4");
INSERT INTO blogpost_table VALUES ('t1', 'p5');
INSERT INTO blogpost_table VALUES ('t2', 'p2');
INSERT INTO blogpost_table VALUES ('t2', 'p6');
INSERT INTO blogpost_table VALUES ("t2", "p7");
I'm launching SQL queries on the table in this topic.
I want to write a SQL query that returns me the name of a topic (s) and the number of blog_post (s) associated with the topic in descending order of the number of blog posts created in July.
Can someone please help me to write this query?
Thank you
Published by: user11994430 on October 9, 2009 07:24Thanks for the test of the configuration!
SQL>SELECT t.NAME, COUNT(*) 2 FROM topic t, blogpost_table b, post_table p 3 WHERE b.topic_id = t.topic_id 4 AND p.post_id = b.post_id 5 AND p.datepost >= DATE '2009-07-01' 6 AND p.datepost < DATE '2009-08-01' 7 GROUP BY t.NAME 8 ORDER BY COUNT(*) desc; NAME COUNT(*) -------------------- ---------- baseball 2 soccer 2
HTH, Urs
-
Need help with PL/SQL so and then select
Hello guys, I am new to the PL/SQl programming (only Java experience) and I'm pretty stuck to my task. It would be great if you could help me. I am in programming with Oracle SQL * Plus Version 10.2.0.3.0
Whenever a user logs on to the server a database entry is created with information about the logged-on user. I need to create a PL/SQL command that selects all the information from last month. Unfortunately, the date_stamp column has a certain weird format: 1131210 for December 10, 2013
My idea so far:
DECLARE
v_today NUMBER;
BEGIN
v_today: = TO_NUMBER (TO_CHAR (SYSDATE, 'MM')); -Save the number of the month (e.g.12) in v_today
IF v_today = 01 THEN
SELECT * from audittrl
WHERE the date_stamp between 1131201 AND the 1131231;
ELSIF v_today = 02 THEN
SELECT * from audittrl
WHERE the date_stamp between the 1130131 AND 1130101;
.......
END IF;
END;
/
Error code: "an INTO clause in this SELECT statement.
I do not want to save the result to select a variable, hope you can help me. Thanks in advance.
Hello
6a4d1bcd-c00e-4dac-AB64-9b6bdb1652d1 wrote:
Thanks, I'll try that, if still get caught once, I'll be back. Anway I'm not sure of the solution of Chris227, because I can't test it right now. From my point of view it gives you information the current month (e.g., December) and not the month previous (-online November), or have I missed something. ?
You are right. In addition, it does not for a given year. If you have data from several years in the table, it will select lines for the month of December 2012, 2011, 2010,... but also of 2013.
Here's a way to get around that:
DECLARE
prev_month_start PLS_INTEGER: = TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE-1)
, "YYMM"1' "01"
)
);
this_month_start PLS_INTEGER: = TO_NUMBER (TO_CHAR (SYSDATE
, "YYMM"1' "01"
)
);
BEGIN
FOR (IN) rec
SELECT *.
Of audittrl
WHERE the date_stamp > = prev_month_start
AND date_stamp< > >
ORDER BY user_id, date_stamp - or other)
LOOP
dbms_output.put_line (rec.date_stamp);
dbms_output.put_line (rec.event);
dbms_output.put_line (rec.user_id)
dbms_output.put_line (rec.host_name);
END LOOP;
END;This should also be more effective, because it will allow the optimizer to use an index on date_stamp. Even if there is no index, it will be more effective because it avoids calling any function (for example, SUBSTR) on each line of the table.
You needn't PL/SQL to get these results. Just use SQL, you might say:
SELECT event, host_name, user_id and date_stamp
Of audittrl
WHERE the date_stamp > = TO_NUMBER (TO_CHAR (ADD_MONTHS (SYSDATE-1)
, "YYMM"1' "01"
)
)
AND date_stamp< to_number="" (="" to_char="" (="" sysdate="" to_number="" (="" to_char="" (=""> >
, "YYMM"1' "01"
)
)ORDER BY user_id, date_stamp - or other
;
Your front end will provide column headers and touch the data so that the columns line up. It can also set the output to a file. (For example, if your front-end is SQL * Plus, you can use the command of the COIL.)
I guess date_stamp is a NUMBER. If it is a string, the solutions above can be simplified a bit.
This problem (and many other problems) would be so much simpler if date_stamp was a DATE column. Using numbers or strings to store the date information is simply asking for trouble.
-
Need help with the error Code 80244019 Windows Update
From: Doug
I get code 80244019 whenever I try to use Windows Update. I tried to change the DWORD in regedit nothing helps... Norton has recently found and 'resolved' trojan.zlob in 128 files in the registry, 21 cases (10 of which were in system32) and 1 browser cache. Whenever I try to use IE to go to http://windowsupdate.microsoft.com I am redirected to msn.com.
Any advice or solutions would be welcome.
From: PA bear [MS MVP]
Chances are that ZLOB was not completely removed and she was accompanied by infections Vundo and SDBot variant, all protected by a rootkit infection. You are going to need specialized assistance to clean this machine,
Unexplained computer behavior may be caused by deceptive software
http://support.Microsoft.com/kb/827315
Run a check of /thorough/ for hijackware, including post your hijackthis on a proper forum log.
Verification / help with Hijackware
http://aumha.org/a/parasite.htm
http://aumha.org/a/quickfix.htm
http://aumha.NET/viewtopic.php?t=5878
http://wiki.CastleCops.com/Malware_Removal_and_Prevention:_Introduction
http://MVPs.org/winhelp2002/unwanted.htm
http://inetexplorer.MVPs.org/data/prevention.htm
http://inetexplorer.MVPs.org/tshoot.html
http://www.MVPs.org/sramesh2k/Malware_Defence.htm
http://defendingyourmachine2.blogspot.com/
http://www.elephantboycomputers.com/page2.html#Removing_Malware
When all else fails, HijackThis v2.0.2
(http://aumha.org/downloads/hijackthis.exe) is the tool to use.
It will help you to identify and remove any hijackware/spyware with
assistance of an expert. * Post your log to
http://aumha.NET/viewforum.php?f=30,
http://forums.Spybot.info/forumdisplay.php?f=22,
http://CastleCops.com/forum67.html, or other appropriate review bodies
by an expert in the field, not here.* *.
If the procedures look too complex - and there is no shame in admitting
isn't your cup of tea - take the local machine, good reputation and
independent computer repair shop (i.e., not BigBoxStoreUSA).
--
~ Robear Dyer (PA Bear)
Another response of the community of Windows Vista discussion groups
-
Hello!
I need help, I don't know why I get errors with my code:
declare
xMin number (3) NOT NULL: = 50;
xMax number (3) NOT NULL: = 70;
yMin number (3): = 0;
yMax number (3): = 20;
Start
XMin CASE <-400 THEN
xMin = - 400;
ELSIF xMax > 400 THEN
xMax = 400;
ELSEIF yMin <-400 THEN
yMin = - 400;
ELSEIF yMax > 400 THEN
yMax = 400;
END IF;
Select sum (population) populacija
of naselje
where x BETWEEN xMin xMax AND
and is BETWEEN yMin AND yMax;
end;
error I get is:
ORA-06550: line 10, column 15:
Thanks for your help!
PLS-00103: encountered the symbol "=" when expecting one of the following conditions:
:= . ( @ % ;
The symbol ': = was inserted before '=' to continue. '
ORA-06550: line 12, column 15:
PLS-00103: encountered the symbol "=" when expecting one of the following conditions:
:= . ( @ % ;
1 declare
2 xMin number (3) NOT NULL: = 50;
3 xMax number (3) NOT NULL: = 70;
Kind regards
DraganFirst ELSEIF is incorrect, it must be ELSIF
AH, Yes, '=' must be ': = '.
Published by: Bob37 on May 16, 2012 12:10
-
Need help with Oracle SQL merge records according to date and term dates
Hi all
I need help to find this little challenge.
I have groups and flags and effective dashboards and dates of term against these indicators according to the following example:
GroupName Flag_A Flag_B Eff_date Term_date Group_A THERE THERE 20110101 99991231 Group_A N N 20100101 20101231 Group_A N N 20090101 20091231 Group_A N N 20060101 20081231 Group_A N THERE 20040101 20051231 Group_A THERE THERE 20030101 20031231 Group_B N THERE 20040101 99991231 Group_B N THERE 20030101 20031231 As you can see, group_A had the same combination of (N, N) flag for three successive periods. I want to merge all the time periods with the same indicators in one. Where entry into force will be the most early (underlined) time period and end date will be later (underlined)
So the final result should look like this:
GroupName Flag_A Flag_B Eff_date Term_date Group_A THERE THERE 20110101 99991231 Group_A N N 20060101 20101231 Group_A N THERE 20040101 20051231 Group_A THERE THERE 20030101 20031231 Group_B N THERE 20030101 99991231 Thanks for your help
Here's the DDL script
drop table TMP_group_test;
create table TMP_group_test (groupname varchar2 (8))
, flag_a varchar2 (1)
, flag_b varchar2 (1)
, eff_date varchar2 (8)
, term_date varchar2 (8)
);
insert into TMP_group_test values ('Group_A', 'Y', 'Y', ' 20110101 ', ' 99991231');
insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20100101 ', ' 20101231');
insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20090101 ', ' 20091231');
insert into TMP_group_test values ('Group_A', 'n', ' n ', ' 20060101 ', ' 20081231');
insert into TMP_group_test values ('Group_A', 'n', 'Y', ' 20040101 ', ' 20051231');
insert into TMP_group_test values ('Group_A', 'Y', 'Y', ' 20030101 ', ' 20031231');
insert into TMP_group_test values ('Group_B', 'n', 'Y', ' 20040101 ', ' 99991231');
insert into TMP_group_test values ('Group_B', 'n', 'Y', ' 20030101 ', ' 20031231');
commit;
Post edited by: user13040446
It is the closest, I went to the solution
I create two rows;
Rnk1: partition by group name, order of eff_date / / desc: this grade will sort the records of the most recent and handed to zero for each group\
Rnk2: (dense) partition by group name, flag_A, flagb: this grade for each combination of group\flag gives a number so that they are classified as "families".
Then I use the function analytic min
Min (eff_date) more (partition of GroupName, rnk2): the idea is that, for each Member of the same family, the new date is the min of the family (and the max for the date of the term), at the end I just need separate so that the duplicates are gone
Now the problem. As you can see from the query below, records of 1 and 6 (as identified by rownum) are identified in the same family, because they have the same combination of flag, but they are not successive, so everyone must keep its own date of entry into force.
If only I can make the distinction between these two that would solve my problem
Query:
Select rowNum,GroupName, flag_a, flag_b, eff_date, term_date, rnk1, rnk2
, min (eff_date) more than (partition by GroupName rnk2( ) min_eff
Of
(
Select rowNum,
GroupName , flag_a , flag_b , eff_date , term_date
rank() more than (partition by GroupName stopped by eff_date desc) rnk1
DENSE_RANK() more than (partition by GroupName order by flag_A flag_B ( ) rnk2
de dsreports . tmp_group_test
) order by rowNum
Hello
user13040446 wrote:
Hi KSI.
Thanks for your comments, you were able to distinguish between these lines highlight, but lost lines 2,3,4 which are supposed to have the same date min = 20060101.
Please see the table wanted to see the final result I want to reach
Thanks again
This first answer is basically correct, but in the main query, you want to use the function MIN, not the analytical function aggregation and GROUP BY columns with common values, like this:
WITH got_output_group AS
(
SELECT GroupName, flag_a, flag_b, eff_date, term_date
ROW_NUMBER () OVER (PARTITION BY GroupName
ORDER BY eff_date
)
-ROW_NUMBER () OVER (PARTITION BY GroupName, flag_a, flag_b)
ORDER BY eff_date
) AS output_group
OF tmp_group_test
)
SELECT GroupName, flag_a, flag_b
MIN (eff_date) AS eff_date
MAX (term_date) AS term_date
OF got_output_group
GROUP BY GroupName, flag_a, flag_b
output_group
ORDER BY GroupName
eff_date DESC
;
The result I get is
GROUP_NA F F EFF_DATE TERM_DAT
-------- - - -------- --------
Group_A Y 20110101 99991231 Y
N Group_A 20101231 20060101 N
Group_A N 20051231 20040101 Y
Group_A Y Y 20031231-20030101
Group_B N Y 99991231 20030101
which is what you asked for.
-
Hi all
I need to write a sql that retrieves data from the status table and check for this time in the ESHIFT table if the flag was or not. If is there, then it will keep the record as it is Furthermore, there
did not understand at the time the flag was N suppose ESHIFT table has one record where you N 13:00:01-13:30 then the status register which is 13:00-13:59 min 59 s, we should get 13:00 - 13: records of 00:00 1 and 2 of 13:30:01-13:59 min 59 s
create table ESHIFT (From_date date, date, to_date, flag varchar2 (2));
insert into ESHIFT values (' 1 February 12 09:00 ", February 1, 12 13:20 ', 'Y');
insert into ESHIFT values (' 1 February 12 13:20:01 ", 1 February 12 13:30 ',' don't);
insert into ESHIFT values (' 1 February 12 13:30:01 ", February 1, 12 16:00 ', 'Y');
SELECT * from eshift;
create table status (date of From_date, to_date date, status number);
insert into values of status (1 February 12 11:00 ', February 1, 12 12:00 ', 1);
insert into values of status (1 February 12 12:00:01 ', February 1, 12 12:20 ', 2);
insert into status values ("1 February 12 12:20:01", 1 February 12 12:59:59 ', 1);
insert into status values ("1 February 12 13:00", February 1, 12 13:59:59 ', 1);
insert into status values ("1 February 12 14:00", February 1, 12 14:59:59 ', 2);
SELECT * STATUS;
In the case above should get sql
1 FEBRUARY 12 11:00 1ST FEBRUARY 12 12:00 1
FEBRUARY 1ST, 12 12:00 1ST FEBRUARY 12 12:20 2
FEBRUARY 1ST, 12 12:20:01, 1 FEBRUARY 12 12:59:59 1
FEBRUARY 1ST, 12 13:00 1ST FEBRUARY 12 13:20 1
FEBRUARY 1ST, 12 13:30 1 FEBRUARY 12 13:59:59 1
FEBRUARY 1ST, 12 14:00 1 FEBRUARY 12 14:59:59 2
It will be really great if someone can help me how I can get the desired result.
Thank you very much in advance.
Please provide instructions creating table and data. It makes it so much easier to answer.
I think you want:
Select (s.from_date, e.from_date) greatest from_date, less (s.to_date, e.to_date) to_date, s.status
s status e eshift join on s.from_date < e.to_date="" and="" s.to_date=""> e.from_date and e.flag = 'Y '.
order by 1
-
need help with the error code 150:30
need help to find out what error code 150:30 is and how to fix it
See the following topics:
Error 150:30 - error "Licensing has stopped working". Mac OS:
http://helpx.Adobe.com/x-productkb/global/error-licensing-stopped-Mac-OS.html
-
Hello
I use oracle 10g and having some small doubts associated with sql, goes here of the situation
I have a Transaction table, which contains the records/operation made by an employee under a code of pattern on different dates, see below examples of data
Actually I want to have the final result as follows (p. ex. some how hide A003, see below for reason)EMP_CODE REASON_CODE DATE A001 B1 1st Jan 2009 A001 B1 3rd Jan 2009 A001 B1 6rd Jan 2009 A001 C2 9th Jan 2009 A002 D4 1st Jan 2009 A002 D4 3rd Jan 2009 A002 D5 6rd Jan 2009 A003 E6 6rd Jan 2009 A003 E6 7rd Jan 2009
So basically, print employee ID and reason code only if the employee has made the transaction under more than 1 code of reason, since the employee "A003" completed transaction code Minus 1 SINGLE code ONLY reason *, I don't want his record in printed.*A001 B1 A001 C2 A002 D4 A002 D5
the current query I wrote is as follows:
but this impression of results asselect emp_cd, reas_cd from employee_trans_table where reas_cd <> ' ' group by emp_cd, reas_cd order by emp_cd, reas_cd
How to avoid printing A003/E6 since she had only 1 reason code attached to it...A001 B1 A001 C2 A002 D4 A002 D5 *A003 E6*
I hope that I am able to clearly state the doubt that I am, let me know if you need any other info/clarrification on it.
Concerning
Learner
Published by: learner1 on October 26, 2009 13:33
Published by: learner1 on October 26, 2009 13:34
Published by: learner1 on October 26, 2009 13:36
Published by: learner1 on October 26, 2009 13:36 (added code tag)A possible solution.
with data as ( select 'A001' as col1, 'B1' as col2 from dual union all select 'A001' as col1, 'B1' as col2 from dual union all select 'A001' as col1, 'B1' as col2 from dual union all select 'A001' as col1, 'C2' as col2 from dual union all select 'A002' as col1, 'D4' as col2 from dual union all select 'A002' as col1, 'D4' as col2 from dual union all select 'A002' as col1, 'D5' as col2 from dual union all select 'A003' as col1, 'E6' as col2 from dual union all select 'A003' as col1, 'E6' as col2 from dual ) select distinct col1, col2 from ( select col1, col2, count(distinct col2) over (partition by col1) as distinct_count from data ) where distinct_count != 1
-
IP number looking for PSI - need help with a sql solution better and faster
Hello
I have a table (one) with more 1 000 000 IP addresses and numbers (the digital equivalent of the IP address)
I have a second table (b) which contains a mapping between the ranges of the ISP and IP. The table looks like this and more contains 150 000 entries:
BEGIN_IP_RANGE END_IP_RANGE ISP_NAME
-------------------------- ---------------------- --------------
600000000 700000000 ISP_X
800000000 900000000 ISP_Y
I'm creating a third table (c) which connects (a) IP numbers to identify the ISP from (B). The query looks like this:
CREATE TABLE c
AS
Select a.IP_ADDRESS
b.ISP_NAME
IP_NUMBERS a, ISP_LOOKUP b lkp
where a.IP_NUMBER between b.BEGIN_IP_RANGE and b.END_IP_RANGE
;
There is no key join between the 2 tables and so I use TO search for the access provider. The performace of it's terrible and table (c) takes several hours to create.
Does anyone have any thoughts/ideas/suggestions on how this research can be achieved by using a solution better and faster?
Thank you very much
Shah
The performace of it's terrible and table (c) takes several hours to create.
Hours what do you say?
See if the following can help.
Cardinalities are similar to yours. The ETG takes 7sec. :
SQL> create table ip_numbers (ip_address, ip_number) as 2 select cast(to_char(level,'fm099G999G999G999', 'nls_numeric_characters=,.') as varchar2(15)) 3 , level 4 from dual 5 connect by level <= 1000000 ; Table created. SQL> select * from ip_numbers where rownum <= 10; IP_ADDRESS IP_NUMBER --------------- ---------- 000.000.000.001 1 000.000.000.002 2 000.000.000.003 3 000.000.000.004 4 000.000.000.005 5 000.000.000.006 6 000.000.000.007 7 000.000.000.008 8 000.000.000.009 9 000.000.000.010 10 10 rows selected. SQL> SQL> create table isp_lookup (begin_ip_range, end_ip_range, isp_name) as 2 select 1 + (level-1)*5 3 , level*5 4 , cast('ISP_'||to_char(level,'fm099999') as varchar2(10)) 5 from dual 6 connect by level <= 200000 ; Table created. SQL> select * from isp_lookup where rownum <= 10; BEGIN_IP_RANGE END_IP_RANGE ISP_NAME -------------- ------------ ---------- 1 5 ISP_000001 6 10 ISP_000002 11 15 ISP_000003 16 20 ISP_000004 21 25 ISP_000005 26 30 ISP_000006 31 35 ISP_000007 36 40 ISP_000008 41 45 ISP_000009 46 50 ISP_000010 10 rows selected. SQL> create index ip_address_number_ix on ip_numbers (ip_number); Index created. SQL> set timing on SQL> SQL> create table ip_mappings as 2 select /*+ use_nl(a b) */ 3 a.ip_address 4 , b.isp_name 5 from isp_lookup b 6 join ip_numbers a on a.ip_number between b.begin_ip_range 7 and b.end_ip_range 8 ; Table created. Elapsed: 00:00:06.94 SQL> select count(*) from ip_mappings; COUNT(*) ---------- 1000000 Elapsed: 00:00:01.22
-
[Help] Need help with php, Sql variables
I have a users table contain fiedls "old, new and total."
When file, update user DEFINED total is $total
where $total = old + $nouveauI did it, I used echo to make sure it's ok, but it's not:
/ * Variable total Count * /.
$old = ['old'] $row_rs_users;
$new = $row_rs_users ['new'];
$total = $vieux + $new;
echo $total;
If ((isset($_POST["MM_update"])) & & ($_POST ["MM_update"] == "doit_form")) {}
$updateSQL = sprintf ("UPDATE users SET total = WHERE id = %s %s",)
$total,
GetSQLValueString ($_POST ['id'], "int"));Thank you
As a part of your code, it is impossible to debug.
However, your approach is bad anyway. All you need to do is add the new value to the old in the SQL query.
$updateSQL = sprintf("UPDATE users SET total=(total+%s) WHERE id=%s", GetSQLValueString($_POST['fieldName'], "double"), GetSQLValueString($_POST['id'], "int"));
$_POST ['fieldName'] is the new value. Use the 'double' if the value contains a decimal point. If it is an integer, replace 'double' 'int '.
-
Need help with the error code 80070424
I'm not able to update my windows vista. It gives the error code 80070424 and says 'windows can not find updates of nw'. I am not able to change all settings also unsuccessfully. Help, please.
Hello
Please, try the following:
Click Start > run >
Type the command of follow-up in the Open box.
"net.exe stop wuauserv" (without quotes)
Press OkRepeat the same for the following commands:
Regsvr32.exe c:\windows\system32\wuapi.dll
Regsvr32.exe c:\windows\system32\wups.dll
Regsvr32.exe c:\windows\system32\wuaueng.dll
Regsvr32.exe c:\windows\system32\dllcache\wucltui.dll
Regsvr32.exe MSXML3.dll
Regsvr32.exe qmgr.dll
Regsvr32.exe qmgrprxy.dll
NET.exe start wuauservRestart the computer and try again.
-
Need help with the error code Udates Windows 0 x 80070424
Hi, can someone give me some advice on how to enable Windows Auto Udates back, they seemed to have close the cottages and after trying to use all the options available I knew I am now facing an error code when I try to use the Microsoft Web site myself to get them. He responds just error Code 0 x 80070424. Thanks, any help would be great so if you "ve had this problem before or heard about what's going on could you please send me one. Brad
See: http://support.microsoft.com/kb/968002
-steve
Maybe you are looking for
-
new computer, win10, wnt to install the early version
I just got a new computer, old it will not start. I have a backup of my old drive that has iTunes on it. I moved it to my new drive C:, but it won't work, says "Reinstall". I don't want the latest version of iTunes, I want an earlier version that wil
-
Hi, new to the forum. Girls like has been stopped during the update of the VICTORY, now gets a blue screen of death. Unavailable recovery disks (purchase of 2012) Have the new HARD drive, would clean install WIN7 Home Premium Bootable USB with the im
-
Win 7 32 BIT drivers HP 15-r035tu
Hi, I bought a new HP 15 r035tu. I want to use win 7 32 bits of the operating system on this. I can't install the controller Ethernet, USB controller and PCI device drivers. Here is the hardware ID Controller Ethernet - PCI\VEN_10EC & DEV_8136 & SUBS
-
HP Envy 700-230: cards graphics/power supply for my computer
Hello I have a hp 700-230, (http://support.hp.com/us-en/document/c04058435 I'm looking to get a new graphics card for games. What grapihcs cards are good and compatible with this computer given its components and power supply (only 300 watts)? The ge
-
XP games have been removed, how to make them return
installation of games I have a XP system and a few games (solitaire, hearts, free cell, spider solitaire) were withdrawn. Is there a way I can reinstall them or copy them from another computer?