FBI was told Steve Jobs would distort reality to achieve goals

There was a time when not much was known about the iconic co-founder of Apple. But after his death, more and more details about Steve Jobs, the person and CEO, have emerged. First there was his official biography, showing him an excellent entrepreneur and visionary but at the same time having a penchant for bullying and being a tough boss. Now FBI has released an extensive report on Jobs, full of rich details about his life as an individual and as an entrepreneur.
Most people contacted by FBI gave thumbs up to Jobs, telling sleuths that he had all the necessary abilities for a high-profile position with the government. For example one person - FBI had redacted all names from the released report - who had known Jobs for several years said Jobs was "an individual of good character and integrity and (he) knew nothing which would reflect upon him in a negative way". Most also said that he was very hard working and prudent with his finances. 
However, at the same time, FBI also found, "Several individuals questioned Mr Jobs' honesty, stating that Mr Jobs will twist the truth and distort reality in order to achieve his goals." One respondent told FBI that Jobs was suitable for high-level political post because honesty and integrity were not required for such positions. 

Why facebook does not get success in China

Facebook said last week it was contemplating re-entering China, the world's second biggest economy, after being blocked nearly three years ago. 


Few foreign internet companies have succeeded in China. EBay Inc, Google Inc, Amazon.com Inc, Yahoo Inc and most recently Groupon Inc form the list of notable online players who have failed to gain traction in the fast-growing nation of 1.3 billion people. It's actually a bit late for Facebook," said Hong Kong-based CLSA analyst Elinor Leung, who added that the market was already quite saturated with local players such as Sina Corp, Renren Inc, Kaixinwang001 and Tencent Holdings.
 Facebook first launched its Chinese interface in 2008 but was blocked by Beijing in mid-2009 following deadly riots in the western province of Xinjiang that authorities say were abetted by the social networking site.
Almost half of China's 500 million internet users use social networking sites, government data showed in January. The dominant players among China's social networking sites (SNS) are Renren and Sina Corp, which is attempting to turn its highly popular microblogging service, Weibo, into a full-fledged social network.
China's SNS space is more crowded and competitive than the U.S. with multiple large and established players all investing for long-term growth," said Joe Chen, chief executive of Renren, which would become a direct competitor with Facebook should the US giant enter the market. 
Facebook will enter a much more competitive market with a significantly different culture, business environment and other characteristics than what it has previously experienced in the global market," Chen added. Analysts agreed.

13000 websites are blocked by Pakistan, for vulgarity

Pakistani authorities have blocked 13,000 "obscene" websites and are taking more steps to prevent the spread of such materials through the Internet.A ministerial committee and a sub-committee had been formed to look into the matter. Khan expressed concern at what he described as the "rapid spread of obscene websites" and said the government currently has no mechanism to block all these websites. 


After a string of cases were filed in courts across Pakistan against blasphemous and pornographic contents on the internet, authorities last year began blocking websites. Earlier, authorities had blocked popular portals like Facebook and YouTube but the move was criticised by civil society groups. Following protests, authorities began selectively blocking only pages that contained blasphemous and pornographic materials.

How to call a function in store procedure Oracle PL/SQL

create or replace function final_sal(v_empno number)
return number
is
v_newsal number;
v_sal number;
v_comm number;
begin
select sal,comm into v_sal,v_comm
    from emp
      where empno=v_empno;
if v_comm is null then
v_newsal :=nvl(v_comm,2000);
V_newsal := (v_newsal+v_sal)*12;
return v_newsal;
else
v_newsal := (v_sal+v_comm)*12;
return v_newsal;
end if;
end final_sal;


create or replace procedure emp_details(v_empno number)
 is
 v_ename varchar2(20);
 v_job varchar2(20);
 v_mgr varchar2(20);
 v_sal number;
 begin
 select ename,job,mgr into v_ename,v_job,v_mgr
      from emp
        where empno=v_empno;
 v_sal := final_sal(v_empno);  -- here i call that function 
