Package org.postgresql.util

Examples of org.postgresql.util.PSQLException


    /** space translation */
    public static String sqlspace(List parsedArgs) throws SQLException{
        StringBuffer buf = new StringBuffer();
        buf.append("repeat(' ',");
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","space"),
                                    PSQLState.SYNTAX_ERROR);
        }
        buf.append(parsedArgs.get(0));
        return buf.append(')').toString();
    }
View Full Code Here


        if (parsedArgs.size()==2){
            return "substr("+parsedArgs.get(0)+","+parsedArgs.get(1)+")";
        }else if (parsedArgs.size()==3){
            return "substr("+parsedArgs.get(0)+","+parsedArgs.get(1)+","+parsedArgs.get(2)+")";
        }else{
            throw new PSQLException(GT.tr("{0} function takes two or three arguments.","substring"),
                                    PSQLState.SYNTAX_ERROR);
        }
    }
View Full Code Here

    /** ucase to upper translation */
    public static String sqlucase(List parsedArgs) throws SQLException{
        StringBuffer buf = new StringBuffer();
        buf.append("upper(");
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","ucase"),
                                    PSQLState.SYNTAX_ERROR);
        }
        buf.append(parsedArgs.get(0));
        return buf.append(')').toString();
    }
View Full Code Here

    }
   
    /** curdate to current_date translation */
    public static String sqlcurdate(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=0){
            throw new PSQLException(GT.tr("{0} function doesn''t take any argument.","curdate"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "current_date";
    }
View Full Code Here

    }

    /** curtime to current_time translation */
    public static String sqlcurtime(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=0){
            throw new PSQLException(GT.tr("{0} function doesn''t take any argument.","curtime"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "current_time";
    }
View Full Code Here

    }

    /** dayname translation */
    public static String sqldayname(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","dayname"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "to_char("+parsedArgs.get(0)+",'Day')";
    }
View Full Code Here

    }

    /** dayofmonth translation */
    public static String sqldayofmonth(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","dayofmonth"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "extract(day from "+parsedArgs.get(0)+")";
    }
View Full Code Here

    /** dayofweek translation
     * adding 1 to postgresql function since we expect values from 1 to 7 */
    public static String sqldayofweek(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","dayofweek"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "extract(dow from "+parsedArgs.get(0)+")+1";
    }
View Full Code Here

    }

    /** dayofyear translation */
    public static String sqldayofyear(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","dayofyear"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "extract(doy from "+parsedArgs.get(0)+")";
    }
View Full Code Here

    }

    /** hour translation */
    public static String sqlhour(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=1){
            throw new PSQLException(GT.tr("{0} function takes one and only one argument.","hour"),
                                    PSQLState.SYNTAX_ERROR);
        }
        return "extract(hour from "+parsedArgs.get(0)+")";
    }
View Full Code Here

TOP

Related Classes of org.postgresql.util.PSQLException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.