Problem: I am trying to import a schema dump on Oracle XE database on my Windows XP machine. Here is the command I am using

        imp myuser file=mydump.dmp fromuser=myuser touser=mynewuser

I didn't get any problem when I use the same command for importing another schema on local database. Not sure why I am getting this error now.

IMP: ORA-12560 TNS:protocol adapter error

Solution: You need to specify the user and database name when you have more then one databases. So here is the command format you need to use for import.

        imp myuser/mypass@MyDB file=mydump.dmp fromuser=myuser touser=mynewuser

You can try below command if you dont like to specify the password on the command itself.

        imp myuser@MyDB file=mydump.dmp fromuser=myuser touser=mynewuser

Usually when connecting we have a query which has a
IN clause and it requires multiple values then you may need to go for creating a
String of all values and pass it.

Solution 1: You can try INSTR function of ORACLE
which can check for a value inside the comma separated String
value.


SELECT myid
FROM
mytable
WHERE INSTR(stringOfnumbers,','|| myid ||',') !=
0;


This solution may not be faster as it will not use
index for the myid column.

Solution 2: Create a PL/SQL function (say
str2table ) which converts comma separated String value to a table.
To store
the data in a table we need to create a data type as table type and then use the
same type as return type for our function.


create or replace type
myTableType as table of number;

create or replace function str2tbl(
p_str in varchar2 ) return myTableType

as
l_str long default
p_str || ',';

l_n
number;
l_data
myTableType := myTabletype();

begin

loop
l_n
:= instr( l_str, ','
);
exit
when (nvl(l_n,0) =
0);

l_data.extend;

l_data( l_data.count ) :=
ltrim(rtrim(substr(l_str,1,l_n-1)));

l_str := substr( l_str, l_n+1 );
end
loop;
return l_data;

end;


Here is how you can use above function


select * from all_users
where
user_id in ( select *
from THE ( select cast(
str2tbl( '1, 3, 5, 7, 99' ) as mytableType ) from dual )
)



passing values to IN clause, JDBC values to IN clause, passing number to IN clause, list of numbers in IN clause

Interesting Posts.....

Loading...