Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
2 replies
Subscribers
5 subscribers
Views
972 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Plug-Ins
Hello, I have a JAVA function that has two lists (Companies and Application
bojanb
over 11 years ago
Hello,
I have a JAVA function that has two lists (Companies and Applications) as input parameters. Based on those input parameters, I have two "for" loops - one nested in another. That is because I want to check every input Application in every Company. Inside the "for" loop, I read from a database, and the result (that can be only one element) is put in a list called "list". So basically, the list gets filled with every iteration of the for cycles (assuming that the database check returned some value, otherwise, the list stays as it is, and i check the next element from the loops). My problem is: Every time i have more than one element in each of the "for" cycles, I get an empty list as a result. But if the input lists (Companies and Applications) are each filled with only one element, then the result returns a list with one element (which is correct). It seems like when I have more elements in the input lists, the result list gets overwritten and returns...
OriginalPostID-58422
OriginalPostID-58422
Discussion posts and replies are publicly visible
Parents
0
bojanb
over 11 years ago
... empty. Why is that?
Thank you in advance. Now here is the code:
@Function
public String[] GetEmployeeApplication(ServiceContext sc,
@Parameter String SQLServer, @Parameter String DatabaseName,
@Parameter String UserName, @Parameter String Password,
@Parameter @UserDataType String SourceUser,
@Parameter String[] Applications,
@Parameter String[] Companies,
@Parameter java.sql.Timestamp From_Date,
@Parameter java.sql.Timestamp To_Date) {
Connection con = getConnection("jdbc:sqlserver://"+SQLServer+";databaseName=" +DatabaseName+ ";user="+UserName+";password="+Password);
String Application = "";
String Employees = SourceUser;
String[] mApplication = Applications;
String[] mCompany = Companies;
java.sql.Timestamp from_date = From_Date;
java.sql.Timestamp to_date = To_Date;
java.util.ArrayList<String> list = new ArrayList<String>();
try {
for (int i = 0; i < mCompany.length; i++) {
for (int j = 0; j < mApplication.length; j++) {
Statement stm = con.createStatemen...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Reply
0
bojanb
over 11 years ago
... empty. Why is that?
Thank you in advance. Now here is the code:
@Function
public String[] GetEmployeeApplication(ServiceContext sc,
@Parameter String SQLServer, @Parameter String DatabaseName,
@Parameter String UserName, @Parameter String Password,
@Parameter @UserDataType String SourceUser,
@Parameter String[] Applications,
@Parameter String[] Companies,
@Parameter java.sql.Timestamp From_Date,
@Parameter java.sql.Timestamp To_Date) {
Connection con = getConnection("jdbc:sqlserver://"+SQLServer+";databaseName=" +DatabaseName+ ";user="+UserName+";password="+Password);
String Application = "";
String Employees = SourceUser;
String[] mApplication = Applications;
String[] mCompany = Companies;
java.sql.Timestamp from_date = From_Date;
java.sql.Timestamp to_date = To_Date;
java.util.ArrayList<String> list = new ArrayList<String>();
try {
for (int i = 0; i < mCompany.length; i++) {
for (int j = 0; j < mApplication.length; j++) {
Statement stm = con.createStatemen...
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
Children
No Data