Display distinct rows from Oracle table without using "DISTINCT" keyword.
How to retrieve distinct rows from oracle table without using 'DISTINCT' keyword in SQL?
Thanks in advance.
Mihir
Welcome to the forum.
Besides GROUP BY you can use UNIQUE instead of DISTINCT as well, but that's probably not wanted here ;) , and the ROW_NUMBER() analytic:
SQL> create table t as
2 select 1 col1 from dual union all
3 select 1 from dual union all
4 select 2 from dual union all
5 select 3 from dual union all
6 select 4 from dual union all
7 select 4 from dual;
Table created
SQL> select col1 from t;
COL1
1
1
2
3
4
4
6 rows selected
SQL> select distinct col1 from t;
COL1
1
2
3
4
SQL> select unique col1 from t;
COL1
1
2
3
4
SQL> select col1 from t group by col1;
COL1
1
2
3
4
SQL> select col1
2 from ( select col1
3 , row_number() over (partition by col1 order by col1) rn
4 from t
5 )
6 where rn=1;
COL1
1
2
3
4
Similar Messages
-
Create a new row in a table without using add new row button
I want to add a new row to the table without using the add new row button of the table. I'm not able to display default row in the table. Though if click on apply the record appears after saving in the database. Any thoughts how to implement this functionality.
Here is what you have to do.
1) You have to handle this in processRequest()
2) In the AM code , u need to check if there is already a row exisit or vo is blank
if (vo.getFetchedRowCount() == 0)
// first time
vo.setMaxFetchSize(0); // THIS IS REQUIRED.
Row row = vo.createRow();
vo.insertRow(row);
row.setNewRowState(Row.STATUS_INITIALIZED);
else
//If already rows are there then you suppose to insert in the end
// i assume you would have execute your vo
YourVORowImpl row= (YourVORowImpl)vo.getRowAtRangeIndex(0);
vo2.insertRowAtRangeIndex();
It should work. -
Add / Delete a row in a table without using a button
Hi,
I was just wondering if it was possible to remove or add a row in a table without using the button? I noticed that in all examples, it always involve putting code in the button click event but I wanted to add or delete a row in a table based on the fact if the row contains a certain value or not. Is that possible?
Much appreciated,
VincentVincent,
Here is the updated file..
https://acrobat.com/#d=bVDBNM0pnS2IpfE58V01Tg
You have checked the checkbox "Repeat subform for each Row" for Header Row under IndTable1. You need to do at Row1 level of Table1.
I bound the Row1 of Table1 to <Row1> tag in your XML which can repeat multiple times.
I wrote the code in the Doc Ready event of the Test1 field to check whether the value is existing or not. If it does not have a value, then I am removing the instance of the Row1 by passing the current index.. (You can check the code)..
While creating a data connection using XML you need to make sure that the below structure is repeated atleast 2 times. And while previewing you can use make a copy of this same XML and remove Row1.
<Row1>
<Test1>Individual Name 1</Test1>
</Row1>
Thanks
Srini -
Distinct rows from two tables linked by a third one
Hi,
I need to write an SQL sentence to bring a group of DISTINCT rows, each row in a form of: A.X, A.Y, C.IDBOLETA. Tables A and C are linked through the table C, as follow:
Table A: INDUSTRIAGEO
NIT VARCHAR2(20) NOT NULL,
CORRELAIGEO NUMERIC(2) NOT NULL,
NOMBREAGENCIA VARCHAR2(255) NOT NULL,
DIRECCION VARCHAR2(255),
X NUMERIC(12,8) NOT NULL,
Y NUMERIC(12,8) NOT NULL,
CONSTRAINT PKGEOINDUST PRIMARY KEY(NIT, CORRELAIGEO),
CONSTRAINT FKGEOINDUST FOREIGN KEY(NIT) REFERENCES INDUSTRIA(NIT)
Table B: ANALISIS
IDANALISIS NUMERIC(12) NOT NULL,
NIT VARCHAR2(20) NOT NULL,
CORRELAIGEO NUMERIC(2) NOT NULL,
FECHA DATE NOT NULL,
IDINSPECTOR NUMERIC(4) NOT NULL,
CONSTRAINT PKANALISIS PRIMARY KEY(IDANALISIS),
CONSTRAINT FKANALGEOI FOREIGN KEY(NIT, CORRELAIGEO) REFERENCES INDUSTRIAGEO(NIT, CORRELAIGEO),
CONSTRAINT FKANALINSP FOREIGN KEY(IDINSPECTOR) REFERENCES INSPECTOR(IDINSPECTOR)
Table C: ANALISISBOLETA
IDANALISIS NUMERIC(12) NOT NULL,
CORRELAANALISIS NUMERIC(2) NOT NULL,
IDBOLETA NUMERIC(12) NOT NULL,
IDCATEGORIAINDUSTRIA NUMERIC(3) NOT NULL,
CONSTRAINT PKANALBOLE PRIMARY KEY (IDANALISIS, CORRELAANALISIS),
CONSTRAINT UKANALBOLE UNIQUE (IDBOLETA),
CONSTRAINT FKANALBOLE FOREIGN KEY(IDANALISIS) REFERENCES COPS.ANALISIS(IDANALISIS),
CONSTRAINT FKANALCATI FOREIGN KEY(IDCATEGORIAINDUSTRIA) REFERENCES COPS.CATEGORIAINDUSTRIA(IDCATEGORIAINDUSTRIA)
Thanks for your help!!!
MarioPerhaps
select distinct a.x,a.y,c.idboleta
from industriaego a,
cops.analisis b,
analisisboleta c
where a.nit = b.nit
and a.correlaigeo = b.correlaigeo
and b.idanalisis = c.idanalisisRegards
Etbin
Edited by: Etbin on 4.5.2010 21:42
the copy/paste elf did it again: b.correlaigeo instead of b.a.correlaigeo (as in the OP's comment below) -
Retrive data from 4 tables without using joins
hi ,
i have to retrive data from 4 tables........but i donot want to use joins because of performance issues.
please guide me how to proceed further ?
thankshi manish,
CONSTANTS: c_act_plan(2) TYPE c VALUE 'U1' ,
c_person(1) TYPE c VALUE 'P' ,
p1_betid(8) TYPE c VALUE '50005316',
c_topdown(1) TYPE c VALUE 'A' ,
c_admnby(3) TYPE c VALUE '032' ,
c_bet_type(1) TYPE c VALUE 'Q' ,
c_firmed(1) TYPE c VALUE '1' ,
c_subtyp_mail(4) TYPE c VALUE '0001' .
TYPES: BEGIN OF ty_hrp1001,
objid TYPE hrp1001-objid,
END OF ty_hrp1001,
BEGIN OF ty_pa0001,
pernr TYPE pa0001-pernr,
subty TYPE pa0001-subty,
objps TYPE pa0001-objps,
sprps TYPE pa0001-sprps,
endda TYPE pa0001-endda,
begda TYPE pa0001-begda,
seqnr TYPE pa0001-seqnr,
werks TYPE pa0001-werks,
gsber TYPE pa0001-gsber,
btrtl TYPE pa0001-btrtl,
END OF ty_pa0001,
BEGIN OF ty_t500p,
persa TYPE t500p-persa,
name1 TYPE t500p-name1,
END OF ty_t500p,
BEGIN OF ty_t001p,
werks TYPE t001p-werks,
btrtl TYPE t001p-btrtl,
btext TYPE t001p-btext,
END OF ty_t001p,
BEGIN OF ty_pa0002,
pernr TYPE pa0002-pernr,
subty TYPE pa0002-subty,
objps TYPE pa0002-objps,
sprps TYPE pa0002-sprps,
endda TYPE pa0002-endda,
begda TYPE pa0002-begda,
seqnr TYPE pa0002-seqnr,
nachn TYPE pa0002-nachn,
vorna TYPE pa0002-vorna,
END OF ty_pa0002,
BEGIN OF ty_pa0105,
pernr TYPE pa0105-pernr ,
subty TYPE pa0105-subty ,
objps TYPE pa0105-objps ,
sprps TYPE pa0105-sprps ,
endda TYPE pa0105-endda ,
begda TYPE pa0105-begda ,
seqnr TYPE pa0105-seqnr ,
usrid_long TYPE pa0105-usrid_long,
END OF ty_pa0105,
BEGIN OF ty_output,
pernr TYPE pa0002-pernr ,
werks TYPE pa0001-werks ,
gsber TYPE pa0001-gsber ,
btrtl TYPE pa0001-btrtl ,
name1 TYPE t500p-name1 ,
btext TYPE t001p-btext ,
nachn TYPE pa0002-nachn ,
vorna TYPE pa0002-vorna ,
usrid_long TYPE pa0105-usrid_long,
END OF ty_output.
DATA: w_hrp1001 TYPE ty_hrp1001,
t_hrp1001 TYPE TABLE OF ty_hrp1001,
t_hrp1001_tmp TYPE TABLE OF ty_hrp1001,
w_pa0001 TYPE ty_pa0001 ,
t_pa0001 TYPE SORTED TABLE OF ty_pa0001
WITH NON-UNIQUE KEY pernr ,
t_pa0001_tmp TYPE TABLE OF ty_pa0001 ,
w_t500p TYPE ty_t500p ,
t_t500p TYPE HASHED TABLE OF ty_t500p
WITH UNIQUE KEY persa ,
w_t001p TYPE ty_t001p ,
t_t001p TYPE HASHED TABLE OF ty_t001p
WITH UNIQUE KEY werks btrtl ,
w_pa0002 TYPE ty_pa0002 ,
t_pa0002 TYPE SORTED TABLE OF ty_pa0002
WITH NON-UNIQUE KEY pernr ,
t_pa0002_tmp TYPE TABLE OF ty_pa0002 ,
w_pa0105 TYPE ty_pa0105 ,
t_pa0105 TYPE SORTED TABLE OF ty_pa0105
WITH NON-UNIQUE KEY pernr ,
w_output TYPE ty_output ,
t_output TYPE TABLE OF ty_output .
SELECT objid
FROM hrp1001
INTO TABLE t_hrp1001
WHERE otype EQ c_person
AND plvar EQ c_act_plan
AND rsign EQ c_topdown
AND relat EQ c_admnby
AND istat EQ c_firmed
AND begda LE sy-datum
AND endda GT sy-datum
AND sclas EQ c_bet_type
AND sobid EQ p1_betid.
IF sy-subrc EQ 0.
SORT t_hrp1001 BY objid.
ENDIF.
IF NOT t_hrp1001[] IS INITIAL.
t_hrp1001_tmp[] = t_hrp1001[].
DELETE ADJACENT DUPLICATES FROM t_hrp1001_tmp
COMPARING objid.
SELECT pernr
subty
objps
sprps
endda
begda
seqnr
werks
gsber
btrtl
FROM pa0001
INTO TABLE t_pa0001
FOR ALL ENTRIES IN t_hrp1001_tmp
WHERE pernr EQ t_hrp1001_tmp-objid
AND endda GT sy-datum
AND begda LE sy-datum.
SELECT pernr
subty
objps
sprps
endda
begda
seqnr
nachn
vorna
FROM pa0002
INTO TABLE t_pa0002
FOR ALL ENTRIES IN t_hrp1001_tmp
WHERE pernr EQ t_hrp1001_tmp-objid
AND endda GT sy-datum
AND begda LE sy-datum.
ENDIF.
IF NOT t_pa0001[] IS INITIAL.
t_pa0001_tmp[] = t_pa0001[].
SORT t_pa0001_tmp BY werks btrtl.
DELETE ADJACENT DUPLICATES FROM t_pa0001_tmp COMPARING werks btrtl.
SELECT werks
btrtl
btext
FROM t001p
INTO TABLE t_t001p
FOR ALL ENTRIES IN t_pa0001_tmp
WHERE werks EQ t_pa0001_tmp-werks
AND btrtl EQ t_pa0001_tmp-btrtl.
DELETE ADJACENT DUPLICATES FROM t_pa0001_tmp COMPARING werks.
SELECT persa
name1
FROM t500p
INTO TABLE t_t500p
FOR ALL ENTRIES IN t_pa0001_tmp
WHERE persa EQ t_pa0001_tmp-werks.
ENDIF.
IF NOT t_pa0002[] IS INITIAL.
t_pa0002_tmp[] = t_pa0002[].
DELETE ADJACENT DUPLICATES FROM t_pa0002_tmp COMPARING pernr.
SELECT pernr
subty
objps
sprps
endda
begda
seqnr
usrid_long
FROM pa0105
INTO TABLE t_pa0105
FOR ALL ENTRIES IN t_pa0002_tmp
WHERE pernr EQ t_pa0002_tmp-pernr
AND subty EQ c_subtyp_mail
AND endda GT sy-datum
AND begda LE sy-datum
AND usrty EQ c_subtyp_mail.
ENDIF.
REFRESH t_output.
LOOP AT t_hrp1001 INTO w_hrp1001.
LOOP AT t_pa0001 INTO w_pa0001
WHERE pernr EQ w_hrp1001-objid.
READ TABLE t_t500p INTO w_t500p WITH KEY persa = w_pa0001-werks
TRANSPORTING
name1.
CHECK sy-subrc EQ 0.
READ TABLE t_t001p INTO w_t001p WITH KEY werks = w_pa0001-werks
btrtl = w_pa0001-btrtl
TRANSPORTING
btext.
LOOP AT t_pa0002 INTO w_pa0002
WHERE pernr EQ w_hrp1001-objid.
LOOP AT t_pa0105 INTO w_pa0105
WHERE pernr EQ w_pa0002-pernr.
w_output-pernr = w_pa0002-pernr .
w_output-werks = w_pa0001-werks .
w_output-gsber = w_pa0001-gsber .
w_output-btrtl = w_pa0001-btrtl .
w_output-name1 = w_t500p-name1 .
w_output-btext = w_t001p-btext .
w_output-nachn = w_pa0002-nachn .
w_output-vorna = w_pa0002-vorna .
w_output-usrid_long = w_pa0105-usrid_long.
APPEND w_output TO t_output.
CLEAR w_output.
ENDLOOP.
ENDLOOP.
ENDLOOP.
ENDLOOP.
Reward if usful,
Thanks,
Srikanth.A -
Select Distinct rows from 3 tables
I need to retrive information from 3 different tables by applying a specific condition.
I have the following query which works fine for retrieving desired data from 2 tables.
SELECT
a.userId
FROM userGeneral
a inner
join userSpecific
b on a.userId
= b.userId
WHERE
a.userActive
= 1
userId
111
222
333
444
Now I have a third table called userMgr which may contain multiple records for each userId with a corresponding mgrId value. It has a primary key identity column called userRecId and I would like to fetch the
mgrId value corresponding to the MAX(userRecId) for the matching userId.
userRecId | userId | mgrId
1 | 111 | 123
2 | 111 | 234
3 | 111 | 345
4 | 333 | 345
5 | 333 | 456
The resultset should be as follows after joining all the 3 tables.
userId | mgrId
111 | 345
222 | NULL
333 | 456
444 | NULL
Can anyone please help with this query.I need to retrive information from 3 different tables by applying a specific condition.
I have the following query which works fine for retrieving desired data from 2 tables.
SELECT
a.userId
FROM userGeneral
a inner
join userSpecific
b on a.userId
= b.userId
WHERE
a.userActive
= 1
userId
111
222
333
444
Now I have a third table called userMgr which may contain multiple records for each userId with a corresponding mgrId value. It has a primary key identity column called userRecId and I would like to fetch the
mgrId value corresponding to the MAX(userRecId) for the matching userId.
userRecId | userId | mgrId
1 | 111 | 123
2 | 111 | 234
3 | 111 | 345
4 | 333 | 345
5 | 333 | 456
The resultset should be as follows after joining all the 3 tables.
userId | mgrId
111 | 345
222 | NULL
333 | 456
444 | NULL
Can anyone please help with this query.
try this:
select userId,userRecId,
from userMgr,
(SELECT a.userId, max(a.userRecId)
FROM userGeneral a inner join userSpecific b on a.userId = b.userId
group by a.userId
WHERE a.userActive = 1) table1(userId,userRecId)
where userMgr.userRecId = table1.userRecId -
Select Distinct rows from multiple tables
Table 1 is a List of Vendors - VID, PID, VName, VAddress, VPhone
Table 2 is a list of Products - PID, PName, PPrice, PWeight, PColor
I need to produce a list of unique PID's showing the following fields - PID, VName, PName, PColor
So, Here is my failed attempt:
SELECT P.PID, V.VName, P.PName, P.PColor
FROM Products P INNER JOIN Vendors V ON P.PID = V.PID
GROUP BY P.PIDIf you post DDL, sample data and your desired output based on that sample data, someone can probably create a query that does what you want.
And I have to tell you that Table 1 is not a list of vendors unless you have a system where a vendor provides one and only one product - something that is unusual. If your system is one where a vendor should provide any number of products (and if a product
can be provided by any number of vendors), you have some fundamental schema issues to correct.
Lastly, there are sticky posts at the top of the forum that provide suggestions for posting questions. Please have a look - help your readers help you by providing sufficient information. Phrases such as "failed" or "does not work"
do not provide any useful detail. And one good rule of thumb - any time you feel you need to use (or say) distinct in a query is an indication that something somewhere is wrong. It could be a schema issue, a misunderstanding of the schema or the
goal, an incorrect query, etc. There are few instances where distinct is needed in a well-defined and implemented system, IMO. -
Display chinese characters from oracle 8i database using UTF-8
I have written a program to retrieve chinese characters from the database and display in the web page.If I change the encoding of the webpage manully it displays the chinese characters(比分卡片 ).Or it shows the junk characters(�������� ).Can anybody help so that do I have to do any encoding or any other settings?.I am using Jdeveloper.
Rgds
Ganesh
<HTML><HEAD><TITLE>Welcome to METRO</TITLE>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<%//@ page contentType="text/html; charset=UTF-8" %>
<%@ page import="java.io.*,java.io.InputStream,java.nio.*,java.lang.*,java.util.*,javax.naming.Context,java.sql.Connection,javax.sql.DataSource,javax.naming.InitialContext,java.sql.*" %>
</HEAD>
<BODY >
<%
String value="";
try{
Connection dbConn;
Statement stmt=null;
Context jndiCtx=new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)jndiCtx.lookup( "jdbc/webdbPooledDS" );
dbConn= ds.getConnection();
stmt=dbConn.createStatement();
String sql="select prog_name_LL2 from wb_prog_new_metro where table_name='SCORE_CARD'";
ResultSet rs = stmt.executeQuery(sql);
if( rs.next()){
value=rs.getString(1);
out.println(value);
}catch(Exception e){
System.out.println("Exception ="+e.getMessage());
%>
</BODY></HTML>Make sure that you have a Unicode font that supports Chinese characters. I have been testing the support of Unicode text (allows many other character and image based languages to be displayed) and have found that it depends on what fonts are available on the system you're viewing the report on. Unicode is supported in Crystal (since version 9 I believe) but it will display '?' or '[]' if there isn't a font to render the text properly.
This font supports loads of languages: http://www.code2000.net/code2000_page.htm -
How to delete the records from database table without using work area
Hi all,
The purpose of the down program is to delete the entire contents from all the tables. The deletion of the table should be in sorted manner. Is there any other way to write the code more efficiently,
TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR, ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL, ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
DELETE ZFFMCTL_AP.
IF SY-SUBRC = 0.
DELETE ZFFMMHDR_AP.
IF SY-SUBRC = 0.
DELETE ZFFM_CHANGE_LOG.
IF SY-SUBRC = 0.
DELETE ZFFMDTL_AR.
IF SY-SUBRC = 0.
DELETE ZFFMHDR_AR.
IF SY-SUBRC = 0.
DELETE ZFFMDTL_JV.
IF SY-SUBRC = 0.
DELETE ZFFMHDR_JV.
IF SY-SUBRC = 0.
DELETE ZFFMDTL_SKF.
IF SY-SUBRC = 0.
DELETE ZFFMHDR_SKF.
IF SY-SUBRC = 0.
DELETE ZFINVOICE_DETAIL.
IF SY-SUBRC = 0.
DELETE ZFFMMASTER.
IF SY-SUBRC = 0.
DELETE ZFFMLOGREAD_CLUS.
IF SY-SUBRC = 0.
DELETE ZFFMCTL.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
ENDIF.
Waiting for response,
Thanks in advance
JohnWrite this way....
TABLES: ZFFMCTL_AP, ZFFMHDR_AP, ZFFM_CHANGE_LOG, ZFFMDTL_AR, ZFFMHDR_AR, ZFFMDTL_JV, ZFFMHDR_JV, ZFFMDTL_SKF,ZFFMHDR_SKF,ZFINVOICE_DETAIL, ZFFMMASTER, ZFFMLOGREAD_CLUS, ZFFMCTL.
DELETE ZFFMCTL_AP.
CHECK SY_SUBRC = 0.
DELETE ZFFMMHDR_AP.
CHECK SY_SUBRC = 0.
DELETE ZFFM_CHANGE_LOG.
CHECK SY_SUBRC = 0.
DELETE ZFFMDTL_AR.
CHECK SY_SUBRC = 0.
DELETE ZFFMHDR_AR.
CHECK SY_SUBRC = 0.
DELETE ZFFMDTL_JV.
CHECK SY_SUBRC = 0.
DELETE ZFFMHDR_JV.
CHECK SY_SUBRC = 0.
DELETE ZFFMDTL_SKF.
CHECK SY_SUBRC = 0.
DELETE ZFFMHDR_SKF.
CHECK SY_SUBRC = 0.
DELETE ZFINVOICE_DETAIL.
CHECK SY_SUBRC = 0.
DELETE ZFFMMASTER.
CHECK SY_SUBRC = 0.
DELETE ZFFMLOGREAD_CLUS.
CHECK SY_SUBRC = 0.
DELETE ZFFMCTL. -
# coming when I select data from oracle table using Native SQL
Hi Gurus,
I am selecting 'First name' from oracle table directly using native sql. I am fetching 65000 records but 10+ records having '#' at the end of firstname. For eg: John#.
But oracle team couldn't find '#' in their table for those records. What could be problem?
or what could be the character in oracle which comes as '#' in abap?
Pls help...
SajThanks for replies.
My DB NLS_PARAMETER is AL32UTF8. I am able to pullout data with older version of ojdbc jar file. So I think there is no issue regarding NLS setting.
So please guide me with proper solution as soon as possible. -
Select 10000 rows from Oracle in shortest way
Looking for a good desicions for trasfering more than 10000 rows from
oracle to mysql using only jdbc. Connect is mostly slow about 1 row in
a second, rights on oracle are just for select, update, insert
operations. I think if I can devide 10000 rows in 10 parts and transfer
them in concurent threads and connections. Any suggestion can help me
to solve this problem.See java.sql.Statement.setFetchSize(), e.g.I'm not sure that setFetchSize will have any impact on your performance. It is mostly a suggestion to the JDBC driver, and while in theory the suggestion may help, in practice I have not seen any signficant benefit when using Oracle.
To test the speed of your fetch, try issuing your select, then loop through the resultset, getting all the columns, just don't do anything with them. You could try changing the fetchSize to see if it does have an impact in your specific architecture.
Now that you know how fast you can 'get' all the rows, how much different is it then the 1 second per row that you are seeing when selecting and inserting (I'm assuming you haven't done this yet, sorry if you already have)?
Assuming that you can select all rows in less then the 1 second per row in your original test; there are several things you can do to increase the speed of inserts. Try using a PreparedStatement if you are not already using one . Try using the .addBatch() and .executeBatch(). You can try changing the count of rows that are inserted on each executeBatch() command.
If all your inserts are inserting into a single table, then I don't think multiple threads will help you, and may in fact hurt you because you could run into locking issues in the mySQL database. If you are inserting into multiple tables, then it is possible that multi-threading, done correctly, may provide some increase in overall speed.
Oracle can be accessed with 3 different JDBC drivers. If you are using Oracle 8i or 9i, then try using the OCI8 driver instead of the thin driver. The OCI8 driver may provide some performance benefits when doing mass inserts in the older versions of Oracle. Do not use the JDBC-ODBC bridge as that will provide the worst performance.
If I was going to move data between two different databases, and the vendor did not provide a utility to do that specifically then I would try and use the 1st db vendors unload utility to unload into a text file, and the 2nd db vendors load utility to load from that text file. These utilities have been optimized for speed far and above anything that will ever be available to you as a Java programmer using JDBC. That isn't always possible based on the architecture of your solution, but it is always preferrable.
Best of luck to you. -
Query from oracle to MySql using dblink fetch all the rows in MySql table
Hello,
I am using Heterogeneous connectivity between oracle 10204 to Mysql database.
I have a database link in the oracle side .
I am query a table in MySql that have 10 million rows.
Its doesnt matter if i am running :
select * from "CDR_Accounts"@mysql where "id"=7675405;
or
select * from "CDR_Accounts"@mysql ;
There is an index on the id column.
Yet, it seems that the Mysql is feteching all the rows from the table , all the data is transfering to oracle over the dblink , and only after that the requested rows are get back to the client.
The /etc/odbcinst.ini file is as follow:
[odbcprd:oracle@odbc /software/oracle]$ cat /etc/odbcinst.ini
[myodbc3]
Description = Mysql connector to mysql version 3.5
Driver = /software/oracle/MysqlOdbc/3.52/lib/libmyodbc3-3.51.25.so
Driver64 = /usr/lib
Setup = /software/oracle/MysqlOdbc/3.52/lib/libmyodbc3S-3.51.25.so
Setup64 = /usr/lib
UsageCount = 1
CPTimeout = 3600
CPReuse = Please advice
ThanksWhen using a gateway it is always possible that a where clause is not sent to the remote database. This is called post processing and depends on several factors like the used ODBC driver, the columns and its data types but also if you specify certain functions in the where clause.
The fastest way to see if post processing happens is in Oracle 11g the explain plan for a query. In 10g the plan does not always match the statement sent to the foreign database. Here it would be better to enable gateway tracing and setting the trace level to ON. This will log the statements sent to the foreign database and you can compare what statement was sent with the statement you've tried to execute. -
How to display row to columns without using pivot keyword
hi,
could someone help me how to dispaly rows into columns without using pivot keyword and actuall my scenario is,iam having two tables with names and sample data is shown below
ID PROJECT MID MINAME TASKID TASKNAME
1 PROJ1 1 AA 100 PR1_TASK1
1 PROJ1 3 CC 102 PR1_TASK3
1 PROJ1 4 DD 103 PR1_TASK4
1 PROJ1 5 EE 104 PR1_TASK5
1 PROJ1 6 FF 105 PR1_TASK6
2 PROJ2 5 EE 114 PR2_TASK1
2 PROJ2 6 FF 115 PR2_TASK2
2 PROJ2 7 GG 116 PR2_TASK3
2 PROJ2 8 HH 117 PR2_TASK4
2 PROJ2 9 JJ 118 PR2_TASK5
2 PROJ2 10 KK 119 PR2_TASK6
2 PROJ2 1 AA 120 PR2_TASK7
The output should display project and count of tasks in particular milestone as shown below
project AA BB CC DD EE FF GG HH JJ KK
1 2 0 1 5 3 2 0 2 1 0
2 1 2 0 2 1 0 2 4 3 1
Thanks in advance ,
vvrWITH t1 AS
(SELECT 1 ID,
'PROJ1' PROJECT,
1 MID,
'AA' MINAME,
100 TASKID,
'PR1_TASK1' TASKNAME
FROM DUAL
UNION
SELECT 1, 'PROJ1', 3, 'CC', 102, 'PR1_TASK3'
FROM DUAL
UNION
SELECT 1, 'PROJ1', 4, 'DD', 103, 'PR1_TASK4'
FROM DUAL
UNION
SELECT 1, 'PROJ1', 5, 'EE', 104, 'PR1_TASK5'
FROM DUAL
UNION
SELECT 1, 'PROJ1', 6, 'FF', 105, 'PR1_TASK6'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 5, 'EE', 114, 'PR2_TASK1'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 6, 'FF', 115, 'PR2_TASK2'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 7, 'GG', 116, 'PR2_TASK3'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 8, 'HH', 117, 'PR2_TASK4'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 9, 'JJ', 118, 'PR1_TASK5'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 10, 'KK', 119, 'PR1_TASK6'
FROM DUAL
UNION
SELECT 2, 'PROJ2', 1, 'AA', 120, 'PR1_TASK7' FROM DUAL)
SELECT id project,
NVL((SELECT mid
FROM t1
WHERE miname = 'AA'
AND id = t_out.id),
0) AA,
NVL((SELECT mid
FROM t1
WHERE miname = 'BB'
AND id = t_out.id),
0) BB,
NVL((SELECT mid
FROM t1
WHERE miname = 'CC'
AND id = t_out.id),
0) CC,
NVL((SELECT mid
FROM t1
WHERE miname = 'DD'
AND id = t_out.id),
0) DD,
NVL((SELECT mid
FROM t1
WHERE miname = 'EE'
AND id = t_out.id),
0) EE,
NVL((SELECT mid
FROM t1
WHERE miname = 'FF'
AND id = t_out.id),
0) FF,
NVL((SELECT mid
FROM t1
WHERE miname = 'GG'
AND id = t_out.id),
0) GG,
NVL((SELECT mid
FROM t1
WHERE miname = 'HH'
AND id = t_out.id),
0) HH,
NVL((SELECT mid
FROM t1
WHERE miname = 'JJ'
AND id = t_out.id),
0) JJ,
NVL((SELECT mid
FROM t1
WHERE miname = 'KK'
AND id = t_out.id),
0) KK
FROM (SELECT DISTINCT id FROM t1) t_out
PROJECT AA BB CC DD EE FF GG HH JJ KK
1 1 0 3 4 5 6 0 0 0 0
2 1 0 0 0 5 6 7 8 9 10As I understand, you want MID of MINAMEs displayed ? But output is not like yours.. What is exactly your requirements? -
Using FDM to load data from oracle table (Integration Import Script)
Hi,
I am using Integration Import Script to load data from oracle table to worktables in FDM.
i am getting following error while running the script.
Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done
Attaching the full error report
ERROR:
Code............................................. -2147217887
Description...................................... Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
At line: 22
Procedure........................................ clsImpProcessMgr.fLoadAndProcessFile
Component........................................ upsWObjectsDM
Version.......................................... 1112
Thread........................................... 6260
IDENTIFICATION:
User............................................. ******
Computer Name.................................... *******
App Name......................................... FDMAPP
Client App....................................... WebClient
CONNECTION:
Provider......................................... ORAOLEDB.ORACLE
Data Server......................................
Database Name.................................... DBNAME
Trusted Connect.................................. False
Connect Status.. Connection Open
GLOBALS:
Location......................................... SCRTEST
Location ID...................................... 750
Location Seg..................................... 4
Category......................................... FDM ACTUAL
Category ID...................................... 13
Period........................................... Jun - 2011
Period ID........................................ 6/30/2011
POV Local........................................ True
Language......................................... 1033
User Level....................................... 1
All Partitions................................... True
Is Auditor....................................... False
I am using the following script
Function ImpScrTest(strLoc, lngCatKey, dblPerKey, strWorkTableName)
'Oracle Hyperion FDM Integration Import Script:
'Created By: Dhananjay
'Date Created: 1/17/2012 10:29:53 AM
'Purpose:A test script to import data from Oracle EBS tables
Dim cnSS 'ADODB.Connection
Dim strSQL 'SQL string
Dim rs 'Recordset
Dim rsAppend 'tTB table append rs object
'Initialize objects
Set cnSS = CreateObject("ADODB.Connection")
Set rs = CreateObject("ADODB.Recordset")
Set rsAppend = DW.DataAccess.farsTable(strWorkTableName)
'Connect to SQL Server database
cnss.open "Provider=OraOLEDB.Oracle.1;Data Source= +server+;Initial Catalog= +catalog+;User ID= +uid+;Password= +pass+"
'Create query string
strSQL = "Select AMOUNT,DESCRIPTION,ACCOUNT,ENTITY FROM +catalog+.TEST_TMP"
'Get data
rs.Open strSQL, cnSS
'Check for data
If rs.bof And rs.eof Then
RES.PlngActionType = 2
RES.PstrActionValue = "No Records to load!"
Exit Function
End If
'Loop through records and append to tTB table in location’s DB
If Not rs.bof And Not rs.eof Then
Do While Not rs.eof
rsAppend.AddNew
rsAppend.Fields("PartitionKey") = RES.PlngLocKey
rsAppend.Fields("CatKey") = RES.PlngCatKey
rsAppend.Fields("PeriodKey") = RES.PdtePerKey
rsAppend.Fields("DataView") = "YTD"
rsAppend.Fields("CalcAcctType") = 9
rsAppend.Fields("Amount") = rs.fields("Amount").Value
rsAppend.Fields("Desc1") = rs.fields("Description").Value
rsAppend.Fields("Account") = rs.fields("Account").Value
rsAppend.Fields("Entity") = rs.fields("Entity").Value
rsAppend.Update
rs.movenext
Loop
End If
'Records loaded
RES.PlngActionType = 6
RES.PstrActionValue = "Import successful!"
'Assign Return value
SQLIntegration = True
End Function
Please help me on this
Thanks,
Dhananjay
Edited by: DBS on Feb 9, 2012 10:21 PMHi,
I found the problem.It was because of the connection string.The format was different for oracle tables.
PFB the format
*cnss.open"Provider=OraOLEDB.Oracle.1;Data Source= servername:port/SID;Database= DB;User Id=aaaa;Password=aaaa;"*
And thanks *SH* for quick response.
So closing the thread......
Thanks,
Dhananjay -
Best practice for deleting multiple rows from a table , using creator
Hi
Thank you for reading my post.
what is best practive for deleting multiple rows from a table using rowSet ?
for example how i can execute something like
delete from table1 where field1= ? and field2 =?
Thank youHi,
Please go through the AppModel application which is available at: http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/sampleapps.html
The OnePage Table Based example shows exactly how to use deleting multiple rows from a datatable...
Hope this helps.
Thanks,
RK.
Maybe you are looking for
-
HT2801 can i use the Apple USB SuperDrive to upgrade my OS from 10.5 t0 10.6?
The optical drive on my Macbook Pro (Build 9L31a) broke a couple of years ago and I have thus far managed to get around it. Now that iCloud is about to reign down on my OS 10.5, I need to upgrade via disk. Will the new Apple USB SuperDrive do the tri
-
Filetype out of unzipped XSTRING
Hello developers! Hope anybody of you can help me with question. I created a report with that i generate an interactive form, zip it and send it out as attachement by miall to my customers. Then i get from the customers the zip file back. But the zip
-
Are sticky notes compatible with Cloud RDS 2012 R2 Server?
Greetings tech wizards. We are running an RDS 2012 R2 Server in the Cloud, and I would like to pose a question: is the default windows sticky notes application compatible in a Cloud environment? Multiple users would be using the application at the
-
HP G61 408CA notebook sound card driver for windows XP
i newly bought HP G61 408CA notebook which came with windows 7. I had to downgrade it to windows XP. Now i have a big problem with its sound card driver for windows XP. I have tried the following instruction: "Re: HP G61 sound card driver for window
-
Help:The Toshiba Bluetooth SD Card 3 is no working..
Thank you for you watching. My laptop model is Satellite 5200 with SD slot, But the it is not working, i doubt it is the SDIO problem. But, the toshiba bluetooth information centre said 5200 is supporting BlueTooth SD card 2, Hmm. Additionally, I hav