Reputation: 47
I'm working on an ASP.NET/ORACLE Application, where I'm trying to export users' Tables using a procedure but I always receive an error. I know that the error is in procedure syntax, but I'm not sure how to fix it.
Here is my code:
public static int ExporterTable(string login, string mdp, string Nomtable)
{
UserDAL.Connect(login, mdp);
OracleTransaction trans = UserDAL.conn.BeginTransaction();
//try
//{
// string sQuery1 = "exp userid="+login+"/"+ mdp+ " file='C:\\dell\\" +Nomtable+".txt'";
// string sQuery1 = "expdp scott/tiger tables=EMP directory=DATAPUMP dumpfile=EMP.dmp logfile=expdpEMP.log";
// string sQuery1="exp system/manager FILE=exp_u.dmp LOG=exp_u.log OWNER=oracle
string sQuery1 = "BEGIN exp userid:=" + login + "/" + mdp + " tables:=" + Nomtable + " file:='C:\\Dell\\" + Nomtable + ".dmp' log:='C:\\Dell\\" + Nomtable + ".log' END;";
OracleCommand cmd1 = new OracleCommand(sQuery1, UserDAL.conn);
cmd1.Transaction = trans;
// Exécution de la requête
cmd1.CommandText = sQuery1;
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.ExecuteNonQuery();
// On soumet la requête au serveur: tout s'est bien déroulé , la requête est exécutée
trans.Commit();
UserDAL.CloseConnection();
return 1;
//}
//catch (Exception) { return 0; }
}
Here is the error:
ORA-06550: line 1, column 17: PLS-00103: Symbol "USERID" met in place of one of the following symbols:
: =. (% @; Symbol "." was substituted for "USERID" to continue. ORA-06550: line 1, column 41: PLS-00103: Symbol "TABLES" met in place of one of the following symbols:
. (* @% & = - + At in is mod remainder not rem <> or! = or ~ => = <= <> and or like LIKE2 Between like4 likec | | member submu ORA-06550: line 1, column 59: PLS-00103: Symbol "FILE" met in place of one of the following symbols:
. (* @% & = - + At in is mod remainder not rem <> or! = or ~ => = <= <> and or like LIKE2 Between like4 likec | | multiset membe
Upvotes: 1
Views: 1521
Reputation: 12179
Well, you have a lot of issues going on here:
There is no colon ":" used in EXP parameter assignment, just PARAMETER=value. Read the EXP documentation
EXP is not an oracle PL/SQL or SQL command. It it a command-line executable. You cannot just call it as an anonymous PL/SQL block. You need to launch it from a shell/command script of some sorts.
You can use the dbms_scheduler package to schedule a task to run on the server (see here how to do that), or use DBMS_DATAPUMP to export data.
Upvotes: 3