Trying to select data using SELECT OR on PostgreSQL but it's giving this output:
"*ERROR: invalid input syntax for integer:*"
Initially, it used worked on MySQL.
Object search=request.getParameter("search_data");
dbase.rs = dbase.st.executeQuery("select * from patient_reg where pat_no='"+search+"' OR pat_fname='"+search+"' OR pat_tel='"+search+"'");
I have done this and it has worked
String search = request.getParameter("search_data");
dbase.pst = dbase.con.prepareStatement("select * from patient_reg where pat_no::text='"+search+"' OR pat_fname='"+search+"' OR pat_tel='"+search+"'");
Related
I'm trying to create a tubmbling window for a Flink table in Java and query data for that window
Table table = tEnv.sqlQuery(query.getQuery());
// create a new column 'EventTime' of type Timestamp from 'EventTimetamp' which is a string
table = table.addColumns($("EventTimestamp").toTimestamp().as("EventTime"));
WindowGroupedTable windowedTable = table.window(Tumble.over("10.minutes").on($("EventTime").proctime())
.as("w"))
.groupBy($("w"), $("GroupingColumn"));
table = windowedTable.select($("*"));
However, I'm getting this error Expected LocalReferenceExpression. Got: EventTime when it tries to execute windowedTable.select($("*")). Does anyone know what this error means and how to solve it ?
The problem is with .addColumns($("EventTimestamp") .
addCoumns() takes an expression as input. Take a look at the example from docs.
Table orders = tableEnv.from("Orders");
Table result = orders.addColumns(concat($("c"), "sunny"));
In this example, the column "c" already exists and you tell flink to concatane the value in column "c" with string "sunny" and add the new value as a new column.
So the meaning of your code
table.addColumns($("EventTimestamp")
in English is "select EventTimeStamp from table and add the values as a new column"
As your table does not have a column "EventTimestamp" yet, expression $("EventTimestamp") returns error.
EDIT: The problem might be related about ROWTIME. Please take a look at my answer using-tumble-failing-on-timestamp
Table tableCpuDataCalculatedTemp = tableEnv.fromDataStream(streamCPUData, Schema.newBuilder()
.column("deviceId", DataTypes.STRING())
.column("cpuUsageAvarage", DataTypes.DOUBLE())
.column("cpuLoad15Average", DataTypes.DOUBLE())
.column("recordCount", DataTypes.INT())
.column("time_Insert_ts", DataTypes.TIMESTAMP(3))
.watermark("time_Insert_ts", "time_Insert_ts")
.build());
Im new on Groovy and need some help.
I have that table called RANGE with :
ID_RANGE - Integer
Year - Integer
six_Month - Integer
Initial_Range - String
Final_Range - String
Last_Update - TimeStamp
I have to do a script to update/insert Initial_Range and Final_Range.
I will receive the new data from a map called "df_map" with the following data:
df_map.Update_date -> String
df_map.six_Month -> Integer
df_map.Initial_range -> String (Format "AA-123456678")
df_map.Final_range -> String (Format "AA-123456678")
That script have to validate some requirements,
if it doesn't, it can´t continues:
the date have to be a valid timeStamp (yyyy-MM-dd HH:mm:ss.SSS)
there must be 1000 values between Initial_Range and Final_Range
Only can update or insert a future date
When check all this, have to search if the register to modify exits, if not exits, have to create it.
that script has helpers to do 2 actions:
sqlQuery -
Make a query against the bbdd and show and array with the data. It get parameters like bbdd,query and parameters maps.
EXAMPLE:
query = "SELECT * FROM RANGE WHERE ID_RANGE = :RANGE"
params = [:]
params.RANGE = 1
outcome = sqlQuery(bbdd,query,params)
-sqlUpdate -
It make an insert or an update against the database and returns an array with the result. It receives as parameters the database, query, parameter map.
EXAMPLE:
query = "UPDATE RANGE SET Initial_Range = :Initial_Range WHERE ID_RANGE = :RANGE"
params = [:]
params.RANGE = 1
outcome = sqlUpdate(bbdd,query,params)
I work with sql but never before with groovy.....
Thanks in advance ;)
I know there are some answers to this error. I know it's a syntax error, but can't fix it!!
I'm running these commands in a Pentaho transformation. They are from one DB to another.
SELECT emp, codlug, nombre, pais, pcia, codp FROM CONDOR.TCODLUG
order by codlug desc
select *
FROM CONDOR.TCABTRAN o138195,
CONDOR.TCRES o138205,
CONDOR.TCCTES o138234,
CONDOR.TITEMS o138320,
CONDOR.TPDC o138351,
CONDOR.TPROV o138355,
CONDORBI.VRENTRAN o138514,
CONDOR.TROCCONT o138537
WHERE ( (o138195.EMP = o138514.EMP AND o138195.CODTRAN = o138514.CODTRAN AND o138195.NUMTRAN = o138514.NUMTRAN)
and (o138205.EMP(+) = o138514.EMP AND o138205.UNORG1(+) = o138514.UNORG1 AND o138205.UNORG2(+) = o138514.UNORG2 AND o138205.UNORG3(+) = o138514.UNORG3)
and (o138234.EMP(+) = o138514.EMP AND o138234.CODCC(+) = o138514.CODCC AND o138234.NUMCC(+) = o138514.NUMCC)
and (o138320.CODITEM(+) = o138537.CODITEM)
and (o138351.CTACONT = o138514.CTACONT)
and (o138355.EMP(+) = o138537.EMP AND o138355.NUMPROV(+) = o138537.NUMPROV)
and (o138537.EMP(+) = o138514.EMP AND o138537.CODTRAN(+) = o138514.CODTRAN AND o138537.NUMTRAN(+) = o138514.NUMTRAN AND o138537.RENGLON(+) = o138514.RENGLON))
AND ((DECODE(o138351.ACRES,1,'C.Res',NULL)) = 'C.Res')
-- AND (o138514.CTACONT BETWEEN :"Cuenta Desde" AND :"Cuenta Hasta")
-- AND (o138514.FECREG BETWEEN :"Desde" AND :"Hasta")
-- AND (o138514.EMP = :"Empresa")
When I run the transformation it throws the syntax error:
java.sql.SQLSyntaxErrorException: ORA-00933: SQL command not properly ended
i´ve already search but can´t find a proper answer.
THNAKS!!!
You can have only one statement in the input table.
Well, you can have more, provided that they are separated by ";". However only the last one will produce rows in the output. (This feature is there to make temporary tables or procedures to execute on the last statement).
If you want a union, and do not want to do it in sql, then make two table input steps and drop those two in the same PDI step. You'll get an error if the metadata (column names, order and types) are not the same.
My query is like this:
select * from plat_customs_complex
where (code_t,code_s)
in (('01013090','10'),('01029010','90'));
It runs well in psql console. My question is how to perform this query in client code.(via C# or Java)
And I already know the following code works well(C#):
string[] codeT = new string[]{"01013090","01029010"};
connection.Query("SELECT * FROM plat_customs_complex WHERE code_t=ANY(#CodeT)",
new { CodeT = codeT });
Finally, I found the unnest function can help.
Pure SQL is like that:
select * from plat_customs_complex
where (code_t,code_s) = ANY(select * from unnest(ARRAY['01013090','01029010'],ARRAY['10','90']))
Can convert it to C# code easily:
string[] codeTs = new string[]{"01013090","01029010"};
string[] codeSs = new string[]{"10", "90"};
connection.Query("select * from plat_customs_complex
where (code_t,code_s) = ANY(select * from unnest(#CodeTs, #CodeSs))",
new {CodeTs=codeTs, CodeSs=codeSs});
i am doing a task converting VB script written from Powerbuild to java,
i am struggled at converting the DataStore Object into java ,
i have something like this :
lds_appeal_application = Create DataStore
lds_appeal_application.DataObject = "ds_appeal_application_report"
lds_appeal_application.SetTransObject(SQLCA)
ll_row = lds_appeal_application.retrieve(as_ksdyh, adt_start_date, adt_end_date, as_exam_name, as_subject_code)
for ll_rc = 1 to ll_row
ldt_update_date = lds_appeal_application.GetItemDatetime(ll_rc, "sqsj")
ls_caseno = trim(lds_appeal_application.GetItemString(ll_rc, "caseno"))
ls_candidate_no = trim(lds_appeal_application.GetItemString(ll_rc, "zkzh"))
ls_subjectcode = trim(lds_appeal_application.GetItemString(ll_rc, "kmcode"))
ls_papercode = trim(lds_appeal_application.GetItemString(ll_rc, "papercode"))
ls_name = trim(lds_appeal_application.GetItemString(ll_rc, "mc"))
ll_ksh = lds_appeal_application.GetItemDecimal(ll_rc, "ks_h")
ll_kmh = lds_appeal_application.GetItemDecimal(ll_rc, "km_h")
simply speaking, a datasoure is created and a data table is point to it by sql query(ds_appeal_application_report). Finally using a for loop to retrieve information from the table.
in java way of doing, i use an entities manager to createnativequery and the query can result a list of object array. However, i just dont know how to retrieve the information like VB using the DataStore Object.
please give me some advice . Thanks