How can I do Exp and Imp by using PL/SQL - oracle

How can I do Exp and Imp by using PL/SQL?

This could be done in a few ways.
First, if you're using 10g or later, you can consider using data pump (expdp and impdp) as opposed to imp and exp. These are the newer and more capable versions of those tools.
As for how to call them from PL/SQL, you can do so by:
You can make an external procedure call to a DLL (or shared library if you're on UNIX)
you could write a simple Java class (to run in the Oracle JVM) that would call out using Java
you could use Advanced Queues or DBMS_PIPE to communicate with external applications
You could use UTL_TCP to interact over the network (e.g. SOAP)
In 10g, you could use the DBMS_SCHEDULER package to call OS commands
The first and last options should be well documented in the Oracle online docs - the other two options would require a little more coordination and coding.

If you are using impdp/expdp - Datapump (10g or later) - , you can simply use DBMS_DATAPUMP:
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_datpmp.htm

You can see an example about exactly you are requesting in the Examples of Using the Data Pump API inside the Oracle Database Utilities book.

Related

What mechanism does 'sqlldr' use to connect to the DB

What happens in the background of a 'sqlldr' execution? How does it connect to the database? Is it using ODBC?
sqlldr is Oracle’s data loader utility. In general, the SQL*Loader client utility loads data into a
database at the same release level or higher.
For learning purpose change/remove the PATH environmental variable and then run the sql loader.
Like sqlplus, expdp, impdp the sqlldr utility is an OCI (Oracle Call Interface) application that uses Oracle Net (formerly called "SQL*Net" or "Net8") to connect and communicate with the database. No odbc nor jdbc.

Porting application which uses Oracle mod_plsql to PostgreSQL

I need to port an application that uses Oracle mod_plsql to PostgreSQL. Currently database procedures are called over HTTP with the use of Apache + mod_plsql. The procedures are easily ported to PostgreSQL, but I can not find a replacement for the Apache + mod_plsql part. Does anybody have any experience on ho to do it and what to use?
UPDATE (to make stuff more clear):
See: http://docs.oracle.com/cd/B14099_19/web.1012/b14010/concept.htm for how mod_plsql work.
What I need is a way to call a function on postgrsql as:
protocol://hostname[:port]/DAD_location/[[!][schema.][package.]proc_name[?query_string]]
ei:
http://www.acme.com:9000/pls/mydad/mypackage.myproc?a=v&b=1
You could fork my NodeJS based implementation of web_plsql as a starting point and "simply" replace the Oracle access with PostgreSQL.
You should be able to use pretty much all of the logic in NodeJS and only need to change the way how the code interacts with the database in the oracle.js module.

Oracle database - use external Java

I'm looking to find a way how to use higher versions of Java (1.6,1.7,...) instead of Java 1.4 which is available for Java stored procedures in a Oracle 10g.
I'm thinking about deploying a GlassFish server on the database server, and deploy web applications which functionalities would I use by calling them from PL/SQL.
Reasons for using Java instead of PL/SQL would be communications with various devices, calling and deploying web services, text processing...
Does anybody have a better, simpler idea on how to use higher version Java from PL/SQL in Oracle 10g database?
Forget about that. There used to be something called Jserver several years ago, but it was abandoned by Oracle. Theoretically you could use Oracle ver 12c which uses JVM ver 1.6. But even this JVM is slightly different. For example it's GC can kill threads when they are not bound to a "live" DB connection. So you may encounter various interesting problems.
There is no way how to "upgrade" JVM inside current Oracle DB installation.

Bulk export in oracle 8i

How can I export data from Oracle 8i database using command which I can run through oracle cli?
My biggest problem is, the data should be exported based in the query I use...
For ex,
select * from emp where emp_id>4
should dump the records having emp_id>4.
I don't have permission to use functions.
Please help!!
Oracle provides a set of tools that are designed for exporting data (the exp tool, for instance). These don't run via the SQL*PLUS command line (which I assume is what you mean by CLI), although they do connect via NET*8. From Oracle 8i onwards, you can use the query parameter to limit the rows exported:
exp scott/tiger tables=emp query="where deptno=10"
But you have to have the Oracle client installed and be able to connect to the database via SQL*NET.
If all you have is the ability to run queries, you're out of luck unless you can write a query that generates a CSV (tricky if you don't have the ability to call/write functions). It sounds to me like all you have access to is a web interface.

Write a file to SFTP using Oracle PL/SQL

I wrote a PL/SQL procedure to connect to an FTP server. I am able to write a file to that FTP server. Using the same code I tried to connect to an SFTP server, but it failed. How do I connect to SFTP using PL/SQL?
You can try the commercial ORA_SFTP package provided from DidiSoft:
connection_id := ORA_SFTP.CONNECT_HOST(...
ORA_SFTP.UPLOAD(connection_id, data, 'remote_file.dat');
Disclaimer: I work for DidiSoft
SFTP requires SSH plus the implementation of a protocol. As far as my PL/SQL knowledge reaches and Google's, there are currently no available implementation of SSH or this protocol in PL/SQL. There are some alternatives:
Use Java in the database and open sufficient ports. Not recommended when this is the only reason to use Java in the database; it is not as well designed as PL/SQL and can be expensive to maintain by a DBA since most DBA's have no experience with it.
Use PL/SQL to start a job outside the database. For instance, in the past I've used often Pentaho Data Integration (formerly known as Kettle) which provides a free solution to draw your data flow from table/procedure to sftp recipient and then run it. Running from PL/SQL requires a scheduler (I always used our own because it also integrates Kettle, but you can also consider the scheduler integrated with Oracle Apps, Redwood JCS/Cronacle or others). Coding in PL/SQL then becomes something like: 'begin package.submit('SFTP it'); package.wait; end;'.
I would go for the second option. If you need further details, please let me know.

Resources