How to convert type numeric to integer - ejb

The field of my database it contains integer, but it refuses to recover me in numerique
Here is my code to convert numeric to int
t.setAnne(Integer.parseInt(""+cell.getNumericCellValue()));

Related

PL/SQL Changing datatype Big int To Varchar(string) facing error BIGINT not in range [-9223372036854775808]

I am trying to change existing attribute values whose datatype is big int by adding new attribute as datatype varchar
e.g : Existing attribute name is supplier_id (datatype is big int)
New Attribute name is supplier_id_1 (datatype is varchar)
Values present in attribute is 5 characters.
e.g : 370430 (big int ) ---> need to change into varchar "370430".
I'm facing Error message
BIGINT not in range [-9223372036854775808
Help me to solve this .

Postgresql function throwing error "ERROR: 42702: column reference "lv" is ambiguous"

This is my function what i am using in postgresql. I want this as output datatable.
RETURNS TABLE(lv integer, userid integer, ccode integer, cdate date, corp_id character varying)
I am new to postgresql. Please suggest how i can resolve this error. Please let me know if any further information needed to answer this problem.
Thank you in advance:)
-- FUNCTION: public.check_login(character varying, character varying)
-- DROP FUNCTION public.check_login(character varying, character varying);
CREATE OR REPLACE FUNCTION public.check_login(
username character varying,
password character varying)
RETURNS TABLE(lv integer, userid integer, ccode integer, cdate date, corp_id character varying)
LANGUAGE 'plpgsql'
COST 100
VOLATILE
ROWS 1000
AS $BODY$
begin
drop table if exists temp;
create table temp(lv int,userid int,ccode int,cdate date,corp_id varchar(20));
insert into temp(lv,userid,ccode,cdate,corp_id)
select lv,userid,code,CONVERT(varchar,cdate,103),corp_id from user_detail
where uname=username and pwd =Password and status='Active';
return query
select * from temp;
end;
$BODY$;
ALTER FUNCTION public.check_login(character varying, character varying)
OWNER TO postgres;
the ambigity meens that query engine can't guess what object to operate while having two object with the same name in one context.
replace
select lv,userid,code,CONVERT(varchar,cdate,103),corp_id from user_detail
where uname=username and pwd =Password and status='Active';
with
select ud.lv,ud.userid,ud.code,CONVERT(varchar,ud.cdate,103),ud.corp_id from user_detail AS ud
where ud.uname=username and ud.pwd=Password and ud.status='Active';
this will remove ambigity with same-named fields in selects and return structure

How to convert TIMESTAMP to UTC milliseconds in ESQL

Is there an ESQL function to convert TIMESTAMP to UTC milliseconds?
This is what I did:
DECLARE eventTimeInteger INTEGER CAST ((eventTimeStamp - epochTimeStamp) SECOND as INTEGER);
But I keep getting this error. So I suspect the "-" is an issue but I'm not sure how else to go about this.
BIP2420E: (.Event_SeparateMessages.Main, 142.60) : Invalid or incompatible data types for '-' operator.
Either the data types of the operands of the operator were not valid for the operator, or the datatypes were incompatible.
Correct the syntax of your ESQL expression in node '.Event_SeparateMessages.Main', around line and column '142.60', then redeploy the message flow: Ensure that the data types of the operands are valid and compatible with each other.
This below is what I've tried but it won't even deploy.
--Converting time in string to timestamp
DECLARE source CHARACTER eventTime ;
DECLARE eventTimeStamp CHARACTER;
DECLARE pattern CHARACTER 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z';
SET eventTimeStamp = CAST(source AS TIMESTAMP FORMAT pattern);
DECLARE epochTimeStamp TIMESTAMP '1970-01-01 00:00:00';
--Casting time from timestamp to Integer
DECLARE eventTimeInteger INTEGER CAST ((eventTimeStamp - epochTimeStamp) SECOND as INTEGER);
I need to have "eventTimeInteger" give me the timestamp in seconds.
The problem, if I'm reading your code right, is that you are trying to subtract a TIMESTAMP from a CHARACTER set.
edit: Noticed the change SET for eventTimeStamp, however the date math is still going to given an INTERVAL output, not an INTEGER
DECLARE EpocTimeStamp TIMESTAMP;
DECLARE eventTimeStamp INTERVAL;
SET EpocTimeStamp = TIMESTAMP '1970-01-01 00:00:00';
SET eventTimeStamp = (CURRENT_TIMESTAMP - EpocTimeStamp) SECOND * 1000;
CAST(eventTimeStamp AS INTEGER);

converting numeric value to String in SQLITE

I have tried to convert numeric value into string datatype in SQLITE.
While changing numeric (Int, float, Real)into string i got like this..
Ex: 2016 , 2016.12
output : 2016.0 , 2016.12
Expected Result: 2016 ,201612
My Code for conversion
CAST(`mega-join-Ex-v1`.`Annee` AS STRING)
Please any one suggest correct method to convert numeric into string type.

Sqlite3 user defined datatype

I can create table like this:
CREATE TABLE mytable
(
name text,
surname varchar
)
I can also create table like this:
CREATE TABLE mytable2
(
name BLABLA,
surname mygrandpaType
)
I know there is no diff between text and varchar in SQLite. But even in second table I can insert and select querys from it and works fine..
It does not make sense what is it use for datataype approach in SQLite ?
Any column with the exception of INTEGER PRIMARY KEY can hold values of any type. The specified datatype is just a hint and it is called type affinity.
Determining type affinity:
If the declared type contains the string "INT" then it is assigned INTEGER affinity.
If the declared type of the column contains any of the strings "CHAR", "CLOB", or "TEXT" then that column has TEXT affinity. Notice that the type VARCHAR contains the string "CHAR" and is thus assigned TEXT affinity.
If the declared type for a column contains the string "BLOB" or if no type is specified then the column has affinity NONE.
If the declared type for a column contains any of the strings "REAL", "FLOA", or "DOUB" then the column has REAL affinity.
Otherwise, the affinity is NUMERIC.
Therefore your BLABLA column gets the NUMERIC affinity.
Further reading: https://www.sqlite.org/datatype3.html

Resources