Convert string with date text to date format in BIRT table - birt

I have a Date which I retrieve as a string "Dec 20 2007" from my front end app and insert into a BIRT table.
Since the data type for this field is set as "Type: String" when I convert it to Date the table breaks and no data is visible in the Table.
My ultimate goal is to sort the table by Date.
Any solution to convert the string which is "Dec 20 2004" to date format in BIRT table.
Thanks.

Is is very simple, simply create a new empty column in the same table.
Add a data item with an expression like this:
new Date(row["String Date"])
http://developer.actuate.com/community/forum/index.php?/topic/36777-convert-string-with-date-text-to-date-format-in-birt-table/
Then you can sort on the new data binding.

Related

How to create an update query with typeorm and Oracle json column?

I have an Oracle table with a JSON column that I want to update, and I am using TypeORM with javascript. I need to access the JSON column in the where clause, following is the raw sql query and what I am attempting with typeORM:
Query updates the date to current date where the key's (inside the json column) value is 123.
entityManager.query(`UPDATE TABLE_NAME T
SET DATE = CURRENT_DATE
WHERE T.JSON_COLUMN.key = '123'`)
The query with createQueryBuilder:
tableRepository.createQueryBuilder()
.update('TABLE_NAME')
.set({DATE: '2021-07-23 10:07:10'})
.where('JSON_COLUMN.key = :key', {key: '123'})
.execute();
I am not sure how to access the JSON column's key in the where clause. Ideally, I would use the dot operator in SQL to access the JSON columns key value pairs, like so:
JSON_Column_Name.key = value but I cannot find a way to implement it with Oracle.
Any help would be appreciated.

Fetch Parent & Child records Quickbase API_DoQuery

I have a table A and Table B.
A is parent of B
What I want to do is perform a quickbase API call API_DoQuery to get the records in table A with all child records, something like this
id,
name
child:[id, name]
how can I do that right now I only got the values in table A and a number in the relation field
.
What I need to do ?
Thanks.
You can use a Combined Text summary field on the parent table to pull all child values into a single comma separated field on the parent table. Since Combined Text fields only work with strings, the Name field should work fine, but for the Record ID you need to first convert that to a string (text) in a new formula text field on the child table.
Summary field on parent:
Formula field to convert Record ID from numeric to string:

How to migrate column data to new data type

I need to migrate table's column to another data type with some modifications. Given: table 'USER' with column 'ORDER_TIME' (DateTime format). It's required to change column type to NUMBER, convert that time to a minutes (e.g. 8:00 AM = 480 mins.) and to store new value. As i understand, i need to create new column with required NUMBER data type, iterate over all records, do some recalculations, store new value, drop old column and rename new one to an actual name. So, basically, algorithm is:
ALTER TABLE USER ADD ORDER_TIME_MINS NUMBER(4) NULL;
iteration and recalculation
ALTER TABLE USER
DROP COLUMN ORDER_TIME
RENAME COLUMN ORDER_TIME_MINS TO ORDER_TIME;
Can you suggest me some reading on how that iteration may looks like?
You can try like this:
update tablename
set columnName = to_number(to_char(to_date(yourDateColumn,'hh24:mi:ss'),'sssss'))/60
And if your time is in format 08:00 PM then like
update tablename
set columnName =TO_NUMBER(TO_CHAR(TO_DATE('08:00 AM','HH:MI AM'),'SSSSS'))/60
Rest of the steps which you have shown ie, dropping and renamin are fine.

Hive Hadoop : Need to LOAD data into a table based on conditions on the input file