dbms_output.put_line('Emp Name:' || v_ename);
dbms_output.put_line('Emp Job :' || v_job);
dbms_output.put_line('Emp Mgr:' || v_mgr);
dbms_output.put_line('Emp Total Sal:' || v_sal);
end emp_details;

Difference between page include and file include in JSP


<jsp:include page="page.jsp" > is action which include the output of page.jsp at dynamically. Instead of copying all content of page.jsp Container translate ,compiles page.jsp separately and copy the output of page.jsp to current page. It means it's dynamic inclusion.


<@include file="page.jsp"> it is directory which copy all content's of page.jsp to current jsp page and then complete current page is translated and compiled. It is static inclusion of file which means copy all source code to current page as it is.

Enable and Disable Assertion in Java


How to enable and disable Assertion in Java

Assertion are simple check  assumption  made at the beginning of the program to ensure the program is true throughout  provided by  the Java language. For example, the range of age should be in between 18  and above; or cannot be more than 50.
These are the set of expression used in Java that enables you to check the assumption made in a program during throughout the execution of program. An Assertion contain a Boolean expression which is set to be true in the beginning of the program. For Example ,a program has a method that allow the value being passed to it should not be zero and negative, you test this assert by sending a only positive number that is greater than zero by using assert statement in java.

How to Enable and Disable Assertion

Assertion are disabled at run-time during execution of java program .
The command line prompt  -ea or enable assertions is used to enable assertion during run-time execution of the program.
java -ea:AssertDemonstration
The command prompt -da or disable is used to disable assertion during run-time execution of the program
java -da :AssertDemonstration

How to convert Enum to String with Example


we can convert Enum to String by using toString Method..


For example


enum EnumToString{
a,b,c
}
public class EnumToStringMain{
public static void main(String args[]){
System.out.println(EnumToString.a.toString); //Here we convert enum value into String
}
}


Output is:
a

Improving Performance of Java application


Thirteen Great Ways to Increase Java Performance

1. Use buffered I/O.
Using unbuffered I/O causes a lot of system calls for methods like InputStream.read(). This is common in code that parses input, such as commands from the network or configuration data from the disk.

2. Try to avoid new.
Garbage collection is rarely a serious performance overhead. But, Java1 virtual machine (JVM)-internal synchronization caused by the new operation can cause lock contention for applications with lots of threads. Sometimes new can be avoided by re-using byte arrays, or re-using objects that have some notion of a state-resetting method.

3. Native methods are really fast.
This sounds silly, but I had heard that the overhead of invoking a native method was so high that it might be the case that small Java methods would be faster. Not! In my test case, I implemented System.arraycopy in plain Java. I then compared this using arrays of different sizes against System.arraycopy . The native (original) method was about an order of magnitude faster, depending on the array size. The native-method overhead may be high, but they're still fast compared to interpreting byte code. If you can use native methods in the JDK, then you can remain 100% pure and have a faster implementation than if you used interpreted methods to accomplish the same thing.

4. String operations are fast.
Using x + y (where x and y are strings) is faster than doing a getBytes of the two and then creating a new String from the byte array. However, String operations can hide a lot of new operations.

5. InetAddress.getHostAddress() has a lot of new operations. It creates a lot of intermediate strings to return the host address. Avoid it, if possible.

6. java.util.Date has some performance problems, particularly with internationalization. 

If you frequently print out the current time as something other than the (long ms-since-epoch) that it is usually represented as, you may be able to cache your representation of the current time and then create a separate thread to update that representation every N seconds (N depends on how accurately you need to represent the current time). You could also delay converting the time until a client needs it, and the current representation is known to be stale.

7. Avoid java.lang.String.hashCode() .
If the String's length exceeds 16 characters, hashCode() samples only a portion of the String. So if the places that a set of Strings differ in don't get sampled you can see lots of similar hash values. This can turn your hash tables into linked lists! 

