Wednesday, August 25, 2010

convert only first later into capital

select initcap('PANJIM OPP BEACH RESORT CAMPAL TISWADI GOA')
output:="Panjim Opp Beach Resort Campal Tiswadi Goa"

Saturday, August 21, 2010

Insert data from table of one schema to another.

 INSERT INTO cynosure.angles SELECT * FROM angles WHERE  city ilike 'KDMC'         

When the schema is public there is noneed to specify it i.e. there is no need to do schemaname.tablename

Thursday, August 19, 2010

Check Table Is Present in SCHEMA or not

   
                                $table="poinavigation_".$city;
                $tableExistQuery="SELECT relname FROM pg_class
         WHERE relname ilike '".$table."
'";
                $result=@pg_query($connectionTo38,$tableExistQuery);
                $istableExist=pg_num_rows($result);
                if($istableExist)
                {
                    while($row = pg_fetch_Array($result))
                    {
                        $table=$row['relname'];
                    }
                }
                else
                $table="poinavigation";

Thursday, August 5, 2010

Table in Relation is present or not

SELECT relname FROM pg_class
         WHERE relname ilike '".$table."'

Tuesday, August 3, 2010

postgresql-ARRAY

 
expression operator ANY (array expression)
expression operator SOME (array expression)
 
 The right-hand side is a parenthesized expression, which must yield an
array value.
The left-hand expression
is evaluated and compared to each element of the array using the
given operator, which must yield a Boolean
result.
The result of ANY is “true” if any true result is obtained.
The result is “false” if no true result is found (including the special
case where the array has zero elements).If the array expression yields a null array, the result of
ANY will be null.  If the left-hand expression yields null,
the result of ANY is ordinarily null (though a non-strict
comparison operator could possibly yield a different result).
Also, if the right-hand array contains any null elements and no true
comparison result is obtained, the result of ANY
will be null, not false (again, assuming a strict comparison operator).
This is in accordance with SQL's normal rules for Boolean combinations
of null values.
 
SOME is a synonym for ANY.