SQL query, function or SP for converting varbinary to image(.jpg format).
Dear Sir/Mam
I want SQL query, function or SP which converts binary data to image (.jpg format).
I m able to convert image (.jpg format) to varbinary. But not able to convert vice versa.
thanks in advance.
Binary data is binary data - "image" is only an intrepretation of binary data. Therefore your question makes little sense in the context of sql server since it does not have any facilities to utilize images. Since you provide no context, I'm
guessing that you are trying to retrieve an image stored in the database in a varbinary column and have your application use it as an image. If so, you should post your question to a forum that is specific to your development environment.
Similar Messages
-
What is the best software for converting video files to .ogg format?
In trying to html5 compliant I want to convert my video files to the .ogg format. After a lot of searching for video converters, I cannot find one that does this; although several claim to but actually don't. Converting audio isn't so much of a problem. So, can you suggest a tool for converting video files to .ogg format?
See this Wikipedia article for some encoders:
* http://en.wikipedia.org/wiki/Theora#Encoding -
SQL Query - store the result for optimization?
Good day experts,
I am looking for advice on a report. I did a lot of analytic functions to get core data that I need to make my report and its takes around 50 min for SQL to complete. Now with this data I need to create 3 different reports and I cant use the same SQL since there is a lot of agregation (example would be group by product in one case and by client in 2nd). For each of those different group bys I need a different report.
So how to create 3 reports from 1 SQL query without running the query 3 times?
First thing that comes to mind is to store the result set into a dummy table and then query the table since the core data I get is around 300 rows and then do different group bys.
Best regards,
IgorSo how to create 3 reports from 1 SQL query without running the query 3 times?
You already know the obvious answer - store the data 'somewhere'.
The appropriate 'somewhere' depends on your actual business requirements and you did not provide ALL of them.
MV - if the query is always the same you could use an MV and do a complete refresh when you want new data. The data is permanent and can be queried by other sessions but the query that accesses the data will be frozen into the MV definition.
GTT (global temp table) - if a NEW data load AND the three reports will ALWAYS be executed by a single session and then the data is NOT needed anymore then a GTT can work. The query that loads the GTT can be different for each run but the data will only be available for a single session and ONLY for the life of that session. So if anything goes wrong and the session terminates the data is gone.
First thing that comes to mind is to store the result set into a dummy table and then query the table since the core data I get is around 300 rows and then do different group bys.
That is commonly referred to as a 'REPORT-READY table'. Those are useful when the data needs to be permanent and available to multiple sessions/users. Typically there is a batch process (e.g. package procedure) that periodically refreshes/updates the data during an outage window. Or the table can have a column (e.g. AS_OF) that lets it contain multiple sets of data and the update process leaves existing data alone and creates a new set of data.
If your core data is around 300 rows you may want to consider a report-ready table and even using it to contain multiple sets of data. Then the reports can be written to query the data using an AS_OF value that rolls up and returns the proper data. You don't need an outage window since older data is always available (but can be deleted when you no longer need it.
If you only need one set of data you could use a partitioned work table (with only one partition) to gather the new set of data and then an EXCHANGE PARTITION to 'swap' in the new data. That 'exchange' only takes a fraction of a second and avoids an outage window. Once the swap is done any user query will get the new data. -
Sql query/function problem??
Hi ,
I have problems writing a difficult sql query, please help me
I have a table t in which there are 50000 records
the table has columns like
create table t
(MATCH_ID NUMBER(4) NOT NULL,
TEAM_ID NUMBER(4),
PLAYER_ID NUMBER(4),
RUNS NUMBER(3))
here match_id, player_id and team_id are jointly primary key
SQL> SELECT * FORM T WHERE MATCH_ID < 10
MATCH_ID TEAM_ID PL_ID RUNS
1 2 1228 8
1 2 1203 82
1 2 1316 24
1 1 1150 27
1 1 1278 13
1 1 1243 60
2 1 1278 37
2 1 1291 0
2 1 1243 53
2 2 1228 25
2 2 1285 103
2 2 1316 60
3 2 1228 8
3 2 1285 25
3 2 858 43
3 1 1278 52
3 1 1394 6
3 1 1243 31
4 1 1278 61
4 1 1394 6
4 1 1243 3
4 2 1228 41
4 2 1285 40
4 2 858 5
6 2 1228 20
6 2 1285 100
6 2 1408 0
7 2 1228 15
7 2 1285 34
7 2 1408 44
8 2 1228 0
8 2 1420 31
8 2 1340 66
9 2 1420 19
9 2 1385 28
9 2 1340 0
.....so on upto 50000 records..
the problem is that I want to extract how many times each player_id in each
match exists in the table, prior to that match_id (or current_match_id)
along with that in another column, I also want the sum of 'RUNS' for each
player_id prior to that match_id (or current_match_id)
my disired output is:
MATCH_ID TEAM_ID player_ID RUNS NO_OF_OCCURENCES SUM(RUNS)
BEFORE_THIS_MATCH BEFORE_THIS_MATCH
FOR_THIS_PLAYER_ID FOR_THIS_PLAYER_ID
1 2 1228 8 0 0
1 2 1203 82 0 0
1 2 1316 24 0 0
1 1 1150 27 0 0
1 1 1278 13 0 0
1 1 1243 60 0 0
2 1 1278 37 1 13
2 1 1291 0 0 0
2 1 1243 53 1 60
2 2 1228 25 1 8
2 2 1285 103 0 0
2 2 1316 60 1 24
3 2 1228 8 2 33
3 2 1285 25 1 103
3 2 858 43 0 0
3 1 1278 52 2 50
3 1 1394 6 0 0
3 1 1243 31 2 113
4 1 1278 61 3 102
4 1 1394 6 1 6
4 1 1243 3 3 144
4 2 1228 41 3 41
4 2 1285 40 2 128
4 2 858 5 1 43
6 2 1228 20 4 82
6 2 1285 100 3 168
6 2 1408 0 0 0
7 2 1228 15 5 102
7 2 1285 34 4 268
7 2 1408 44 1 0
8 2 1228 0 6 117
8 2 1420 31 0 0
8 2 1340 66 0 0
9 2 1420 19 1 31
9 2 1385 28 0 0
9 2 1340 0 1 66
as you can see from the above data (5TH COLUMN), i have mentioned the
existance of each player_id in each match prior to the current_match_id
since match_id = 1 is the 1st match in the table so no player_id comes in the
table before match number 1.
In match number 2 , player_id = 1278 was also present in match_id = 1 so
thats why Number_OF_OCCURENCES = 1 for player_id = 1278 in match_id = 2
and so on..
same is the case with 'RUNS' column but here RUNS are the SUM of each
player_id's 'RUNS' before the current match
Note: if some player_id does not exist in the table before the current
match_ID then the query should return zero for that player_id ( as in 4th and
5th columns of no_of_occurances and sum(runs) respectively)
for example: in above data
MATCH_ID TEAM_ID PLayer_ID RUNS NO_OF_OCCURENCES SUM(RUNS)
BEFORE_THIS_MATCH BEFORE_THIS_MATCH
FOR_THIS_PLAYER_ID FOR_THIS_PLAYER_ID
9 2 1385 28 0 0
I hope this will clear my problem
i would be extremely grateful if someone helps me out??
here is sample ddl of the above data
create table t
(MATCH_ID NUMBER(4) NOT NULL,
TEAM_ID NUMBER(4),
PLAYER_ID NUMBER(4),
RUNS NUMBER(3))
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1228, 8);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1203, 82);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 2, 1316, 24);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1150, 27);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1278, 13);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (1, 1, 1243, 60);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1278, 37);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1291, 0);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 1, 1243, 53);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1228, 25);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1285, 103);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (2, 2, 1316, 60);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 1228, 8);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 1285, 25);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 2, 858, 43);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1278, 52);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1394, 6);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (3, 1, 1243, 31);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1278, 61);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1394, 6);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 1, 1243, 3);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 1228, 41);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 1285, 40);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (4, 2, 858, 5);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1228, 20);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1285, 100);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (6, 2, 1408, 0);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1228, 15);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1285, 34);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (7, 2, 1408, 44);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1228, 0);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1420, 31);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (8, 2, 1340, 66);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1420, 19);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1385, 28);
insert into t (MATCH_ID, TEAM_ID, PLAYER_ID, RUNS) values (9, 2, 1340, 0);regards
ramis.Ramis,
SQL> select * from tt;
MATCH_ID TEAM_ID PLAYER_ID RUNS
1 2 1228 8
1 2 1203 82
1 2 1316 24
1 1 1150 27
1 1 1278 13
1 1 1243 60
2 1 1278 37
2 1 1291 0
2 1 1243 53
2 2 1228 25
2 2 1285 103
2 2 1316 60
3 2 1228 8
3 2 1285 25
3 2 858 43
3 1 1278 52
3 1 1394 6
3 1 1243 31
4 1 1278 61
4 1 1394 6
4 1 1243 3
4 2 1228 41
4 2 1285 40
4 2 858 5
6 2 1228 20
6 2 1285 100
6 2 1408 0
7 2 1228 15
7 2 1285 34
7 2 1408 44
8 2 1228 0
8 2 1420 31
8 2 1340 66
9 2 1420 19
9 2 1385 28
9 2 1340 0
36 rows selected.
SQL> select tt.match_id,
tt.team_id,
tt.player_id,
tt.runs,
nvl(a.sum_player,0) OCC,
nvl(b.sum_runs,0) SUM_RUNS
from
tt,
(select a.match_id,a.team_id,a.player_id,a.runs,count(*) sum_player
from tt a,
(select match_id,player_id
from tt
group by match_id,player_id) b
where a.match_id>b.match_id
and a.player_id=b.player_id
group by a.match_id,a.team_id,a.player_id,a.runs
) a,
(select a.match_id,a.team_id,a.player_id,a.runs,sum(b.runs) sum_runs
from tt a,
(select match_id,player_id,runs
from tt) b
where a.match_id>b.match_id
and a.player_id=b.player_id
group by a.match_id,a.team_id,a.player_id,a.runs
) b
where tt.match_id=a.match_id(+)
and tt.team_id=a.team_id(+)
and tt.player_id=a.player_id(+)
and tt.match_id=b.match_id(+)
and tt.team_id=b.team_id(+)
and tt.player_id=b.player_id(+)
MATCH_ID TEAM_ID PLAYER_ID RUNS OCC SUM_RUNS
1 1 1150 27 0 0
1 1 1243 60 0 0
1 1 1278 13 0 0
1 2 1203 82 0 0
1 2 1228 8 0 0
1 2 1316 24 0 0
2 1 1243 53 1 60
2 1 1278 37 1 13
2 1 1291 0 0 0
2 2 1228 25 1 8
2 2 1285 103 0 0
2 2 1316 60 1 24
3 1 1243 31 2 113
3 1 1278 52 2 50
3 1 1394 6 0 0
3 2 858 43 0 0
3 2 1228 8 2 33
3 2 1285 25 1 103
4 1 1243 3 3 144
4 1 1278 61 3 102
4 1 1394 6 1 6
4 2 858 5 1 43
4 2 1228 41 3 41
4 2 1285 40 2 128
6 2 1228 20 4 82
6 2 1285 100 3 168
6 2 1408 0 0 0
7 2 1228 15 5 102
7 2 1285 34 4 268
7 2 1408 44 1 0
8 2 1228 0 6 117
8 2 1340 66 0 0
8 2 1420 31 0 0
9 2 1340 0 1 66
9 2 1385 28 0 0
9 2 1420 19 1 31
36 rows selected.
SQL> Is this do you want ?
Nicolas. -
How to know which sql query is taking time for concurrent program
Hi sir,
I am running concurrent program,that is taking time to execute ,i want to know which sql query causing performance
Thanaks,
SreekanthHi,
My Learning: Diagnosing Oracle Applications Concurrent Programmes - 11i/R12
How to run a Trace for a Concurrent Program? (Doc ID 415640.1)
FAQ: Common Tracing Techniques in Oracle E-Business Applications 11i and R12 (Doc ID 296559.1)
How To Get Level 12 Trace And FND Debug File For Concurrent Programs (Doc ID 726039.1)
How To Trace a Concurrent Request And Generate TKPROF File (Doc ID 453527.1)
Regards
Yoonas -
Function module for convert date as sap internal format ?
Hi All,
Is there any standard function module to convert the date filed as SAP internal date?
My problem is while uploading data from excel sheet date filed can be any format
for exp: dd/mm/yyyy or mm/dd/yyyy or yyyy/dd/mm or dd-mm-yyyy,mm-dd-yyyy
dd-mm-yyyy or dd.mm.yyyy or mm.dd.yyyy etc...
In our case there is no particular format in excel it can be differ for each user. I know we have few FM's in standard.
But those are not working for my req. pls help me if you have any idea.
Thanks in advance.
Regards,
Venkat Mote.Hi Venkatesh,
Can you please check with the following function module. For my case, it is working fine.
CALL FUNCTION 'CONVERT_DATE_TO_INTERN_FORMAT'
EXPORTING
datum = p_gs_date
dtype = 'DATS'
IMPORTING
idate = p_gs_date
Hope it helps to you.
Regards
Rajkumar Narasimman -
Sql query to betwen clause for date
i have a interface there user can enter two dates . in my servlet program i am getting it as string by using request .get parameter. i wanan to know how to write sql query for selecting data from database with between clause
i have a interface there user can enter two dates . in my servlet program i am getting it as string by using request .get parameter. i wanan to know how to write sql query for selecting data from database with between clause
-
SQL query to get DDL for Adding PK.
Guys,
I'm looking for SQL query that gets me the "ALTER TABLE <TABLE_NAME> ADD CONSTRAINT <constraint_name> PRIMARY KEY (X,Y,...);" statments of all tables in my schema containing Primary Keys.
Could someone help me with the query please?
Regards,
BhagatYou need this
SELECT 'ALTER TABLE '||table_name||' ADD CONSTRAINT '||constraint_name||' PRIMARY KEY ('||column_name||');'
FROM ( SELECT uc.table_name
,uc.constraint_name
,RTRIM (XMLAGG (XMLELEMENT (ucc, column_name || ',')).extract ('//text()'), ',') column_name
FROM user_constraints uc
,user_cons_columns ucc
WHERE uc.constraint_type = 'P'
AND uc.constraint_name = ucc.constraint_name
GROUP BY uc.table_name
,uc.constraint_name
ORDER BY table_name; Regards
Arun -
Sql query question - been trying for two days
Hi guys im trying to carry out an sql query
Im using a left join to do a query, which gives me a set of results:
select COURSESTUDENT.StudentNo, COURSESTUDENT.CourseCode, COURSESTUDENT.Year, MARKS.ExamMark, MARKS.EntryNo FROM COURSESTUDENT LEFT JOIN MARKS ON COURSESTUDENT.StudentNo=MARKS.StudentNo AND COURSESTUDENT.CourseCode=MARKS.CourseCode AND COURSESTUDENT.Year=MARKS.Year
but I would like to do a select on this result but do not want to use a create view as if more than one person access this page at a time then if the servlet tries to create the view an error will occur.
I would like to do the following select statement on the results of the query above..
select * from (above) where CourseCode='ELE304' AND Year=1999;
Is this possible, im using postgres..
Please help......
thanks
tzafSorry, I have never used postgres, but in several databases, the following syntax would work and provide the correct ResultSet.
select *
from (
SELECT
COURSESTUDENT.StudentNo,
COURSESTUDENT.CourseCode,
COURSESTUDENT.Year,
MARKS.ExamMark,
MARKS.EntryNo
FROM
COURSESTUDENT LEFT JOIN MARKS ON
COURSESTUDENT.StudentNo=MARKS.StudentNo AND
COURSESTUDENT.CourseCode=MARKS.CourseCode AND
COURSESTUDENT.Year=MARKS.Year
) A
WHERE
CourseCode='ELE304' AND
Year=1999 -
FB for converting inputed period into period format of the user
Hi All,
my concern is to convert from to another period format.
For example:
in my user-profile is setted the following format: DD/MM/YYYY
what i do input is a period with format: DD.MM.YYYY
Does a FB exists in BW that can help with this task?hi,
do like this.
code]DATA: V_DATE_IN(10) TYPE C,
V_DATE_SAP TYPE SY-DATUM.
V_DATE_IN = '01.01.2005.'.----------------------> ur input
CONCATENATE V_DATE_IN+6(4) "<--for Year
V_DATE_IN+3(2) "<--for month
V_DATE_IN+0(2) "<--for Day
INTO V_DATE_SAP.
now V_DATE_SAP will have value like 20060101.
pass the above to this FM.
data:date_form type CHAR10.
call function 'HRGPBS_HESA_DATE_FORMAT'
exporting
P_DATE = V_DATE_SAP -
> input date
importing
DATESTRING = date_form
exceptions
others = 1.[/code]
date_from -
> DD/MM/YYYY fomat
rgds
Anver
if hlped pls mark points -
Image resolution for converted documents and images
We are converting documents from several different formats to PDF. We have a requirement that the images must be 300 dpi when converted. I turned off the down sampling option in PDF settings. However, the images are all coming out at 72 dpi. So I have some questions.
Is there a way to control the dpi of a converted image?
How about an image embedded in a document?
Is there any easy way to check the dpi of an image in a PDF? The only way I've found to check the image dpi is use preflight in Acrobat.
-KellyNo good.
I've followed the instructions 3 times to the letter and it still opens without any mention of a password request. In fairness, its exactly the same process I followed with the Google instructions so I am at a complete loss with this one.
Maybe my Macbook is configured wrong somewhere. I'll have to take it in to the Apple Store when I can get up there and see if they can work it out.
Thanks for the assist anyway Allan, I'm sure I'll get it working one way or another
Maffstar -
Need conversion mechanism for converting 24 bit image to 16 bit
In my java project I need to convert 24 bit image to 16 bit image. I don't have any clue. Please provide me the option to implement it.
Thanks,
jaiThat doesn't tell me much, and I know what you're talking about. I doubt that it tells the OP anything useful whatsoever.Sorry EJP, it was a mouthful I know. Maybe this will help instead, a ColorConversionOps class to work on *32 bit > 16 bit > 32 bit colors*. To help clarify where the 16 bit color input and output goes, some of the methods return or require parameters of type short. Also take notice the bitmask for variables of type short vs the bitmasks for int. AND pay particular attention to the unsigned right bit-shifting of the most-significant-digit.
public class ColorConversionOps
public static short convert32_16(int rgb) {
int a = ((rgb & 0xF0000000) >>> 16);
int r = ((rgb & 0x00F00000) >> 12);
int g = ((rgb & 0x0000F000) >> 8);
int b = ((rgb & 0x000000F0) >> 4);
return (short)( a | r | g | b);
public static int convert16_32(short rgb) {
int a = ((rgb & 0xF000) << 16);
int r = ((rgb & 0x0F00) << 12);
int g = ((rgb & 0x00F0) << 8);
int b = ((rgb & 0x000F) << 4);
return (a | r | g | b);
public static void printRGB_32(int rgb) {
System.out.println("a="+((rgb & 0xFF000000) >>> 24));
System.out.println("r="+((rgb & 0x00FF0000) >> 16));
System.out.println("g="+((rgb & 0x0000FF00) >> 8));
System.out.println("b="+ (rgb & 0x000000FF));
System.out.println();
public static void printRGB_16(short rgb) {
System.out.println("a="+((rgb & 0xF000) >>> 12));
System.out.println("r="+((rgb & 0x0F00) >> 8));
System.out.println("g="+((rgb & 0x00F0) >> 4));
System.out.println("b="+ (rgb & 0x000F));
System.out.println();
}Now to make the conversion from 32 bit color to 16 bit color and back. NOTICE there willl be a loss of precision -- just like someone else has already said.
public class Test
public static void main(String[] args)
int rgb = 0xFFFFFFFF;
ColorConversionOps.printRGB_32(rgb);
//a=255
//r=255
//g=255
//b=255
rgb = ColorConversionOps.convert32_16(rgb);
ColorConversionOps.printRGB_16((short)rgb);
//a=15
//r=15
//g=15
//b=15
rgb = ColorConversionOps.convert16_32((short)rgb);
ColorConversionOps.printRGB_32(rgb);
//a=240
//r=240
//g=240
//b=240
}And now we see, the reason 16bit color is so unpopular to the rest of the world, but not for us here! -
SQL query in ART database for incoming calls
This is the sql statement I am using to pull records from ART database below. After looking at the data pulled I am not getting incoming calls. What colum do I need to include.
select user_id, orig_party_number, orig_called_party_number, final_destination, connect_date, disconnect_date, (disconnect_date - connect_date) as duration, call_type, call_classification from Tbl_Billing_Data where orig_party_number = '50656' and timestamp > '2006-01-03' and timestamp < '2006-01-31'Query the CDR DB directly instead of ART and use this query for inbound:
PARAMETERS [Called Number] Text ( 255 ), [Start Date] DateTime, [End Date] DateTime;
SELECT DateAdd("s",[dateTimeOrigination],"31-Dec-1969 19:00:00") AS [Origin DateTime], IIf(dateTimeConnect<>0,DateAdd("s",[dateTimeConnect],"31-Dec-1969 19:00:00"),DateAdd("s",[dateTimeDisconnect],"31-Dec-1969 19:00:00")) AS ConnectDateTime, DateAdd("s",[dateTimeDisconnect],"31-Dec-1969 19:00:00") AS DisconectDateTime, dbo_CallDetailRecord.callingPartyNumber, dbo_CallDetailRecord.finalCalledPartyNumber, dbo_CallDetailRecord.duration AS Duration
FROM dbo_CallDetailRecord
WHERE (((dbo_CallDetailRecord.callingPartyNumber)<>"") And ((dbo_CallDetailRecord.finalCalledPartyNumber)=[Called Number]) And ((dbo_CallDetailRecord.dateTimeOrigination)>=DateDiff("s",#31/12/1969 19:0:0#,[Start Date]) And (dbo_CallDetailRecord.dateTimeOrigination)<=DateDiff("s",#31/12/1969 19:0:0#,[End Date])));
adignan - berbee -
Sql query to find dependencies for a table
Hi All,
I am having a table (REPT_ALL) with dependent objects on it ( child tables, indexes, constraints, views, synonyms, sequences , packages,procedures,functions,triggers).
I want the query to find out all the above dependencies for the above table(REP_ALL).
I m looking for the query to find dependencies inorder to find out the risks before dropping the above table(drop table REP_ALL cascade constraints)?
ThnxTo find foreign key constraints for a table you cannot use DBA_DEPENDENCIES but you have to use DBA_CONSTRAINTS.
Example Re: Find out foreign key column -
Tuning SQL query with similar subqueries for select columns
Hi all,
My query is something like below:
1> SELECT
2> A.COL1,
3> SUM(CASE WHEN A.flag=100 AND NVL(B.flag,0)=0 AND
4> EXISTS (
5> SELECT 'ROW_EXISTS'
6> FROM A A0
7> WHERE A0.COL2=100 AND NVL(A0.flag,0)=0 AND 0.DIRN<>A.DIRN)
8> THEN 1
9> ELSE 0
10> END) SUM_COLUMN1,
11>SUM(CASE WHEN A.flag=100 AND
12> EXISTS (
13> SELECT 'ROW_EXISTS'
14> FROM A A0
15> WHERE A0.COL2=100 AND A0.DIRN<>A.DIRN)
16> THEN 1
17> ELSE 0
18>END) SUM_COLUMN2
19>FROM A,B
20>WHERE A.COL=B.KEY_COL
21>GROUP BY A.COL1
My problem is that I need to index scan the tables A aliased as A0 in the two exist queries. Lines: 5-7 and 13-15.
The major performance degradation i see with the query is that it has to scan A0 twice to compute SUM_COLUMN1 and SUM_COLUMN2.
Is there any way by which i can use the same subquery to scan the table just once to compute the columns.
The table A has more than a 100million records. So i need to improve performance of this query though it is a small issue.
Please feel free to ask me more if i'm not clear with the example.
Thanks in advance,
RajAlso you could use analytic functions:
SQL> select deptno, sum(case when e.mgr is not null and
2 exists (select 1 from emp e1 where e1.empno <> e.empno
3 and e1.deptno = 10 and e1.sal >= 1500)
4 then 1 else 0 end) sum1,
5 sum(case when e.mgr is not null and e.sal >= 1200 and
6 exists (select 1 from emp e1 where e1.empno <> e.empno and e1.deptno = 10)
7 then 1 else 0 end) sum2
8 from emp e
9 group by deptno
10 /
DEPTNO SUM1 SUM2
10 2 2
20 5 3
30 6 5
SQL> select deptno, sum(case when mgr is not null and
2 (d12 != empno or empno !=d11) then 1 else 0 end) sum1,
3 sum(case when mgr is not null and (d21 != empno or empno !=d22)
4 and sal >= 1200 then 1 else 0 end) sum2
5 from (
6 select deptno, empno, mgr, sal,
7 min(case when deptno = 10 and sal >= 1500
8 then empno else -1 end) over(order by null) d11,
9 max(case when deptno = 10 and sal >= 1500
10 then empno else -1 end) over(order by null) d12,
11 min(case when deptno = 10 then empno else -1 end) over(order by null) d21,
12 max(case when deptno = 10 then empno else -1 end) over(order by null) d22
13 from emp e
14 )
15 group by deptno
16 /
DEPTNO SUM1 SUM2
10 2 2
20 5 3
30 6 5In your case it could be something like
SELECT COL1,
SUM( CASE WHEN a_flag = 100 and nvl(b_flag,0)=0 and
(DIRN != MIN_A OR DIRN != MAX_A) THEN 1 ELSE 0 END) SUM_COLUMN1,
SUM( CASE WHEN a_flag = 100 and
(DIRN != MIN_B OR DIRN != MAX_B) THEN 1 ELSE 0 END) SUM_COLUMN2
FROM (
SELECT A.COL1, A.FLAG A_FLAG, B.FLAG B_FLAG, A.DIRN,
MIN(CASE WHEN A.COL2=100 and NVL(A.flag,0) = 0 THEN A.DIRN ELSE null END) OVER(order by null) MIN_A,
MAX(CASE WHEN A.COL2=100 and NVL(A.flag,0) = 0 THEN A.DIRN ELSE null END) OVER(order by null) MAX_A,
MIN(CASE WHEN A.COL2=100 THEN A.DIRN ELSE null END) OVER(order by null) MIN_B,
MAX(CASE WHEN A.COL2=100 THEN A.DIRN ELSE null END) OVER(order by null) MAX_B
FROM A,B
WHERE A.COL=B.KEY_COL
GROUP BY COL1
Rgds.
Maybe you are looking for
-
Will Appletv connect to Sony tv RM-YDO14
Will AppleTV connect to Sony TV model RM-YDO14? Have tried all 3 HDMI inputs and I can't get the Apple setup screen. Is there more than one type of HDMi cable?
-
Burn DVD off digital cable box?
I tried searching this topic a number of ways so I apologize if this is repetitious, the ones I found just didn't seem to be relevant. I was just wondering if I could burn a dvd on my mac from a digital cable box? The box is a Scientific Atlanta Expl
-
Hi all, I got the following error.... Can't understand what happen? I can get the interface from the server. However, I cannot invoke any method. Any thought? Thank you, edu.cmu.nat.project6.server._SupervisorInterfaceStub:IOR:000000000000003849444c3
-
HT1222 Security Update 2014-002 it won't allow my macbook to update. HELP!!
HELP!! For myself to have the Security Update 2014-002 it won't allow my macbook to update. After i check the checkbox of Security Update 2014-002, it tells me to restart but i restarted about 4 times & it never really updated itself. Can Somebody h
-
I've noticed that the email field is labeled as Email 1 (Primary), but I can't seem to find a default Secondary email. I can implement it with the extended CRM, but am I missing something here? Is there already a secondary email implemented? Any help