Procedure calling in Oracle ADF

In Oracle Adf we will doing DML operation by calling the Procedure.Here the syntax of calling
Stored procedure is as follow:

Here Procedure name is --  Vinayprocedure(empno,job,name)

StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("Vinayprocedure");
call.addUnamedArgument("empno");
call.addUnamedInOutputArgument("job", "job", String.class);
call.addUnamedOutputArgument("name");

DataModifyQuery query = new DataModifyQuery();
query.setCall(call);
query.addArgument("empno");
query.addArgument("job");
query.addArgument("name");

session.addQuery("Vinayprocedure ", query);

Vector parameters = new Vector();
parameters.addElement(new Integer(7369));
parameters.addElement("engineer");
parameters.addElement("Vinay");
Object data = session.executeQuery(query, parameters);

When we are calling data from some view object, we can use this code  :-
VinayViewObject1Iterator= view object iterator.

StoredProcedureCall call = new StoredProcedureCall();
call.setProcedureName("Vinayprocedure2");
call.addNamedArgument("empno");
call.addNamedArgument("job");
call.addNamedArgument("name");

DataModifyQuery query = new DataModifyQuery();
query.setCall(call);
query.addArgument("empno");
query.addArgument("job");
query.addArgument("name");
Vector parameters = new Vector();

DCIteratorBinding iteratorobject= findIterator("VinayViewObject1Iterator");
RowSetIterator rowObject = iteratorobject.getRowSetIterator();
rowObject.setRangeSize(rowObject.getRowCount());
RowKeySet keysetobject = this.getTable().getSelectionState();
Set keySetobject = keysetobject.getKeySet();
Iterator itrobject = keysetobject.iterator();

while (itrobject.hasNext()) {
Integer intr = (Integer)itr.next();
VinayViewObjectRowImpl row =
(VinayViewObjectRowImpl)keysetobject.getRowAtRangeIndex(intr.intValue());
parameters.addElement(row.getAttribute(“empno));                       parameters.addElement(row.getAttribute(“job”));
parameters.addElement(row.getAttribute(“name”));

session.addQuery("Vinayprocedure2", query);
Object data = session.executeQuery(query, parameters);

parameters.clear();

Code to Send an Email in C#

dotnetlogo
Want to send an email from your .net application?
Just use the following code and don’t forget to put in the valid SMTP server id in the code and your email will be sent.

using System.Web.Mail;
private bool SendEmail(string sFrom, string sTo, string sCC,
string sBCC, string sSubject, string sMessage, int iMailType)
{
try
{
MailMessage Message = new MailMessage();

// If sFrom is blank, system mail id is assumed as the sender.
if(sFrom==””)
Message.From = “[email protected]”;
else
Message.From = sFrom;

// If sTo is blank, return false
if(sTo==””)
return false;
else
Message.To = sTo;

Message.Cc = sCC;
Message.Bcc = sBCC;
Message.Subject = sSubject;
Message.Body = sMessage;
Message.BodyFormat = MailFormat.Text;
SmtpMail.SmtpServer = “Put a valid smtp server IP”;
SmtpMail.Send(Message);

return true;
}
catch(System.Web.HttpException ehttp)
{
// Your exception handling code here…
return false;
}
catch(Exception e)
{
// Your exception handling code here…
return false;
}
catch
{
// Your exception handling code here…
return false;
}
}

Code to Write Log files in C#

dotnetlogo
Following method can be used to write errors into a log file through an application.

using System.IO;
public void WriteLogLine(string sCallerName, string sLogFolder,
long lCallerInstance, string sLogLine)
{
lock(this)
{
string sFileName;
sFileName = String.Format("{0}_{1:yyyy.MM.dd}_{2:00}.log",
sCallerName, DateTime.Now, lCallerInstance);
StreamWriter swServerLog =
new StreamWriter(sLogFolder + sFileName, true);
swServerLog.WriteLine(
String.Format("[{0:T}] {1}", DateTime.Now, sLogLine));
swServerLog.Close();
}
}