Function For Selecting data in Database helper:   public List&lt;Question&gt; slectQuestionsC(String tab_name) {      List&lt;Question&gt; quesList = new ArrayList&lt;Question&gt;();     // Select All Query     SQLiteDatabase db = this.getReadableDatabase();     String selectQuery = "SELECT * FROM " + tab_name ;      try {     Cursor cursor = db.rawQuery(selectQuery, null);      if(cursor != null){         cursor.moveToFirst();     }      // looping through all rows and adding to list     if (cursor.moveToFirst()) {         if (cursor.getCount() &gt; 0) {         do {             Question Quiz = new Question();             Quiz.setID(cursor.getInt(0));             Quiz.setQUESTION(cursor.getString(1));             Quiz.setOPT1(cursor.getString(2));             Quiz.setOPT2(cursor.getString(3));             Quiz.setOPT3(cursor.getString(4));             Quiz.setOPT4(cursor.getString(5));             Quiz.setANSWER(cursor.getString(6));             Quiz.setHINT(cursor.getString(7));             quesList.add(Quiz);         } while (cursor.moveToNext());     }     }     } catch (Exception e) { e.printStackTrace(); }      return quesList; }   I have called this function in main activity like this but it only return first value of the table but i want it to return whole values of table so I can save it to the list!:     Question currentQ;    List&lt;Question&gt; quesList;    int qid = 0;    @Override     protected void onCreate(Bundle savedInstanceState) {     // TODO Auto-generated method stub      super.onCreate(savedInstanceState);      db.Open();           quesList = db.slectQuestionsC(tab_name);         currentQ = quesList.get(qid);          setQuestionView();     next.setOnClickListener(new OnClickListener() {          @Override         public void onClick(View v) {             int ansID = options.getCheckedRadioButtonId();             RadioButton rb_ans = (RadioButton)findViewById(ansID);             String answer = rb_ans.getText().toString();             Log.d("yourans", currentQ.getANSWER()+" "+answer);               if(currentQ.getANSWER().equals(answer))             {                 scoreT++;                 Log.d("score", "Your score"+scoreT);             }              if (qid &lt; 6)             {                 try {                 currentQ=quesList.get(qid);                 setQuestionView();                 } catch (Throwable e) {                     e.printStackTrace();                     Toast("Exception" + e.toString());                 }              }             else              {                 qid = 1;                 Intent intent = new Intent(CustomQuizActivity.this, Quiz_End.class);                 Bundle b = new Bundle();                 b.putInt("score", scoreT); //Your score                 intent.putExtras(b); //Put your score to your next Intent                 startActivity(intent);             }           }     });   Here is a function for setting question view!     private void setQuestionView()    {      question_no.setText("Question #" + qid);     question_text.setText(currentQ.getQUESTION());     op1.setText(currentQ.getOPT1());     op2.setText(currentQ.getOPT2());     op3.setText(currentQ.getOPT3());     op4.setText(currentQ.getOPT4());        qid++;  }
129
What are Null Pointer Exceptions (java.lang.NullPointerException) and what causes them?  What methods/tools can be used to determine the cause so that you stop the exception from causing the program to terminate prematurely?
15484
Is it possible to automate the process of picklist values retrieval from the backend?  Here is how I am doing it right now:  @AuraEnabled public static List&lt;String&gt; retrieveMyObjectMyFieldOptions() {     List&lt;String&gt; res = new List&lt;String&gt;();      Schema.DescribeFieldResult fieldResult             = MyObject__c.MyField__c.getDescribe();     List&lt;Schema.PicklistEntry&gt; ple = fieldResult.getPicklistValues();     for(Schema.PicklistEntry f: ple) {         res.add(f.getLabel());         res.add(f.getValue());     }      return res; }   Is it possible to pass two strings to a method and get the same list as above? In other words is it possible to change the signature to the following:   public static retrieveMyObjectMyFieldOptions(String MyObject, String MyField)?
113519
I'm having a save method with several Conditions in it.Here is my apex class  invoiceset = [select SiteUrl__c, Prefix__c,Seperator__c,Seperator1__c,DateValue__c,DateValue1__c,Date_Format__c,Incrementer__c,Counter_Val1__c,counter__c from Invoice_setting__c limit 1];        if(invoiceSet[0].DateValue__c == 'Date' &amp;&amp; invoiceSet[0].DateValue1__c == 'Date'){         if(invoiceSet[0].Date_Format__c == 'dd-mm-yyyy'){              datenow = DateTime.now().format('dd-MM-yyyy');                   }else if(invoiceSet[0].Date_Format__c == 'MM-dd-yyyy'){              datenow = DateTime.now().format('MM-dd-yyyy');                     }else if(invoiceSet[0].Date_Format__c == 'dd/MM/yyyy'){              datenow = DateTime.now().format('dd/MM/yyyy');          }else if(invoiceSet[0].Date_Format__c == 'mm/dd/yyyy'){              datenow = DateTime.now().format('mm/dd/yyyy');          }else if(invoiceSet[0].Date_Format__c == 'yy'){              datenow = DateTime.now().format('yy');          }else if(invoiceSet[0].Date_Format__c == 'yyyy'){              datenow = DateTime.now().format('yyyy');          }           prefixName = invoiceset[0].prefix__c + invoiceSet[0].seperator__c + datenow + invoiceset[0].Seperator1__c + datenow;       }      else if(invoiceSet[0].DateValue__c == 'Counter' &amp;&amp; invoiceSet[0].DateValue1__c == 'Counter'){       if(invoiceSet[0].counter_val1__c == null){          invoiceSet[0].Counter_Val1__c = invoiceset[0].Counter__c;        }else if(invoiceSet[0].Counter_Val1__c == invoiceset[0].Counter__c){            intt = integer.valueof(invoiceSet[0].Counter__c) + integer.valueOf(invoiceSet[0].Incrementer__c) ;            invoiceSet[0].Counter_Val1__c = string.valueOf(intt) ;        }else {             intt = integer.valueof(invoiceSet[0].Counter_Val1__c) + integer.valueOf(invoiceSet[0].Incrementer__c) ;            invoiceSet[0].Counter_Val1__c = string.valueOf(intt) ;        }        update invoiceset;         prefixName = invoiceset[0].prefix__c + invoiceSet[0].seperator__c + invoiceSet[0].Counter_Val1__c + invoiceset[0].Seperator1__c +invoiceset[0].Counter_Val1__c;       } &amp;&amp; so on........   Inorder to cover all this conditions should I write those many methods or any other easy way?  Here is my Test Code  public static testmethod void test(){    invoice_setting__c setng = new invoice_setting__c(Name='Invoice Settings',SiteUrl__c='www.google.com',Prefix__c='Test',Seperator__c = '-',dateValue__c = 'Date',Seperator1__c = '/',dateValue1__c = 'Date',date_format__c='dd-mm-yyyy');     insert setng; } public static testmethod void test1(){     invoice_setting__c setng1 = new invoice_setting__c(Name='Invoice Settings',Prefix__c='Test',Seperator__c = '-',dateValue__c = 'Counter',Seperator1__c = '/',Counter_Val1__c=null,dateValue1__c = 'Counter',date_format__c='dd-mm-yyyy',Incrementer__c='10');     insert setng1; } &amp; so on......   Any Suggestions for this please
69441
I would like to create a function that operates on a table, for example  create or replace function test(t table)      returns void language plpgsql as $func$ begin        select * from t limit 10; end; $func$   Then, I can call the function with any tablename, e.g.  select test(myTable);   How would I do something like this?
115908
Suppose the following function:  CREATE FUNCTION [dbo].[ufnTest]() RETURNS TABLE AS RETURN SELECT 1 AS Nr   My actual function will select actual data from many different tables. I (mostly) understand the risks of using nolock hints, and decided that in this case I actually want them. So I try to call above function like this:  SELECT * FROM [dbo].[ufnTest]() WITH(NOLOCK)   However,  with the following message:     Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.   The tips for fixing this error are not relevant. Perhaps this table hint isn't available for table valued functions then?  There are several alternatives I'd consider. One is to use the hint on all tables in my select query, but I'd prefer not to as (a) I'll have to remember this whenever I change the function around and (b) it's repetitive. Another alternative would be to SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED, but a downside is that I don't quite know how to set it back to wat it was before (and statements after the select from my TVF should have the original isolation level).  So, I'd prefer to make WITH (NOLOCK) for a select from a table valued function work. Is this possible?
38323
This code compiles but in preview, it shows an error Invalid selectOptions found. Use SelectOption type in Apex.   public list&lt;student__c&gt; myStud = new list&lt;student__c&gt;();    List&lt;student__c&gt; stud_qry = new List&lt;student__c&gt;();     public list&lt;student__c&gt; getStud(){         stud_qry =  [select Id, First_Name__c, name from Student__c];          for(student__c getEm : stud_qry){           myStud.add(new student__c(Name = getEm.first_name__c+' ' + getEm.name));            }            return myStud;    }   VFP  &lt;apex:outputText &gt;Select Student:&lt;/apex:outputText&gt;                 &lt;apex:selectList size="1"&gt;                      &lt;apex:selectOptions value="{!Stud}"/&gt;                 &lt;/apex:selectList&gt;
64650
In an earlier question  I asked in general about the symbol table for an Apex class.  Using the Tooling API wrapper from  I am able to get part way there. But am unGodly confused.  If I go to the developer console, query editor, check the "Use Tooling API" box and run this query:  Select Id, Name, symbolTable FROM ApexClass Where Name Like '%NewCaseListController%'   I get back an ID, Name and [object Object] for the symbol table, meaning there is a symbol table object there.   But if I try the same query in Apex code in the execute anonymous window I get the error:   System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element location   If I do this in Apex I can get a result back, and according to the code for the class the result should be of type ToolingAPIWSDL.QueryResult. The QueryResult should contain a member consisting of a list of sObject_x records sObject_x[], unless I am mis-reading what that means.  ToolingAPIWSDL.QueryResult result = tooley.query('select Id, Name from ApexClass WHERE Name Like \'NewCaseListController\'');   I can take the result and apparently put the sObject_x object in it like this:  List&lt;ToolingAPIWSDL.sObject_x&gt; objList = new List&lt;ToolingAPIWSDL.sObject_x&gt;(); for(Integer i = 0; i&lt;result.records.size(); i++){     objList.add(result.records[i]); }   At least that does not throw an error and I can write:     System.debug('objList: ' + objList[0]);  And get a result, but how do I access the symbol table? Or more to the point, how can I get a list of methods and variables? I am assuming the symbolTable is the only way?
41779
I m trying to understand where we use following Database.Methods. I know if we want to insert a record to an object we use DML Statement. What i want to know is why/where we use Database. methods. It might be silly question. Database.saveResults Database.insert Database.query Database.Query Database.error   really appreciate the inputs. Thanks a ton in advance.
75524
Open the Tags page and select a specific tag(ex: Android) View the list of questions and open a question for more details. After answering the question press back button. I expect to go back to question list but Stack Exchange Android app is taking me to list of Tags.  This is very inconvenient. Every time either I have to press back key once more or select the tag and again move to the place where I was previously.
2552
Possible Duplicate:          I've coded something like this:  public bool IsDataChanged() {                T value1 = GetValue2;     T value2 = GetValue1();      return (valueInDB != valueFromView); }   Right now the function doesn't compile with the error "Operator '!=' cannot be applied to operands of type 'T' and 'T'". What do I have to do to make this function work ?
56441
I am currently programming a trigger on Opportunities.   I created a test class for this and in my Sandbox I created an account, contact and opportunity. When I try to reference them   Opportunity Opp = [SELECT id from Opportunity where name = 'Test1'];    and then start my   Test.startTest();         Opp.StageName = 'PO in (100%)';          update Opp;         Test.stopTest();   It just errors and shows that Opp returns 0 rows. However when I paste my first bit of code in 'Execute Anonymous' it returns a row and the correct info.   Does this mean I have to create an account, contact, quote and all necessary fields in my test class?
110550
For a new project that I'm doing in PHP I've created an SQLMethods class to connect to the database and perform queries. Tonight was the first night that I actually got to test it (I wrote it a week or so ago and forgot about it) and an unexpected error occured: When it was calling my ExecuteQuery() function, it wouldn't use the database I selected in the constructor.  The constructor:      public function SQLMethods() {         $SQLConnection = mysql_connect($SQLDBAddress, $SQLUserName, $SQLPassword);          if (!$SQLConnection) {             die('Could not connect: ' . mysql_error());         }          mysql_select_db($SQLDB, $SQLConnection);     }   The function in question:      public function ExecuteQuery($Query) {         mysql_query($Query, $SQLConnection) or die('Could not perform query: ' . mysql_error());     }   Does anyone see what the issue might be? Does the connection close after the constructor completes?
26106
I have webservice which is passed an array of ints. I'd like to do the select statement as follows but keep getting errors. Do I need to change the array to a string?  [WebMethod] public MiniEvent[] getAdminEvents(int buildingID, DateTime startDate) {         command.CommandText = @"SELECT id,                             startDateTime, endDateTime From                             tb_bookings WHERE buildingID IN                             (@buildingIDs) AND startDateTime &lt;=                             @fromDate";      SqlParameter buildID = new SqlParameter("@buildingIDs", buildingIDs); }
102897
Anyone working on the Android ('gPhone') have or know of a place where I can find a good ORM tool for it? The code is written in Java, and the database is SQLite. What I would like to find is a tool that given the object definition, can auto-generate the tables and the CRUD functions (that would be awesome), or, barring that, a tool that can take the table definition, the object definition, and auto-generate the CRUD functionality. The rub is that all of this must happen within the Android framework, which has its own conventions as to how database access works.
103721
Here is the code  global class DeleteRjectedQuote implements Database.Batchable{     global Database.QueryLocator start(Database.BatchableContext BC){         return Database.getQueryLocator([select id,Status from Case where Status='Escalated']);     }     global void execute(Database.BatchableContext BC,list lstcase){          if(!lstcase.isEmpty()){             delete lstcase;         }      }     global void finish(Database.BatchableContext BC){ }  }   test class:: i have gone through trailhead but I am getting 0 codecoverage. How can we increase code coverage::                                                                                       @isTest public class TestDeleteRjectedQuote {     @isTest static void testDeleteRjectedQuotemethod(){         Test.startTest();         Case qt = new Case();         qt.status = 'escalated';         insert qt;            DeleteRjectedQuote drq = new DeleteRjectedQuote();         database.executeBatch(drq);         Test.stopTest();     } }
93193
Trying to populate an lightning attribute if a single record exists and if multiple records exists would like to provide the user a select list to choose the record then set the attribute.  I cannot seem to get the lightning:select to get its value to be set:  Component  &lt;aura:component description="Account_Selection" controller="MyController"&gt;         &lt;!-- Handle component initialization in a client-side controller --&gt;         &lt;aura:handler name="init" value="{!this}" action="{!c.doInit}"/&gt;          &lt;!-- The list of accounts to display --&gt;         &lt;aura:attribute name="accounts" type="Account[]"/&gt;          &lt;lightning:select aura:id="a_opt" name="a_opt" label="Accounts"  onchange="{!c.onSelectChange}"&gt;             &lt;aura:iteration items="{!v.accounts}" var="account"&gt;                 &lt;option value="{!account.Id}"&gt;{!account.Name}&lt;/option&gt;             &lt;/aura:iteration&gt;         &lt;/lightning:select&gt; &lt;/aura:component&gt;   Controller  ({     doInit : function(component, event, helper) {         //console.log('here');         helper.getAccounts(component);     },      onSelectChange : function(component, event, helper) {         // Print out the selected value         var selected = component.find("a_opt").get("v.value");         console.log('@@@@@@@: ' + selected);     } })   Helper  ({     getAccounts : function(cmp) {          var action = cmp.get("c.getAccounts");          action.setCallback(this, function(response){             var state = response.getState();             if (state === "SUCCESS") {                 cmp.set("v.accounts", response.getReturnValue());                 cmp.set("v.accountId","ANIDTOTESTTHESET");                 var sel = cmp.find('a_opt');                 sel.set("v.value","ANIDTOTESTSETTINGTHEVALUE");             }         });          $A.enqueueAction(action);     } })   Now, the select DOES show the available select options but I cannot for the life of me get the value to be set via the code.   The above component is within a parent component as so:  &lt;c:Account_Selection aura:id="a_selection"/&gt;   The parent component has an attribute  &lt;aura:attribute name="accountId" type="Id"/&gt;   What I would like to happen:   If only one account record returned from the apex controller, set the value of the accountId attribute to the Id of that record If multiple accounts found, set the default value of the select list to a specific value and set the attribute value If user selects a value then set the value of the attribute   I have tried everything I can think of searched but cannot get it to work. The select list has all the options but the first value seems to always be selected regardless of the value I attempt to set.   The outPutText does not have any value despite explicitly setting it from the component..  Any ideas how to make this work?   Update  I think the issue is the "cmp" is not the lightning component it is the apex controller? How do i get a reference back to the component on the callback?
96988
I'm trying to write an Android app that requires users to select a value from a list of potentially hundreds. They're likely to know the item they're selecting to asking them to filter by typing seems like a sensible approach.  I've searched high and low but I can't find a standard way of doing this.  A spinner is no good and it takes too long to go through the list of values  An autocomplete box is no good as I need users to be contrained to only selecting items from my list.