8. Architecture matters.
In most applications, good performance comes from getting the architecture right. Using the right data structures for the problem you're solving is a lot more important than tweaking String operations. Thread architecture is also important. (Try to avoid wait/notify operations--they can cause a lot of lock contention in some VMs.) And of course you should use caching for your most expensive operations.

9. I have mixed feelings about java.util.Hashtable . It's nice to get so much functionality for free, but it is heavily synchronized. For instance, get() is a synchronized method. This means that the entire table is locked even while the hashCode() of the target key is computed.

10. String.getBytes() takes about ten times as long as String.getBytes(int srcBegin, int srcEnd, byte dst[], int dstBegin) . This is because the former does correct byte-to-char conversion, which involves a function call per character. The latter is deprecated, but you can get 10% faster than it without any deprecated methods using the following code: 

    static void getBytesFast()
    {
      String str = new String("the dark brown 
        frog jumps the green tree");
      // alloc the buffer outside loop so 
      // all methods do one new per iteration...
      char buffer[] = new char[str.length()];
      for(int i=0; i<10000; i++)
      {
          int length = str.length();
          str.getChars(0, length, buffer, 0);
          byte b[] = new byte[length];
          for (int j = 0; j < length; j++)
              b[j] = (byte) buffer[j];
      }
    }

This still does an incorrect char->byte conversion though.

11. Synchronized method invocation is about six times longer than non-synchronized invocation.
This time hasn't been a problem in the Java Web Server, so we tend to try to break locks up into smaller locks to avoid lock contention. A lot of times people synchronize on an entire class for everything, even though the class contains variables that can be read/written concurrently without any loss of consistency. This calls for locking on the variables or creating dummy objects to serve as locks for the variables. 

12. Be careful about using lots of debugging code.
A lot of people do something like the following: 
  
 debug("foobar: " + x + y + "afasdfasdf");
  public static void debug(String s) {
// System.err.println(s);
        }
Then they think that they've turned off debugging overhead. Nope! If there are enough debugging statements, you can see a lot of time spent in creating new strings to evaluate "foobar: " + x + y + "afasdfasdf", which is then tossed after calling debug . 

13. Profiles of the Java Web Server show it spending about 1-2% of its time running the garbage collector under most uses. So we rarely worry about performance of the garbage collector. The one thing you want to be careful about is response time. Running with a large heap size decreases the frequency of a garbage collection, but increases the hit taken when one occurs. The current VM pauses all your threads when a garbage collection occurs, so your users can see long pauses. Smaller heap sizes increase the frequency of garbage collections, but decrease their length.

How to create File and Directory in Java Example


Create a File 

Whenever the data is need to be stored, a file is used to store the data. File is a collection of stored information that are arranged in string, rows, columns and lines etc.
In this section, we will see how to create a file. This example takes the file name and text data for storing to the file.
For creating a new file File.createNewFile( ) method is used. This method returns a boolean value true if the file is created otherwise return false. If the mentioned file for the specified directory is already exist then the createNewFile() method returns the false otherwise the method creates the mentioned file and return true. 
Lets see an example that checks the existence of  a specified file.
import java.io.*;


public class CreateFile1{
  public static void main(String[] args) throws IOException{
  File f;
  f=new File("myfile.txt");
  if(!f.exists()){
  f.createNewFile();
  System.out.println("New file \"myfile.txt\" has been created
  to the current directory");
  }
  }
}
First, this program checks, the specified file "myfile.txt" is exist or not. if it does not exist then a new file is created with same name to the current location.
               
Create Directory


This program  explains the process of creating all non-existent ancestor directories automatically. We will use the class File class to crate the directory.

Class File
The File class an abstract representation of file and directory pathnames. File class is used to interact with the files system.


Here is the code for creating directory and all non-existing ancestor directories:
import java.io.*;
class CreateDirectory
{
public static void main(String args[])
{
try{
String strDirectoy ="test";
String strManyDirectories="dir1/dir2/dir3";


//Create one directory
boolean success = (
 new File(strDirectoy)).mkdir();
if(success){
System.out.println("Directory:"
 +strDirectoy+"created");
}
//Create multiple directories
success =(newFile(strManyDirectories)).mkdirs();
if(success){
System.out.println("Directories:"
 +strManyDirectories+"created");
}


}catch(Exception e){//Catch exception if any
System.err.println("Error:"+e.getMessage());
}
}
}

Java Final Method with Example


A final method cannot be overridden by any subclass in java. This means if we try to override final method through subclass compiler will throw an error. 
This is example of Java final method

FinalMethod.java
public class FinalMethod {
  public final void finalMethodClass()
  {
          System.out.println("This is final method of java");
  }
}
Cannot override final methods


SubClassFinalMethod.java
public class SubClassFinalMethod extends FinalMethod{


        public void finalMethodClass()
        {
                // Error by compiler
                // Cannot override the final method from FinalMethod
        }
}
This will throw error as shown in code












Final Classes in Java

The class declared as final can't be subclass or extend..
In Java, a class organization such as: 
        class A {}


        class B extends A {}
results in a superclass (A) and a subclass (B). References to B objects may be assigned to A references, and if an A reference "really" refers to a B, then B's methods will be called in preference to A's. All of this is a standard part of the object-oriented programming paradigm offered by Java. 
But there is a way to modify this type of organization, by declaring a class to be final. If I say: 
        final class A {}
then that means that A cannot be further extended or subclassed. 
This feature has a couple of big implications. One is that it allows control over a class, so that no one can subclass the class and possibly introduce anomalous behavior. For example, java.lang.String is a final class. This means, for example, that I can't subclass String and provide my own length() method that does something very different from returning the string length. 
There is also a big performance issue with final classes. If a class is final, then all of its methods are implicitly final as well, that is, the method is guaranteed not be overridden in any subclass. A Java compiler may be able to inline a final method. For example, this program: 
        final class A {
                private int type;
                public int getType() {return type;}
        }


        public class test {
                public static void main(String args[])
                {
                        int N = 5000000;
                        int i = N;
                        int t = 0;
                        A aref = new A();
                        while (i-- > 0)
                                t = aref.getType();
                }
        }
runs about twice as fast when the class is declared final. 
Of course, much of the time it's desirable to use the superclass / subclass paradigm to the full, and not worry about wringing out the last bit of speed. But sometimes you have heavily used methods that you'd like to have expanded inline, and a final class is one way of achieving that.


Blank final

The blank final, which was introduced in Java 1.1, is a final variable whose declaration lacks an initializer.  A blank final can only be assigned once and must be unassigned when an assignment occurs. In order to do this, a Java compiler runs a flow analysis to ensure that, for every assignment to a blank final variable, the variable is definitely unassigned before the assignment; otherwise a compile-time error occurs.

In general, a Java compiler will ensure that the blank final is not used until it is assigned a value and that once assigned a value, the now final variable cannot be reassigned another value


What is final in Java? Final variable, Method and Class Example


Java Final Keyword 

A java variable can be declared using the keyword final. Then the final variable can be assigned only once. 
A variable that is declared as final and not initialized is called a blank final variable. A blank final variable forces the constructors to initialise it. 
Java classes declared as final cannot be extended. Restricting inheritance! 
Methods declared as final cannot be overridden. In methods private is equal to final, but in variables it is not. 
final parameters – values of the parameters cannot be changed after initialization. Do a small java exercise to find out the implications of final parameters in method overriding. 
Java local classes can only reference local variables and parameters that are declared as final. 
A visible advantage of declaring a java variable as static final is, the compiled java class results in faster performance. 

Final variables
A final variable can only be initialized once, either via an initializer or an assignment statement. It need not be initialized at the point of declaration: this is called a "blank final" variable. A blank final instance variable of a class must be definitely assigned at the end of every constructor of the class in which it is declared; similarly, a blank final static variable must be definitely assigned in a static initializer of the class in which it is declared: otherwise, a compile-time error occurs in both cases. [4] (Note: If the variable is a reference, this means that the variable cannot be re-bound to reference another object. But the object that it references is still mutable, if it was originally mutable.)
Unlike the value of a constant, the value of a final variable is not necessarily known at compile time. 
Example:


1. /*
2. Java Final variable example
3. This Java Example shows how to declare and use final variable in
4. a java class.
5. */
6.
7. public class FinalVariableExample {
8.
9. public static void main(String[] args) {
10.
11. /*
12. * Final variables can be declared using final keyword.
13. * Once created and initialized, its value can not be changed.
14. */
15. final int hoursInDay=24;
16.
17. //This statement will not compile. Value can't be changed.
18. //hoursInDay=12;
19.
20. System.out.println("Hours in 5 days = " + hoursInDay * 5);
21.
22. }
23. }
24.
25. /*
26. Output would be
27. Hours in 5 days = 120
28. */

You can see here :- Java Final Method with Example

Google is going to develope 'Terminator-style' HUD goggles

Google is going to  launch hi-tech glasses with in-built computer displays.Supposition is dominant  that hi-tech "heads up display" glasses are being developed at Google's secret "Google X" lab for months.
The glasses will be armed with cameras, an Android operating system.The glasses will run a version of the California-based Google's Android. 

Google specialist Seth Weintraub says, "Our tipster has now seen a prototype and said it looks something like Oakley Thumps. These glasses, we heard, have a front-facing camera used to gather information and could aid in augmented reality applications. "Google has always invested in speculative R&D projects -- it's part of our DNA. While the possibilities are incredibly exciting, the sums involved are very small by comparison to the investments we make in our core businesses.

Microsoft may ditch start button‎ in Windows 8

The start button evolved to become the operating system's 'launchpad', offering access to software, files and search functions. 
According to leaked screenshots from the tech site, The Verge, earlier test versions of Windows 8 had flattened the recognisable 'orb', but the new build removes it altogether. Microsoft's iconic start button, which was introduced in Windows 95, is likely to be removed in the software firm's upcoming Windows 8 version, according to a report. 


A thumbnail-like user interface will appear in Metro or desktop mode, providing a consistent way to access the Windows desktop and Start Screen in Windows 8 regardless of touch or mouse input," it added. Microsoft has not announced a release date for the new operating system, built to work with touchscreens as well as on conventional PCs, but it is widely expected to be released in the second half of 2012.

SQL and delayed locks

The purpose of delayed locking is to postpone the physical lock of a record as long as possible. The program places the physical lock immediately before updating. During updating, the value of the record at the moment of selection must be known, as this is compared to the value at the moment of updating. During comparison, the relationships between fields are taken into account.For a record to be delayed-locked when selected, the keyword FOR UPDATE must be included in the SELECT statement. In SQL, 'normal' record locking is not possible.
When placing a delayed lock on a record, the program fills the field <table>._dlock with an identification number linked to the record. This field identifies the original record. This guarantees a fast search procedure. This field will be overwritten when changing the record buffer.
Updates in combination with SELECT FOR UPDATE are executed with the following functions:
  • db.insert(table, DB.RETRY [, eflag])
  • db.update(table, DB.RETRY [, eflag])
  • db.delete(table, DB.RETRY [, eflag])
The DB.RETRY flag indicates that we are dealing here with updates with SELECT FOR UPDATE and retry points. This flag ensures that the actual update action is postponed until the commit. The db.update() and db.delete() functions with the DB.RETRY flag can be invoked only in combination with SELECT FOR UPDATE. The use of db.insert() with the DB.RETRY flag, on the other hand, is not linked to the use of SELECT FOR UPDATE.


Related Post:

SQL subquries

Baan SQL permits the use of subqueries. These are SELECT statements in the WHERE clause of another SELECT statement.Defining nested queries can be very difficult. It is best to define the subquery of the lowest level first and the main question last. 
Example 1
Select those prices from the item file that are above average. When calculating the average, the system should not take prices less than or equal to zero into account.
SELECT tiitm001.copr | cost price
FROM tiitm001
WHERE tiitm001.copr >
( SELECT avg(tiitm001.copr)
WHERE tiitm001.copr > 0 )
ORDER BY tiitm001.copr
In this case, the subquery should only produce one result (here the average cost price). If the subquery produces more than one result, use the operators IN and EXISTS.


Example 2
Select the numbers and names of all suppliers who have yet to deliver.
SELECT tccom020.suno, tccom020.nama
FROM tccom020 | Suppliers
WHERE EXISTS
( SELECT *
FROM   timps053 | Purchase orders
WHERE  timps053.suno = tccom020.suno )


SELECT tccom020.suno, tccom020.nama
FROM tccom020
WHERE tccom020.suno IN
( SELECT   timps053.suno
FROM     timps053
GROUP BY timps053.suno )


Related Post:

SQL and combined fields

Defining a query that can be handled efficiently by the query handler is a complex task. This is especially true if there are combined fields (which consist of a number of child fields), as each field must be specified separately. 


Specifying a combined field
As the designer can usually judge best which index should be used for an optimum result, the following construction enables the designer to specify a combined field:


WHERE ppmod001.comb1 = {"adv", "099", "123"}


A child field can be an expression, a BAAN 4GL variable, or a pseudo variable. A comparison operator (=, >, >=, etc.) for a combined field applies to the combination of all child fields. For example:
| suppose the combined field ppmod001.comb1 consists of the 
| fields ppmod001.modu, ppmod001.tblno and ppmod001.compno:


WHERE ppmod001.comb1 >= {"adv", "000", "100"}


| The above statement is equal to the following statement


WHERE ( ppmod001.modu > "adv" ) OR
( ppmod001.modu = "adv" AND ppmod001.tblno > "000" ) OR
( ppmod001.modu = "adv" AND ppmod001.tblno = "000" AND
                                  ppmod001.compno >= "100" )



Comparison operators for combined fields
The comparison operators #>, #>=, #<, #<= for a combined field apply to each child field separately. For example:


WHERE ( ppmod001.comb1 #>= {"adv", "000", "100"} AND
ppmod001.comb1 #<= {"zzz", "999", "200"} )


This represents the following: 
WHERE         ppmod001.modu >= "adv" AND ppmod001.modu <= "zzz" AND
ppmod001.tblno >= "000" AND ppmod001.tblno <= "999" AND
                        ppmod001.compno >= "100" AND ppmod001.compno <= "200"


If a child field of a combined field is not specified, the value of this field is free and is not included in the condition. For example:
WHERE ppmod001.comb1 #>= {"adv", "000", "100"} AND
                                                                  ppmod001.comb1 #<= {"zzz", "999"}
This represents the following:
WHERE ppmod001.modu >= "adv" AND ppmod001.modu <= "zzz" AND
ppmod001.tblno >= "000" AND ppmod001.tblno <= "999" AND
                        ppmod001.compno >= "100"


As the field ppmod001.compno has no upper limit, all values greater than or equal to 100 are fetched.


Indexes as combined fields
You can specify an index as a combined field even if a combined field is not present in the data dictionary. The index name is table._indexY where:


table is the name of the table or alias of a table
_index is a prefix to indicate that an index field is involved (a condition for this syntax is that there are no field names having this format)
Y is the sequence number of the index defined in the data dictionary
As a combined field is being used, the value must always be enclosed by '{' and '}'. For example:


WHERE tiitm001._index1 = { :item }


As with other combined fields, children of index fields for which no value is specified are not included in the condition. However, you can leave fields unspecified only at the end of the index, not in the middle.
An index's pseudo field cannot be used in the query preceded by ':'.


Related Post:

Company number

The company number used during execution of a BAAN 4GL query is the current company number. The current company number is:
  • the default company number ( defined in the session "Maintain User Data" )
  • a company number specified by the compnr.check() function
The <table._compnr field 
The <table>._compnr field enables the use of different company numbers. This field specifies the actual company number of the table. When this field is undefined, the current company number is taken as the default. 'Undefined' is denoted by the value -1.
When a record is selected with 'select <table>.*', the field <table>._compnr in the record contains the company number of the table. When inserting a record in a table with a specific company number, you must fill <table>._compnr with the corresponding company number. The function db.insert() takes care of this and writes the record in the correct (physical) table. No special file pointers are necessary (for example, by using db.bind()). 
Example
The record where the field ttadv100._compnr = 000 belongs to the
(physical) table ttadv100000
The record where the field ttadv100._compnr = 200 belongs to the


(physical) table ttadv100200


Using <table>._compnr in the WHERE clause
You can also use <table>._compnr in the WHERE clause of a Baan SQL statement. In this case it is used as a search condition. For example:


SELECT  ttadv100.*
FROM    ttadv100
WHERE   ttadv100._compnr = 200 AND ttadv100.cpac = 'tt'
This query lists all records from table ttadv100200 where ttadv100.cpac has the value 'tt'.


You can use <table>._compnr in the following ways:

  • <table>._compnr = <number> or <number> = <table>._compnr where <number> specifies an integer number. The value of <number> is taken as the company number. It must be a 3-digit number.
  • <table>._compnr = <string> where <string> specifies a list of company numbers, separated by commas [,]. This construction can be used to check a condition for a range of company numbers. The string can contain only digits and commas. (So, you specify company numbers 0 and 23 by <table>._compnr = "000,023"). For example:
  • SELECT ttadv100.*
  • WHERE ttadv100._compnr = "200,300" AND <condition>
  • This query results in a list of the records from the table ttadv100 (with company numbers 200 and 300) that match <condition>. 
  • <table>._compnr IN <set specification> where <set specification> is a set of constants or a subquery.
Combining <table>._compnr conditions
A list of AND conditions can contain only one condition that includes <table>._compnr. So, the following construction is possible:


WHERE <table>._compnr = 100 AND <condition>
but the following is not possible:
WHERE <table>._compnr = 100 AND <table>._compnr = 200 
In a list of OR conditions, each condition must have a condition on <table>._compnr, or none of them. So, the following construction is possible:
WHERE (<table>._compnr = 100 OR <table>._compnr = 200)
AND <condition>
but the following is not possible:
WHERE (<table>._compnr = 100 OR <other_field> = <value>)
AND <condition>


Related Post:

References

Retrieving references to a record
In the standard SQL interface, you can retrieve references to a record as follows:
| Suppose that tiitm001 has a reference to tccom010 (field 'cuno'),
| and to tccom011 (field 'suno')
table ttiitm001
table ttccom010
table ttccom011
SELECT tiitm001.*, tccom010.*, tccom011.*
FROM tiitm001, tccom010, tccom011
WHERE tiitm001.cuno = tccom010.cuno AND
tiitm001.suno = tccom011.suno



Retrieving references using REFERS TO
To simplify the retrieval of references, you can specify references (using the keyword REFERS TO) in the WHERE clause. Apart from simplifying the query, this also optimizes query handling. As references always refer to a primary key, they can be found immediately. Moreover, the program fills a field with reference characters if it does not find a reference. The following implements the previous example by using REFERS TO:
table ttiitm001
table ttccom010
table ttccom011
SELECT tiitm001.*, tccom010.*, tccom011.*
WHERE tiitm001.cuno REFERS TO tccom010 AND
tiitm001.suno REFERS TO tccom011
| OR
SELECT tiitm001.*, tccom010.*, tccom011.*
WHERE tiitm001 REFERS TO tccom010 AND
tiitm001 REFERS TO tccom011



REFERS TO syntax
A REFERS TO statement has the following form:
<from> REFERS TO <to> [PATH <path> [,<path>...]] [UNREF<mode>]
The following table explains the various parts of the statement:
<from> The referring table field or table.
<to> The table referred to.
<path> The path via which reference is reached (always table fields). If PATH is specified, specifying a table field for <from> is mandatory. For example:WHERE table1.field REFERS TO table4.fieldPATH table2.field, table3.field
<mode> A mode indicating system action if reference does not exist; possible values are:SKIP If a reference cannot be found, the record is skipped.CLEAR If a 
                        reference is empty or absent, the referring 
record is filled with spaces or 0 (numeric).SETUNREF The value of an undefined 
                        reference is filled with 
an 'undefined reference' sign, defined in the data 
dictionary, or with 0 (numeric).CLEARUNREF The referred record is filled with spaces or 0 
(zero) when reference fields are empty. When 
the reference is undefined the referred record 
is filled with an 'undefined reference' sign.Depending on the reference       
                                definition in the data dictionary, the default reference mode is:
reference mode in DD                         UNREF mode
mandatory                                         SETUNREF
mandatory unless empty                CLEARUNREF
not mandatory                                 CLEAR


Related Post:

Using Program Variables

As a 4GL query is handled via the bshell, you can directly relate program variables to it. Linking program variables is required for both the SELECT clause and the WHERE clause.
SELECT clause
In the <select list> of the SELECT clause, program variables are used to indicate the elements in which the query results must be stored. You can do this by explicitly specifying a program variable. The general syntax is:
<select part>:<program variable>


For example:
SELECT ppmod123.field1:my_val1
Or you can directly use a program variable (a table or field name) from the calling program in the <select list>. For example:
SELECT ppmod123.field1
In the first example, the program places the result in the <program variable>. In the second example, the name in the query and the name of the program variable are identical.


FROM clause
You can also use program variables in the WHERE clause. When evaluating the query, the program loads the values of the program variables into the query and includes them in the evaluation. This link can be realized by incorporating a program variable in the query, preceded by a colon [:]. For example:
WHERE ppmod123.field1 = :myval1
Note
A table field can be a program variable as well as a query variable. Note that the following query:
select tccom010.*
where tccom010.cuno = tccom010.cuno
has a different result from:
select tccom010.*
where tccom010.cuno = :tccom010.cuno
The latter selects one record; the former selects all records from the table tccom010, as tccom010.cuno by definition equals tccom010.cuno for each row.


Related Post:

SQL Syntax

The general structure of an SQL query is as follows:


SELECT <select list> 
[ FROM <from list> ] 
[ WHERE <where condition> ] 
[ GROUP BY <group list> 
[ HAVING <having condition> ] ] 
[ ORDER BY <order by list> [ WITH RETRY [REPEAT LAST ROW] ]] 


[ SET SPECIFICATION ] 


Related Post:

BAAN SQL

You use Baan SQL (Structured Query Language) to retrieve information from the database. With Baan SQL's SELECT statement, you can retrieve any selection of data from the database, regardless of the number of tables in which the data is stored. The system does search through all records sequentially. It bases its search on a number of conditions defined in the SELECT statement. 
The SELECT statement does not modify the data in the database. It is used simply to query the data. Whereas only one user at a time can modify data, any number of users can query or select the data concurrently.
The SELECT statement works at the table level; the output is also a table consisting of 0, 1, or more records. If the query is very specific, the output may consist of only one record. The structure of a SELECT statement is directly derived from the table structure. It takes the following general form:


SELECT columns ...
FROM table(s) ...
WHERE each row fulfills the condition(s) ...


The following sections provide information on SQL syntax and using SQL:

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More