我是PostgreSQL的新手。我要转换或将此代码添加到存储过程。
2019-01-25 08:51:26,842 SEVERE [org.eclipse.birt.report.engine.api.impl.ReportEngine] (default task-34) An error happened while running the report. Cause:: java.lang.NullPointerException
at org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.addColumnBinding(ReportQueryBuilder.java:1561)
at org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.createSubQuery(ReportQueryBuilder.java:1452)
at org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.createQuery(ReportQueryBuilder.java:1398)
at org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder$QueryBuilderVisitor.visitGridItem(ReportQueryBuilder.java:509)
at org.eclipse.birt.report.engine.ir.GridItemDesign.accept(GridItemDesign.java:142)
at org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:256)
at org.eclipse.birt.report.engine.data.dte.ReportQueryBuilder.build(ReportQueryBuilder.java:226)
at org.eclipse.birt.report.engine.data.dte.AbstractDataEngine.prepare(AbstractDataEngine.java:180)
at org.eclipse.birt.report.engine.executor.ReportExecutor.execute(ReportExecutor.java:122)
at org.eclipse.birt.report.engine.internal.executor.wrap.WrappedReportExecutor.execute(WrappedReportExecutor.java:60)
...
答案 0 :(得分:1)
只需将其放入函数中即可
public Tokens(String token){
contents = token;
if (isNumeric(token)){
type = "NUM";
}else if (isAlpha(token)){
for (int i = 0; i < Main.keywords.size(); i++){
if (token.equals(Main.keywords.get(i).trim())){
type = "KEYWORD";
break;
}else if (i == Main.keywords.size() - 1){
type = "ID";
break;
}
}
}
}
您可以像这样使用它:
create function generate_anagrams(p_word text)
returns table(combo text, word text)
as
$$
WITH RECURSIVE t(i) AS (
SELECT *
FROM unnest((select regexp_split_to_array(p_word,''))::char[])
), cte AS (
SELECT i AS combo, i, 1 AS ct
FROM t
UNION ALL
SELECT cte.combo || t.i, t.i, ct + 1
FROM cte, t
WHERE ct <= 8
AND position(t.i in cte.combo) = 0
)
SELECT distinct cc.combo,ww.word
FROM cte cc
inner join words ww ON ww.word=cc.combo
WHERE length(combo)>1
AND ww.source_id in(1,2,19,21,24,26,33,34)
ORDER BY cc.combo ASC
$$
language sql;