我正在尝试创建一个带有过滤器的选择查询,其日期时间字段等于“无穷大”字样。和' -infinity':
Here is the code.I am still getting the output as 2.3TCS3200 EVM Version.
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class JavaColorSensorDemo {
public JavaColorSensorDemo()
{
super();
}
void connect ( String portName ) throws Exception
{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if ( portIdentifier.isCurrentlyOwned() )
{
System.out.println("Error: Port is currently in use");
}
else
{
System.out.println("Connect 1/2");
CommPort commPort = portIdentifier.open(this.getClass().getName(),9600);
if ( commPort instanceof SerialPort )
{
System.out.println("Connect 2/2");
SerialPort serialPort = (SerialPort) commPort;
System.out.println("BaudRate: " + serialPort.getBaudRate());
System.out.println("DataBIts: " + serialPort.getDataBits());
System.out.println("StopBits: " + serialPort.getStopBits());
System.out.println("Parity: " + serialPort.getParity());
serialPort.setSerialPortParams(9600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_ODD);
serialPort.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_IN);
System.out.println("BaudRate: " + serialPort.getBaudRate());
System.out.println("DataBIts: " + serialPort.getDataBits());
System.out.println("StopBits: " + serialPort.getStopBits());
System.out.println("Parity: " + serialPort.getParity());
InputStream in = serialPort.getInputStream();
OutputStream out = serialPort.getOutputStream();
(new Thread(new SerialReader(in))).start();
(new Thread(new SerialWriter(out))).start();
}
else
{
System.out.println("Error: Only serial ports are handled by this example.");
}
}
}
public static class SerialReader implements Runnable
{
InputStream in;
public SerialReader ( InputStream in )
{
this.in = in;
}
public void run ()
{
byte[] buffer = new byte[1024];
int len = -1;
try
{
while ( ( len = this.in.read(buffer)) > -1 )
{
//System.out.println("Received a signal.");
System.out.print(new String(buffer,0,len));
}
}
catch ( IOException e )
{
e.printStackTrace();
}
}
}
public static class SerialWriter implements Runnable
{
OutputStream out;
public SerialWriter ( OutputStream out )
{
this.out = out;
}
public void run ()
{
try
{
byte[] data = {0x01,(byte)0x80,0x02,0x01};
while ( true )
{
this.out.write(data);
this.out.flush();
Thread.sleep(1000);
}
}
catch ( IOException | InterruptedException e )
{
e.printStackTrace();
}
}
}
public static void main ( String[] args )
{
try
{
(new JavaColorSensorDemo()).connect("COM66");
}
catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
我该怎么做?
答案 0 :(得分:3)
SELECT *
FROM mytable
WHERE dt = 'infinity'
OR dt = '-infinity';
这假定dt
是DATE
或TIMESTAMP
列。
你也可以明确这一点(显然它不是一个错字):
SELECT *
FROM mytable
WHERE dt = 'infinity'::timestamp
OR dt = '-infinity'::timestamp;