Help for pl/sql
Hi all
I am new to oracle.Can anybody suggest me the books,websites to practise procedure,cursor,triggers,function,packages.specially assignments on this
http://www.oracle.com/pls/db112/portal.portal_db?selected=1&frame=#developer_essentials
http://asktom.oracle.com
http://www.sqlsnippets.com/en/home.html
Similar Messages
-
need help on this to performance better.
DECLARE
FILE_READ UTL_FILE.FILE_TYPE;
LOCATION VARCHAR2(128):='D:\PLSQL';
FILENAME VARCHAR2(128):='TEST.txt';
OPEN_MODE VARCHAR2(128):='r';
V_LINE VARCHAR2(128);
V_ORDERCODE CHAR(15);
V_REST CHAR(100);
V_OWNERCODE CHAR(5);
CURSOR C_ORD IS
SELECT ORD.ORDERID,ORD.OWNERID
FROM ORDERS ORD,OWNERS OWN
WHERE ORD.ORDERCODE=V_ORDERCODE
AND ORD.OWNERID=OWN.OWNERID
AND OWN.OWNERCODE=V_OWNERCODE
AND ORD.STATUS=10
ORDER BY ORD.SEQ DESC;
R_ORD C_ORD%ROWTYPE;
BEGIN
FILE_READ:=UTL_FILE.FOPEN(LOCATION,FILENAME,OPEN_MODE);
LOOP
BEGIN
UTL_FILE.GET_LINE(FILE_READ,V_LINE);
EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
V_OWNERCODE:=RTRIM(SUBSTR(V_LINE,0,5));
V_ORDERCODE:=SUBSTR(V_LINE,7,15);
V_REST:=SUBSTR(V_LINE,23,LENGTH(RTRIM(LTRIM(V_LINE))));
OPEN C_ORD;
FETCH C_ORD INTO R_ORD;
IF C_ORD%FOUND THEN
UPDATE ORDERS SET UNDEF10=RTRIM(V_REST) WHERE ORDERCODE=V_ORDERCODE AND OWNERID=R_ORD.OWNERID;
END IF;
CLOSE C_ORD;
END LOOP;
UTL_FILE.FCLOSE(FILE_READ);
EXCEPTION
WHEN UTL_FILE.INVALID_MODE THEN
RAISE_APPLICATION_ERROR(-20001,'INVALID_MODE');
WHEN UTL_FILE.READ_ERROR THEN
RAISE_APPLICATION_ERROR(-20002,'READ_ERROR');
WHEN UTL_FILE.INVALID_PATH THEN
RAISE_APPLICATION_ERROR(-20003,'INVALID_PATH');
WHEN UTL_FILE.INVALID_FILEHANDLE THEN
RAISE_APPLICATION_ERROR(-20004,'INVALID_FILEHANDLE');
WHEN UTL_FILE.INVALID_OPERATION THEN
RAISE_APPLICATION_ERROR(-20005,'INVALID_OPERATION');
WHEN UTL_FILE.WRITE_ERROR THEN
RAISE_APPLICATION_ERROR(-20006,'WRITE_ERROR');
WHEN UTL_FILE.INTERNAL_ERROR THEN
RAISE_APPLICATION_ERROR(-20007,'INTERNAL_ERROR');
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20008,SQLERRM);
END;My obersvations for poor performance (although you have not defined what is "poor")
1. Why ORDER BY in cursor ?
2. Why CURSOR itself ?
It seems to me that all you are doing is checking whether the SQL (in cursor) returns any data. If yes, yo are updating ORDERS table. You should be able to eliminate cursor entirely. That will save all processing on cursor.
If you can explain (in english) what you are trying to achieve, I may be able to provide better solution. -
SQL logic help for pl/sql block
Hi All,
I need your suggestions and comments for the below issue:
I have two tables: table A and table B
Table A has two columns as id and counts:
Id Counts
99 10
999 13
9999 7
Table B has two columns as Id and order:
Id Order
99 1
999 2
9999 3
We need to update Order in Table B such that Id having highest count in table A has Order as 1 in table B and it keep on increasing the order for other Ids based on decreasing counts in table A. This will be like a job which will run daily and look for counts in table A and update Order in table B according to it.
It seems to be simple but i am not getting it. Please help me out of this by writing some PL/SQL block.
I will really appreciate your all comments and responses.
Regards
DevHi,
Keen2Learn wrote:
Hi All,
I am really greatful to all fo you for all your replies and comments. I change ORDER table to ORDERS. All you replies worked for me but there is some slight change in scenario which i need to discuss with you all.
E.g: Table A has 10 rows like below:
Id Counts Type
99 10 A
999 13 A
9999 7 C
99 4 B
999 2 C
88 2 A
77 1 C
777 3 B
777 5 A
888 2 CIf you'd like help, please post CREATE TABLE and INSERT statements for your sample data (including table b as it is before the UPDATE or MERGE).
I populate data in Orders column Table B based on id, by grouping sum of counts for that id in table A.
Id 999 has highest sum(count) as 15, so it has orders as 1 in Table B and do same for descending counts for each Id.
Table B has 5 rows like below:
Id Orders
99 2
999 1
88 4
777 3
555 5
Assume Table B as static(no new record comes in it) but only its Orders changes for each Id based on counts for that Id in Table A. As you see, Table B has id 555 which is not in Table A, so we need to update its orders to the highest number by taking its Count as 0(zero). Sorry, it's unclear what you want to do.
Post what you'd like table b to look like after the UPDATE or MERGE.
Right now i am doing it like this:
declare
cursor c1 is
select Id, SUM (COUNT), RANK () OVER (ORDER BY SUM (COUNT)) rnk
from TableA AND Id IN (SELECT Id FROM TableB)
GROUP BY Id
ORDER BY rnk DESC;
i NUMBER := 1;
begin
for curr in c1
loop
update TableB
set orders = i
where id = curr.id;
i := i + 1;
end loop;
end;I'm not sure what you're trying to do, but I'll bet you don't need PL/SQL to do it. Use a single UPDATE or MERGE statement (inside PL/SQL if necessary).
But it is not updating orders for Id 555 in TableB.There is no row for id=555 in table b, and, according to your requirements, there never will be, because "Table B as static(no new record comes in it)". It's behaving exactly as you said you wanted it to. What's the problem?
Please provide your suggesstions on what needs to be done to take care of this scenario. I will really appreciate your all suggesstions and comments. Please let me know if need some more explanation.Whenever you have a problem, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
In the case of a DML operation (such as UPDATE) the sample data should show what the tables are like before the DML, and the results will be the contents of the changed table(s) after the DML.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using. -
Need help for the sql statement !!!!!
hi all,
i need a sql statement for a query, how can i get the result from the rownum between 100 and 150?
plz helpuse a scrollable statement:
PreparedStatement stat = Connection.prepareStement("select * from blah", ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_UPDATABLE);
ResultSet rs = stat.executeQuery();
rs.absolute(100);
while (rs.next()) {
String something = rs.get(1);
Look into the JDK API reference for ResultSet to get an expalantion of scrollable statements. -
Help for Pl/SQL Logic & Syntax used
Hi, in Ivan Bayross' book, following example is given illustrating use of triggers.
Create trigger audit_trail
After update or delete on customer
for each row
DECLARE
oper VARCHAR(20);
BEGIN
If updating then
oper :='UPDATE';
End if;
If deleting then
oper :='DELETE';
End if;
Insert into audit_cust
Values(*:OLD.CUST_NO* , *:OLD.FNAME* );
END;
Questions :*
1. Why : symbol is used in insert query above? Viz. :OLD.CUST_NO
what does it indicate ?? ALso, what does . ( dot operator) indicates?
OLD is not table name.
2. In the program above what does this line mean??
If deleting then
oper :='DELETE';
End if;
We are just assigning value 'DELETE' to oper variable ?? or something else??Hi,
So, still struggling on Ivan's book, eh ;-) ?
1. :OLD and :NEW means you can refer to the old and new column values.
They are only usable in triggers.
So, if you're updating column X from 1 to 2, the value of :OLD.X = 1 and :NEW.X = 2 in your trigger only.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/triggers.htm#CNCPT118
http://www.oracle.com/pls/db102/search?word=TRIGGER&partno=
We are just assigning value 'DELETE' to oper variable ?? or something else??I guess the autor meant do do this:
Create trigger audit_trail
After update or delete on customer
for each row
DECLARE
oper VARCHAR(20);
BEGIN
If updating then
oper :='UPDATE';
End if;
If deleting then
oper :='DELETE';
End if;
Insert into audit_cust
Values( :OLD.CUST_NO, : OLD.FNAME, oper );
END;He probably forgot to insert the oper variable in his audit table, -
Help asked for a sql request - thanks
Hello,
I'm not a sql Guru... Who can help for this sql request ?
First I have this:
SELECT ADDINFO_ID, INFO, LANGUAGE_FK, ENGLISH_NAME
FROM V_ADDINFOS
WHERE LANGUAGE_FK = 'EN' (which is very simple...-)
But now complicated... I have to add this in the same request:
select sum(val) as nbrInfo
from(
select count(*) val from eccgis where addinfo1_fk = ADDINFO_ID
union all
select count(*) val from eccgis where addinfo2_fk = ADDINFO_ID
union all
select count(*) val from eccgis where addinfo3_fk = ADDINFO_ID
union all
select count(*) val from thirdgis where addinfo1_fk = ADDINFO_ID
union all
select count(*) val from thirdgis where addinfo2_fk = ADDINFO_ID
In other words, for each row of the first select, I need to know how much it is linked in the tables eccgis and thirdgis...
Hope is is clear... -)
Thank you very very much,
MichelHi, Michel,
Almost anywhere that SQL allows an expression (such as a column name, literal or function call) it also allows a scalar sub-query, a SELECT statement based on any table (or tables) that returns one column and (at most) one row. Like other sub-queries, scalar sub-queries can be corellated to the main query.
To get the grand total you want on each row of your output:
SELECT ADDINFO_ID, INFO, LANGUAGE_FK, ENGLISH_NAME
, (select count(*) from eccgis where addinfo1_fk = ADDINFO_ID)
+ (select count(*) from eccgis where addinfo2_fk = ADDINFO_ID)
+ (select count(*) from eccgis where addinfo3_fk = ADDINFO_ID)
+ (select count(*) from thirdgis where addinfo1_fk = ADDINFO_ID)
+ (select count(*) from thirdgis where addinfo2_fk = ADDINFO_ID)
AS nrbInfo
FROM V_ADDINFOS
WHERE LANGUAGE_FK = 'EN';VERY IMPORTANT: Each sub-query must be in parentheses. You'll get a run-time error if any scalar sub-query returns more than one row. (Returning no rows is okay: the value will be NULL).
By the way, this looks like a bad table design. If each row in eccgis or thirdgis can be associated with more than one foreign key, they should be kept in a separate table. That's the standard way to handle many-to-many relationships. -
Help required in changing to str for dynamic sql
Hi
I am trying to make this to string for dynamic sql, this is a part of the sql which is giving problem with p_..as parameters from proc. Help me in this , iam also seeing dbms _output but stil unable to format it to required error free string.
|| ' AND ( po.abbreviationprojectopportid LIKE '
|| '%'
|| 'NVL'
|| '('
|| p_opp_code
|| ', ''NULL'')'
|| '%'
|| ' OR co.companyname LIKE '
|| '%'
|| 'NVL'
|| '('
|| p_client_name
|| ', '' NULL'')'
|| '%'
|| ' OR le.line_item_amount = NVL '
|| ' ('
|| p_booking_amt
|| ', -0.197) '
|| 'OR po.dealcurrency = NVL '
|| '('
|| p_currency
|| ',''NULL'')'
|| 'OR be.booking_entry_id LIKE '
|| '%'
|| 'NVL ('
|| p_entry_id
|| ',''NULL'')'
|| '%'
|| ' OR le.line_item_id LIKE '
|| '%'
|| 'NVL ('
|| p_line_item
|| ',''null'')'
|| '%'
|| ' OR be.ticket_num LIKE '
|| '%'
|| 'NVL ('
|| p_ticket_num
|| ',''NULL'')'
|| '%'
|| ' OR be.updatedby LIKE '
|| '%'
|| 'NVL ('
|| p_user_name
|| ',''NULL'')'
|| '%'
|| ' OR credittransaction.acct_code ='
|| 'NVL ('
|| p_gl_account
|| ','
|| '-0.197)'
|| 'OR debittransaction.acct_code ='
|| 'NVL ('
|| p_gl_account
|| ', '
|| '-0.197) '
|| 'OR credittransaction.profit_ctr_code ='
|| 'NVL ('
|| p_profit_center
|| ','
|| ' -0.197)'
|| 'OR debittransaction.profit_ctr_code ='
|| 'NVL ('
|| p_profit_center
|| ','
|| '-0.197)'
|| ' OR le.sap_posting = NVL ('
|| p_sap_posting
|| ',''$'')'
|| 'OR cmis.cmis_code = NVL ('
|| p_cmis_nominal
|| ','' -0.197)'
|| 'OR sa.sap_code = NVL ('
|| p_sap_booking_entity
|| ', -0.197)'
|| ' OR (be.booking_date BETWEEN '
|| v_booking_date_from
|| 'AND '
|| v_booking_date_to
|| ')'
|| ' )'
|| 'ORDER BY '
|| p_sort_by
|| ' '
|| p_order;some errors.. Try this...
' SELECT be.booking_date bookingdate, '
|| ' be.booking_entry_id entryid, le.line_item_id itemid,'
|| ' po.abbreviationprojectopportid opportunitycode,'
|| ' co.companyname clientname, '
|| ' le.line_item_amount bookingamount,'
|| ' be.ticket_num ticketnum, po.dealcurrency currency,'
|| ' cmis.cmis_code cmis_nominal,'
|| ' sa.sap_code sap_booking_entity,'
|| ' (SELECT full_name '
|| ' FROM iba_employee '
|| ' WHERE TO_CHAR (employeeid) = be.updatedby) updatedby,'
|| ' be.updateddate updateddate, '
|| ' (SELECT le.line_item_amount * rate '
|| ' FROM iba_currencyconversion '
|| ' WHERE tocurrencycd = '
|| 'USD'
|| ' AND currencycd = po.dealcurrency '
|| ' AND conversiondate = be.booking_date) amountusd,'
|| 'debittransaction.acct_code debitglaccount,'
|| ' credittransaction.acct_code creditglaccount,'
|| ' debittransaction.profit_ctr_code debitprofitcenter,'
|| ' credittransaction.profit_ctr_code creditprofitcenter,'
|| ' debittransaction.amt debitamount,'
|| ' credittransaction.amt creditamount'
|| ' FROM rb_booking_entry be, '
|| ' rb_line_item le, '
|| ' rb_booking_period bp,'
|| ' rb_cmis_gl_account cmisgl,'
|| ' rb_cmis_account cmis,'
|| ' iba_projectopportunity po,'
|| ' iba_company co,'
|| ' rb_sap_account sa,'
|| ' (SELECT acctr.line_item_id line_item,'
|| ' sapgl_acc.account_code acct_code,'
|| ' acctr.amount amt,'
|| ' sappr.profit_center_code profit_ctr_code'
|| ' FROM rb_account_transaction acctr,'
|| ' rb_sap_profit_center sappr,'
|| ' rb_sap_gl_account sapgl_acc'
|| ' WHERE acctr.profit_center_id = sappr.profit_center_id '
|| ' AND acctr.gl_account_id = sapgl_acc.gl_account_id '
|| ' AND acctr.transaction_type = ''D'') debittransaction,'
|| ' (SELECT acctr.line_item_id line_item,'
|| ' sapgl_acc.account_code acct_code,'
|| ' acctr.amount amt,'
|| ' sappr.profit_center_code profit_ctr_code '
|| ' FROM rb_account_transaction acctr, '
|| ' rb_sap_profit_center sappr, '
|| ' rb_sap_gl_account sapgl_acc '
|| ' WHERE acctr.profit_center_id =sappr.profit_center_id '
|| ' AND acctr.gl_account_id = sapgl_acc.gl_account_id '
|| ' AND acctr.transaction_type = ''C'') credittransaction '
|| ' WHERE po.projectopportunityid = be.projectopportunityid '
|| ' AND be.booking_entry_id = le.booking_entry_id '
|| ' AND po.companyid = co.companyid '
|| ' AND bp.booking_period_id = be.booking_period_id '
|| ' AND cmis.cmis_id = cmisgl.cmis_id '
|| ' AND le.sap_id = sa.sap_id '
|| ' AND le.cmis_id = cmis.cmis_id '
|| ' AND debittransaction.line_item(+) = le.line_item_id '
|| ' AND credittransaction.line_item(+) = le.line_item_id '
|| ' AND ( po.abbreviationprojectopportid LIKE ' || '''%' || NVL(p_opp_code,'NULL') || '%'''
|| ' OR le.line_item_id LIKE '
|| '''%'
|| NVL (
|| p_line_item
|| ,'null')
|| '%'''
| ' OR le.line_item_amount = '
||NVL(|| p_booking_amt, -0.197)
|| ' OR po.dealcurrency ='
|| NVL(p_currency,'NULL')
|| ' OR be.booking_entry_id LIKE '
|| '''%'
|| NVL (p_entry_id,'NULL')
|| '%'''
|| ' OR be.ticket_num LIKE '
|| '''%'
|| NVL (p_ticket_num,'NULL')
|| '%'''
|| ' OR be.updatedby LIKE '
|| '''%'
|| NVL (p_user_name,'NULL')
|| '%'''
|| ' OR credittransaction.acct_code ='
|| NVL (p_gl_account,-0.197)
|| ' OR debittransaction.acct_code ='
|| NVL (p_gl_account, -0.197)
|| ' OR credittransaction.profit_ctr_code ='
|| NVL (p_profit_center, -0.197)
|| ' OR debittransaction.profit_ctr_code ='
|| NVL (p_profit_center, -0.197)
|| ' OR le.sap_posting = '
||NVL (p_sap_posting,'$')
|| ' OR cmis.cmis_code = '
||NVL (p_cmis_nominal, -0.197)
|| ' OR sa.sap_code = '
|| NVL (p_sap_booking_entity, -0.197)
|| ' OR (be.booking_date BETWEEN to_date('''
|| v_booking_date_from
|| ''') AND to_date('''
|| v_booking_date_to
|| ''')'
|| ' OR co.companyname LIKE '
|| '''%'
|| NVL(p_client_name,'NULL')
|| '%'''
|| ' )'
|| 'ORDER BY ' || p_sort_by || ',' || p_order; -
Help for identifing top sql statements
Hi all,
We are doing load testing on oracle 9i with 500 concurent users. At some point of
time the database was hang. I would like to know which query is taking more time/
which resource occuping more. Can any body help in this regard.
Thanks in advanceSome useful information can be found in V$SQLAREA, for example :
SQL> select SQL_TEXT, EXECUTIONS, DISK_READS, BUFFER_GETS, ROWS_PROCESSED, CPU_TIME, ELAPSED_TIME
2 from v$sqlarea
3* order by CPU_TIME desc; -
Hi,
Need help to write sql statement.
create table t_dt ( dt_start date, dt_end date, amount number);
insert into t_dt values('1-Jan-10','10-Feb-10',12);
insert into t_dt values('11-Feb-10','10-Mar-10',10);
insert into t_dt values('11-Mar-10','20-Apr-10',8);
insert into t_dt values('21-Apr-10','28-Jun-10',10);
insert into t_dt values('29-Jun-10','20-Sep-10',10);
insert into t_dt values('21-Sep-10','10-Oct-10',10);
insert into t_dt values('11-Oct-10','31-Dec-10',8);
insert into t_dt values('1-Jan-11','10-Feb-11',8);
insert into t_dt values('11-Feb-11','10-Mar-11',7);
insert into t_dt values('11-Mar-11','20-Apr-11',6);
insert into t_dt values('21-Apr-11','28-Jun-11',6);
insert into t_dt values('29-Jun-11','20-Sep-11',6);
insert into t_dt values('21-Sep-11','10-Oct-11',4);
insert into t_dt values('11-Oct-11','31-Dec-11',8);
Result should be like below..
dt_start dt_end Amount
1-Jan-10 10-Feb-10 12
11-Feb-10 10-Mar-10 10
11-Mar-10 20-Apr-10 8
21-Apr-10 10-Oct-10 10
11-Oct-10 10-Feb-11 8
11-Feb-11 10-Mar-11 7
11-Mar-11 20-Sep-11 6
21-Sep-11 10-Oct-11 4
11-Oct-11 31-Dec-11 8
Just to explain the example, take a row with start date as 21-Apr-10 in the above insert statements, since it has the same amount for next two rows (i.e. with start date '29-Jun-10' and '21-Sep-10') these 3 rows should be converted to represent only 1 row in the result and the start date and end date should be changed per the result shown above.
Thanks.Hello
I think this gives yuo what you need....
SELECT
MIN(dt_start),
MAX(dt_end),
amount
FROM
( SELECT
dt_start,
dt_end,
MAX(marker) OVER(ORDER BY dt_start) marker,
amount
FROM
Select
dt_start,
dt_end,
amount,
CASE
WHEN LAG(amount) OVER(ORDER BY dt_start) <> amount THEN
ROW_NUMBER() OVER(ORDER BY dt_start)
END marker
from t_dt
GROUP BY
amount,
marker
order by
MIN(dt_start)
MIN(DT_START) MAX(DT_END) AMOUNT
01-JAN-2010 00:00:00 10-FEB-2010 00:00:00 12
11-FEB-2010 00:00:00 10-MAR-2010 00:00:00 10
11-MAR-2010 00:00:00 20-APR-2010 00:00:00 8
21-APR-2010 00:00:00 10-OCT-2010 00:00:00 10
11-OCT-2010 00:00:00 10-FEB-2011 00:00:00 8
11-FEB-2011 00:00:00 10-MAR-2011 00:00:00 7
11-MAR-2011 00:00:00 20-SEP-2011 00:00:00 6
21-SEP-2011 00:00:00 10-OCT-2011 00:00:00 4
11-OCT-2011 00:00:00 31-DEC-2011 00:00:00 8
9 rows selected.HTH
David
Edited by: Bravid on Feb 23, 2012 12:08 PM
Beaten to it by Frank! :-) -
How will sql certification be helpful for a datamining career
Hi,
I have recently started to learn oracle and i am planning to go fro Sql certification in Oracle 9i. I also have a plan of venturing into datamining utilities in oracel 9i. Few advised that sql cert can be a good starting point. Can any one share some word of wisdom on my option or might suggest some other alternatives that might prove to be useful.
Thanks in advance
luxHow can we know how many processors are enough to buy?
I know that each SQL Server edition and version has it's different limitation of the number of processors it can support, for example SQL Server 2012 Standard Edition can support up to 4 sockets or 16 cores per SQL Server Instance, but this does not mean
that I have to buy 4 physical CPUs. two could be enough. how can I know?
This is off topic question how can we answer it. We even dont have any knowledge about your application.
Please speak to licensing specialist about servers and cores below link will give you more information.
https://msdn.microsoft.com/en-us/library/ms143760.aspx?f=255&MSPPError=-2147217396
Please mark this reply as answer if it solved your issue or vote as helpful if it helped so that other forum members can benefit from it
My Technet Wiki Article
MVP -
Need help trouble shooting Database Gateway for MS SQL Server setup, getting ORA-28546 error
Dear All,
I am trying to setup Oracle Database Gateway for MS SQL Server(I don't have admin access to the MS SQL Server). When I try to test the dblink connection, I get the following error.
I issued select * from dual@xyz;
ORA-28546: connection initialization failed, probable Net8 admin error
ORA-28511: lost RPC connection to heterogeneous remote agent using SID=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))(CONNECT_DATA=(SID=dg4msql)))
ORA-02063: preceding 2 lines from xyz
28546. 0000 - "connection initialization failed, probable Net8 admin error"
My setup is the following.
1. Oracle 11gR2 running on Oracle Linux 6, the same version gateway is installed on the same server, but different home directory.
2. Oracle DB home directory is /u01/app/oracle/product/11.2.0/dbhome_1, gateway home directory is /u01/gateway.
3. I use the same listener.ora file for both the db and the gateway.
4. the contents of my listener.ora, tnsnames.ora and the initdg4msql.ora are below.
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
#(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1522))
(ADDRESS = (PROTOCOL = TCP)(HOST = db.abc.com.tw)(PORT = 1522))
mssql =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME=db.abc.com.tw)
(ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)
(SID_NAME=orcl)
SID_LIST_mssql =
(SID_LIST =
(SID_DESC =
(SID_NAME=dg4msql)
(ENVS=LD_LIBRARY_PATH=/u01/gateway/dg4msql/driver/lib:/u01/gateway/lib)
(PROGRAM_NAME=/u01/gateway/bin/dg4msql)
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.abc.com.tw)(PORT = 1522))
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = db.abc.com.tw)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.abc.com.tw)
dg4msql =
(DESCRIPTION=
(ADDRESS=(PROTOCOL=TCP) (HOST=localhost)(PORT = 1521))
(CONNECT_DATA=(SID=dg4msql))
(HS=OK)
/u01/gateway/dg4msql/admin/initdg4msql.ora
HS_FDS_CONNECT_INFO=[192.168.0.1]:1433//XIETEST
# alternate connect format is hostname/serverinstance/databasename
HS_FDS_TRACE_LEVEL=255
HS_FDS_RECOVERY_ACCOUNT=RECOVER
HS_FDS_RECOVERY_PWD=RECOVER
dblink was created using statement below.
CREATE DATABASE LINK "xyz.abc.COM.TW"
CONNECT TO SA IDENTIFIED BY
USING 'dg4msql';
Couple more things, that I have done to check the work above.
[oracle@db admin]$ ping 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=61 time=7.61 ms
64 bytes from 192.168.0.1: icmp_seq=2 ttl=61 time=7.41 ms
^C
--- 192.168.0.1 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1818ms
rtt min/avg/max/mdev = 7.417/7.516/7.615/0.099 ms
[oracle@db admin]$ tnsping dg4msql
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2013 10:53:11
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=TCP) (HOST=localhost)(PORT = 1521)) (CONNECT_DATA=(SID=dg4msql)) (HS=OK))
OK (0 msec)
[oracle@db admin]$ lsnrctl status mssql
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 11-SEP-2013 10:54:23
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
Alias mssql
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 11-SEP-2013 10:09:46
Uptime 0 days 0 hr. 44 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/db/mssql/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))
Services Summary...
Service "dg4msql" has 1 instance(s).
Instance "dg4msql", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
Obviously, I would like to get this setup to work, but I also have couple other questions regarding this setup.
1. When installing the gateway, it asks to run the root.sh script. the root.sh script as for the following.
Enter the full pathname of the local bin directory: [/usr/local/bin]:
The file "dbhome" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: n
The file "oraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: n
The file "coraenv" already exists in /usr/local/bin. Overwrite it? (y/n)
[n]: n
is the above answer correct?
Thanks for reading.Dear Klaus,
I did start a new SQL*PLUS session
The output of /u01/gateway/bin/dg4msql is
[oracle@db log]$ /u01/gateway/bin/dg4msql
Oracle Corporation --- WEDNESDAY SEP 11 2013 14:45:06.604
Heterogeneous Agent Release 11.2.0.1.0 - 64bit Production Built with
Oracle Database Gateway for MSSQL
The output of env is
HOSTNAME=db.abc.com.tw
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
ORACLE_UNQNAME=orcl
TMPDIR=/tmp
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
USER=oracle
LD_LIBRARY_PATH=/u01/app/oracle/product/11.2.0/dbhome_1/lib:/lib:/usr/lib
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
ORACLE_SID=orcl
ORACLE_BASE=/u01/app/oracle
ORACLE_HOSTNAME=db.abc.com.tw
MAIL=/var/spool/mail/oracle
PATH=/u01/app/oracle/product/11.2.0/dbhome_1/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
PWD=/home/oracle
LANG=en_US.UTF-8
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/oracle
TMP=/tmp
LOGNAME=oracle
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
CLASSPATH=/u01/app/oracle/product/11.2.0/dbhome_1/jlib:/u01/app/oracle/product/11.2.0/dbhome_1/rdbms/jlib
LESSOPEN=|/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
G_BROKEN_FILENAMES=1
_=/bin/env -
Help Configuring Transparent Gateway for Ms Sql Server
I have Installed Oracle 9.2.0.1.0 with Transparent Gateway for Ms Sql Server.
Followed the configuration furnished therein the Documents for Tnsnames.ora & Listener.ora.
Connection to Sql Server 2000 is NOT SUCCESSFUL. Trace File contents from Tg4sql is furnished below :
Oracle Corporation --- WEDNESDAY DEC 18 2002 22:32:50.625
Heterogeneous Agent Release
9.2.0.1.0
HS Agent diagnosed error on initial communication,
probable cause is an error in network administration
Network error 2: NCR-00002: NCR: Invalid usage
Note :- Sql Server & Oracle Server are on the same Machine running of Windows 2000 Server.
Am i missing something !!!
TIAPlease guide me, would appreciate your suggestions to solve this heck....
TIA -
Loading XML parser for PL/SQL
I am working my way thru 'Building Oracle XML Applications' by Steve Muench.
I am getting a problem when I try to install the XML parser for PL/SQL
The following errors occur when I try to do
loadjava -v -r -u xmlbook/xmlbook xmlparserv2.jar
initialization complete
loading : oracle/xml/parser/v2/XMLByteReader
creating : oracle/xml/parser/v2/XMLByteReader
Error while creating class oracle/xml/parser/v2/XMLByteReader
ORA-29545: badly formed class: User has attempted to load a class (oracle.xml.parser.v2.XMLByteReader) into a restricted package. Permission can be granted using dbms_java.grant_permission(<user>, LoadClassInPackage...
loading : oracle/xml/parser/v2/PrintDriver
creating : oracle/xml/parser/v2/PrintDriver
Error while creating class oracle/xml/parser/v2/PrintDriver
ORA-29545: badly formed class: User has attempted to load a class (oracle.xml.parser.v2.PrintDriver) into a restricted package. Permission can be granted using dbms_java.grant_permission(<user>, LoadClassInPackage...
resolving: oracle/xml/parser/v2/PrintDriver
Error while resolving class oracle/xml/parser/v2/PrintDriver
ORA-04043: object /a065289c_PrintDriver does not exist
resolving: org/w3c/dom/html/HTMLAnchorElement
Error while resolving class org/w3c/dom/html/HTMLAnchorElement
ORA-04043: object /564607d_HTMLAnchorElement does not exist
About 20 classes get loaded correctly. All the rest get ORA-29545 or ORA-04043 errors.
I expect the ORA-04043 errors are a result of the earlier errors.
The documentation seems to indicate that there is no need to do
dbms_java.grant_permission to load into your own schema.
I have NT4 (sp6)
Oracle 8.1.7
xmlparserv2.jar dated 24/8/2001 17:01 size 1,177,259
xmlparserv2_2027.jar gives the same errors.
Any help would be appreciated.
nullWas it definitely xmlparsev2.jar that you had to load?
I recently started going through some of these examples as well and found that the standard xml parser was there but that I needed to load the xml parser for PL/SQL. I did this using loadjava from a subdirectory within the xdk directory and everything worked fine. -
Need help for understanding the behaviour of these 2 queries....
Hi,
I need your help for understanding the behaviour of following two queries.
The requirement is to repeat the values of the column in a table random no of times.
Eg. A table xyz is like -
create table xyz as
select 'A' || rownum my_col
from all_objects
where rownum < 6;
my_col
A1
A2
A3
A4
A5
I want to repeat each of these values (A1, A2,...A5) multiple times - randomly decide. I have written the following query..
with x as (select my_col, trunc(dbms_random.value(1,6)) repeat from xyz),
y as (select level lvl from dual connect by level < 6)
select my_col, lvl
from x, y
where lvl <= repeat
order by my_col, lvl
It gives output like
my_col lvl
A1 1
A1 3
A1 5
A2 1
A2 3
A2 5
A3 1
A3 3
A3 5
A4 1
A4 3
A4 5
A5 1
A5 3
A5 5
Here in the output, I am not getting rows like
A1 2
A1 4
A2 2
A2 4
Also, it has generated the same set of records for all the values (A1, A2,...,A5).
Now, if I store the randomly-decided value in the table like ---
create table xyz as
select 'A' || rownum my_col, trunc(dbms_random.value(1,6)) repeat
from all_objects
where rownum < 6;
my_col repeat
A1 4
A2 1
A3 5
A4 2
A5 2
And then run the query,
with x as (select my_col, repeat from xyz),
y as (select level lvl from dual connect by level < 6)
select my_col, lvl
from x, y
where lvl <= repeat
order by my_col, lvl
I will get the output, exactly what I want ---
my_col ....lvl
A1 1
A1 2
A1 3
A1 4
A2 1
A3 1
A3 2
A3 3
A3 4
A3 5
A4 1
A4 2
A5 1
A5 2
Why the first approach do not generate such output?
How can I get such a result without storing the repeat values?If I've understood your requirement, the below will achieve it:
SQL> create table test(test varchar2(10));
Table created.
SQL> insert into test values('&test');
Enter value for test: bob
old 1: insert into test values('&test')
new 1: insert into test values('bob')
1 row created.
SQL> insert into test values('&test');
Enter value for test: terry
old 1: insert into test values('&test')
new 1: insert into test values('terry')
1 row created.
SQL> insert into test values('&test');
Enter value for test: steve
old 1: insert into test values('&test')
new 1: insert into test values('steve')
1 row created.
SQL> insert into test values('&test');
Enter value for test: roger
old 1: insert into test values('&test')
new 1: insert into test values('roger')
1 row created.
SQL> commit;
Commit complete.
SQL> select lpad(test,(ceil(dbms_random.value*10))*length(test),test) from test;
LPAD(TEST,(CEIL(DBMS_RANDOM.VALUE*10))*LENGTH(TEST),TEST)
bobbobbobbobbobbobbobbobbobbob
terryterry
stevestevesteve
rogerrogerrogerrogerrogerrogerrogerrogerrogerYou can alter the value of 10 in the SQL if you want the potential for a higher number of names.
Andy -
Using DB Adapter for MS SQL Server 2005 SP in OSB 11g.
Hi All,
I have a requirement to create a DB Adapter for MS SQL Server Stored Procedure in JDeveloper and export the Adapter file to OSB 11g. I have Created the Adapter and imported it into OSB 11g successfully. Created the Datasource and Connection pool also in console.
The problem is while trying to execute the created business Service, I am getting the error as below,
<Oct 26, 2012 12:20:25 PM IST> <Error> <JCATransport> <BEA-381967> <Invoke JCA outbound service failed with application error, exception: com.bea.wli.sb.transports.jca.JCATransportException: oracle.tip.adapter.sa.api.JCABindingException: oracle.tip.adapter.sa.impl.fw.ext.org.collaxa.thirdparty.apache.wsif.WSIFException: servicebus:/WSDL/Test/CheckAppID/WL_Driver/CheckAppId_WL_Driver [ CheckAppId_WL_Driver_ptt::CheckAppId_WL_Driver(InputParameters,OutputParameters) ] - WSIF JCA Execute of operation 'CheckAppId_WL_Driver' failed due to: Unimplemented string conversion.
Conversion of JDBC type to String is not supported.
An attempt was made to convert a Java object to String using an unsupported JDBC type: .
; nested exception is:
BINDING.JCA-11804
Unimplemented string conversion.
My XSD is ,
<element name="InputParameters">
<complexType>
<sequence>
<element name="application_id" type="int" db:index="1" db:type="INT" minOccurs="0" nillable="true"/>
</sequence>
</complexType>
</element>
<element name="OutputParameters">
<complexType>
<sequence>
<element name="RowSet0" type="db:RowSet0_RowSet" db:type="RowSet0" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
<element name="RowSet1" type="db:RowSet1_RowSet" db:type="RowSet1" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</sequence>
</complexType>
</element>
<complexType name="RowSet1_RowSet">
<sequence>
<element name="RowSet1_Row" minOccurs="0" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="cde" type="int" db:type="INT" minOccurs="0" nillable="true"/>
<element name="msg" db:type="NVARCHAR" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="255"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
<complexType name="RowSet0_RowSet">
<sequence>
<element name="RowSet0_Row" minOccurs="0" maxOccurs="unbounded">
<complexType>
<sequence>
<element name="aaa" type="boolean" db:type="BIT" minOccurs="0" nillable="true"/>
<element name="bbb" db:type="NVARCHAR" minOccurs="0" nillable="true">
<simpleType>
<restriction base="string">
<maxLength value="10"/>
</restriction>
</simpleType>
</element>
</sequence>
</complexType>
</element>
</sequence>
</complexType>
I don't know why there is a datatype conversion error.
Help me in resolving this.
Regards,
Nataraj R.Hi,
I believe NVARCHAR is an unsupported type...
The following document lists the supported data types for SQL Server stored procedures and functions... NVARCHAR is not in the list... :-(
http://docs.oracle.com/cd/E23943_01/integration.1111/e10231/adptr_db.htm#CHDEBEEE
Hope this helps...
Cheers,
Vlad
Maybe you are looking for
-
Why can't I click on the "Buy Now" button on some apps in the Mac app store?
I've tried to buy Limbo, Modern Warfare, and a numerous ammounts of other games, but it won't let me click. on it. I hover my mouse over it, then click, but nothing happens. The button works fine with other apps, but some apps just don't work at all.
-
How to save a file with tiling
I have a completed artboard that I need to be tiled into nine 11"x17" sheets. How do I tile the board and how do I save the file so that when I take it to get it printed (i.e. Office Max, Fed Ex) it will print individually?
-
Media Offline After Restarting
I rebooted my computer and when I came back to my PremierePro project the Media was offline. The video appears in the viewer as "Media Pending", but it never loads in. In the project assets window, there is a question mark icon next to each media cli
-
We use oracle 9i on windows 2000, now we want to migrate database to another server. when I export all tables, it success without error and warning. But when I import, each time there is one table I could not import, give the message IMP-00058 oracle
-
Flashplayer Shortcut funktioniert nicht
Hi, warum funktioniert die Tastenkombination im Flashplayer (Strg+Pfeil nach rechts für "vor" und Strg+Pfeil nach links für "zurück" nicht? Welche Tastenkombination muss ich drücken, um mich je einen Schritt vor bzw zurück zu bewegen? Es handelt sich