I am new to Hadoop Hive and have just started to do basic querying in hive.
My intention is I have an input text file (which has large number of records per line). The format of the file is something like this:
1;23;0;;;;1;3;2;1;1;4;5;6;;;;
1;43;6;;;;1;3;2;1;1;4;5;5;;;;
1;53;7;;;;1;3;2;1;1;4;5;2;;;;
(Each integer before a ";" has a meaning which I am intending to put it in Hive table as column names - and each line contains about 400 fields)
So for inserting this I have created a table "test" - using the following query:
CREATE TABLE test (field1 INT, field2 INT, field3 INT, field4 INT, ... field390 INT)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY "\073";
And I load my text file with the records using the LOAD query as below:
LOAD DATA LOCAL INPATH '/tmp/test.txt'
OVERWRITE INTO TABLE test;
For now all the fields are getting inserted into the table upto 50 fields accurately. Later I have mismatches.
What I have in my format of input is - at 50th field in the test.txt I have a INT number which decides the number of fields to take following the field.
Example:
50th field: 2 -> Hive has to take the next 2*10 field INT values and insert in the table.
50th field: 1 -> Hive has to take the next 1*10 field INT values and insert in the table. And the rest 10 fields can be set NULL.
(The maximum value of 50th field is 2 - so I have reserved 2*10 fields for this in the table)
After 50th+(2*10) fields , the data should be read normally in the sequence as it did before the 50th field.
Do we have a way in which we can have a condition on the input so that the data gets inserted accordingly in Hive.
A help may be appreciated. Need a solution which will not guide me to pre-process the test.txt and then supply to the table.
I have tried to answer it at http://www.knowbigdata.com/page/hive-hadoop-need-load-data-table-based-conditions-input-file#comment-85
Does it make sense?
You can use where clause in Hive.
First load data into Hive raw table or HDFS, then again create table and load data based on where clause.
Means:
SELECT * FROM table_reference
WHERE name like "%venu%"
GROUP BY City;
Resource: https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Select

how to insert current date into a DATE field in dd/mm/yyyy format in oracle

I have a field in my table with datatype as DATE in Oracle.
I want to insert the current date into that field, in format DD/MM/YYYY format.
I tried the below query:
select to_date(to_char(sysdate,'dd/mm/yyyy'),'dd/mm/yyyy') from dual
But it gives
1/8/2011 12:00:00 AM.
I want it to insert and show as
08/01/2011 12:00:00 AM.
Can anyone help me in this please ?
DATE is a built-in type in Oracle, which is represented in a fixed way and you have no control over it.
So:
I want it to insert [...] as 08/01/2011 12:00:00 AM
The above is nonsensical. You don't insert a string, you insert a date.
Format is useful only when you want:
to convert a string to an internal representation of date with TO_DATE (format mask: how to parse the string);
to convert an internal representation of date to a string with TO_CHAR (format mask: how to render the date).
So basically, in your example you take a DATE, you convert it to a STRING with some format, and convert it back to DATE with the same format. This is a no-op.
Now, what your client displays: this is because your Oracle Client won't display DATE fields directly and the NLS layer will convert any DATE field that is selected. So it depends on your locale by default.
What you want is SELECT TO_CHAR(SYSDATE,'DD/MM/YYYY') FROM dual; which will explicitly perform the conversion and return a string.
And when you want to insert a date in a database, you can use TO_DATE or date literals.
Alternatively, if you want to retrieve the date part of the DATE field, you may use truncate, i.e.
select to_char(trunc(sysdate),'dd/mm/yyyy') from dual;
When the column is of type DATE, you can use something like:
Insert into your_table(your_date_column) Select TRUNC(SYSDATE) from DUAL;
This removes the time part from SYSDATE.
Maybe this can help
insert into pasok values ('&kode_pasok','&kode_barang','&kode_suplier',
to_date('&tanggal_pasok','dd-mm-yyyy'),&jumlah_pasok);
note: '&' help we to insert data again, insert / end than enter to
insert again example: Enter value for kode_pembelian: BEL-E005 Enter
value for kode_barang: ELK-02 Enter value for kode_customer: B-0001
old 2: '&kode_pembelian','&kode_barang','&kode_customer', new 2:
'BEL-E005','ELK-02','B-0001', Enter value for tanggal_pembelian:
24-06-2002 Enter value for jumlah_pembelian: 2 old 3:
to_date('&tanggal_pembelian','dd-mm-yyyy'),&jumlah_pembelian) new 3:
to_date('24-06-2002','dd-mm-yyyy'),2)
1 row created.
SQL> / (enter)

Resources