Package org.postgresql.util

Examples of org.postgresql.util.PSQLException


    }

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


    }

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

    }

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

    }

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

    }

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

    }

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

    }

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

    }
   
    /** time stamp add */
    public static String sqltimestampadd(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=3){
            throw new PSQLException(GT.tr("{0} function takes three and only three arguments.","timestampadd"),
                                    PSQLState.SYNTAX_ERROR);
        }
        String interval = EscapedFunctions.constantToInterval(parsedArgs.get(0).toString(),parsedArgs.get(1).toString());
        StringBuffer buf = new StringBuffer();
        buf.append("(interval ").append(interval)
View Full Code Here

        return buf.toString();
    }
   
    private final static String constantToInterval(String type,String value)throws SQLException{
      if (!type.startsWith(SQL_TSI_ROOT))
        throw new PSQLException(GT.tr("Interval {0} not yet implemented",type),
                    PSQLState.SYNTAX_ERROR);
      String shortType = type.substring(SQL_TSI_ROOT.length());
      if (SQL_TSI_DAY.equalsIgnoreCase(shortType))
        return "'"+value+" day'";
      else if (SQL_TSI_SECOND.equalsIgnoreCase(shortType))
        return "'"+value+" second'";
      else if (SQL_TSI_HOUR.equalsIgnoreCase(shortType))
        return "'"+value+" hour'";
      else if (SQL_TSI_MINUTE.equalsIgnoreCase(shortType))
        return "'"+value+" minute'";
      else if (SQL_TSI_MONTH.equalsIgnoreCase(shortType))
        return "'"+value+" month'";
      else if (SQL_TSI_QUARTER.equalsIgnoreCase(shortType))
        return "'"+ Integer.valueOf(value).intValue()*3+" month'";
      else if (SQL_TSI_WEEK.equalsIgnoreCase(shortType))
        return "'"+value+" week'";
      else if (SQL_TSI_YEAR.equalsIgnoreCase(shortType))
        return "'"+value+" year'";
      else if (SQL_TSI_FRAC_SECOND.equalsIgnoreCase(shortType))
        throw new PSQLException(GT.tr("Interval {0} not yet implemented","SQL_TSI_FRAC_SECOND"),
                    PSQLState.SYNTAX_ERROR);
      else throw new PSQLException(GT.tr("Interval {0} not yet implemented",type),
                PSQLState.SYNTAX_ERROR);
    }
View Full Code Here

   
   
    /** time stamp diff */
    public static String sqltimestampdiff(List parsedArgs) throws SQLException{
        if (parsedArgs.size()!=3){
            throw new PSQLException(GT.tr("{0} function takes three and only three arguments.","timestampdiff"),
                                    PSQLState.SYNTAX_ERROR);
        }
        String datePart = EscapedFunctions.constantToDatePart(parsedArgs.get(0).toString());
        StringBuffer buf = new StringBuffer();
        buf.append("extract( ").append(datePart)
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.