import ifs.fnd.ap.Record;
import ifs.fnd.ap.RecordAttribute;
import ifs.fnd.ap.PlsqlCommand;
import ifs.fnd.ap.PlsqlBaseMethodCommand;
import ifs.fnd.ap.PlsqlBaseMethodAction;
import ifs.fnd.ap.PlsqlBaseMethodType;
import ifs.fnd.ap.Server;
import ifs.fnd.ap.APException;
public abstract class PLSQLCommands {
private static Server srv;
public static void main(String [] pars) {
try {
if(pars.length != 3) {
System.out.println("Syntax : java PLSQLCommands [connectstring] [identity] [password]");
System.out.println();
return;
}
srv = new Server();
srv.setConnectionString(pars[0]);
srv.setCredentials(pars[1], pars[2]);
System.out.println();
System.out.println("\n***** IFSAPP Description *****");
GetUserDescription();
System.out.println("\n***** Prepare Profile *****");
PrepareProfile();
}
catch(APException err) {
err.printStackTrace(System.out);
}
}
private static void GetUserDescription() throws APException {
PlsqlCommand cmd = new PlsqlCommand(srv, ":DESC := FND_USER_API.GET_DESCRIPTION(:IDENTITY)");
cmd.getBindVariables().add("IDENTITY", "IFSAPP");
cmd.getBindVariables().add("DESC", "");
cmd.execute();
System.out.println((String)cmd.getBindVariables().findValue("DESC"));
System.out.println();
}
private static void PrepareProfile() throws APException {
Record profile = new Record("PROFILE");
profile.add("OBJID", "");
profile.add("OBJVERSION", "");
profile.add("OWNER", "");
PlsqlBaseMethodCommand cmd = new PlsqlBaseMethodCommand(srv, PlsqlBaseMethodType.NEW, "FNDRR_CLIENT_PROFILE_API", "New__", profile, PlsqlBaseMethodAction.PREPARE);
cmd.execute();
RecordAttribute owner = profile.find("OWNER");
if(owner!=null && owner.hasValue())
System.out.println("OWNER set in Prepare_Insert to " + (String)owner.getValue());
else
System.out.println("OWNER set in Prepare_Insert to null");
System.out.println();
}
}