Select ordering works differently on windows and in container - spring

I'm facing problem with ordering database records. I'm using jOOQ and DSLContext in SpringBoot application to select data from configured Oracle database. Everything works fine locally on my Windows device. After deploying application to Openshift container platform, the same select orders records differently. Database contains text values in Slovak language with accents and special characters as you can see in result tables.
Select:
var companies = DSLContext.select().from(Company.COMPANY)
.orderBy(Company.NAME)
.fetch()
.stream()
.map(this::mapCompany)
.collect(Collectors.toList());
Result on Windows: (good result)
ID
NAME
1
Aaaa
2
Áááá
3
Bbbb
4
"Bcbb"
5
"Ccccc"
Result on deployed app: (wrong result)
ID
NAME
1
"Bcbb"
2
"Ccccc"
3
Aaaa
4
Áááá
5
Bbbb
I think that problem is caused by different locale or encoding on windows and container(unix). The application is deploying using dockerfile. Can anyone provide some solution, how to achieve the same behavior in container as in Windows?

The jOOQ API supports collations, which is the SQL way of specifying the sort order for different character sets and locales. You could write:
var companies = DSLContext.select().from(Company.COMPANY)
.orderBy(Company.NAME.collate(myCollation))
.fetch(this::mapCompany)
But this is only really a good idea if you're not in control of your database collations. Otherwise, better specify them with your table definitions, or when you set up your database. Please refer to your database manual for details on how to deal with collations.

Related

SSIS Google Analytics - Reporting dimensions & metrics are incompatible

I'm trying to extract data from Google Analytics, using KingswaySoft - SSIS Integration Toolkit, in Visual Studio.
I've set the metrics and dimensions, but I get this error message:
Please remove transactions to make the request compatible. The request's dimensions & metrics are incompatible. To learn more, see https://ga-dev-tools.web.app/ga4/dimensions-metrics-explorer/
I've tried to remove transactions metric and it works, but this metric is really necessary.
Metrics: sessionConversionRate, sessions, totalUsers, transactions
Dimensions: campaignName, country, dateHour, deviceCategory, sourceMedium
Any idea on how to solve it?
I'm not sure how helpful this suggestion is but could a possible work around include having two queries.
Query 1: Existing query without transactions
Query 2: The same dimensions with transactionId included
The idea would be to use the SSIS Aggregate component to group by the original dimensions and count the transactions. You could then merge the queries together via a merge join.
Would that work?
The API supports what it supports. So if you've attempted to pair things that are incompatible, you won't get any data back. Things that seem like they should totally work go together like orange juice and milk.
While I worked on the GA stuff through Python, an approach we found helped us work through incompatible metrics and total metrics was to make multiple pulls using the same dimensions. As the data sets are at the same level of grain, as long as you match up each dimension in the set, you can have all the metrics you want.
In your case, I'd have 2 data flows, followed by an Execute SQL Task that brings the data together for the final table
DFT1: Query1 -> Derived Column -> Stage.Table1
DFT2: Query2 -> Derived Column -> Stage.Table2
Execute SQL Task
SELECT
T1.*, T2.Metric_A, T2.Metric_B, ... T2.Metric_Z
INTO
#T
FROM
Stage.T1 AS T1
INNER JOIN
Stage.T2 AS T2
ON T2.Dim1 = T1.Dim1 /* etc */ AND T2.Dim7 = T1.Dim7
-- Update you have solid data aka
-- isDataGolden exists in the "data" section of the response
-- Usually within 7? days but possibly sooner
UPDATE
X
SET
metric1 = S.metric1 /* etc */
FROM
dbo.X AS X
INNER JOIN #T AS T
ON T.Dim1 = X.Dim1
WHERE
X.isDataGolden IS NULL
AND T.isDataGolden IS NOT NULL;
-- Add new data but be aware that not all nodes might have
-- reported in.
INSERT INTO
dbo.X
SELECT
*
FROM
#T AS T
WHERE
NOT EXISTS (SELECT * FROM dbo.X AS X WHERE X.Dim1 = T.Dim1 /* etc */);

auto increment of data(int type) which is not Id(identity already used) ASP.NET MVC

I am trying to auto increment data, which is not Id, I have used Sql Identity on Id so can't use it anymore. I tried sql sequence to bind data column and it works if I add information from sql via script but it does not work on adding from visual studio. I tried to [DatabaseGenerated(DatabaseGeneratedOption.Computed)] but it does not work too. I have been searching this topic for 2 days in web but can't find any solution
You can use SQL Sequences for this. According to the documentation by Microsoft
A sequence is a user-defined schema bound object that generates a sequence of numeric values according to the specification with which the sequence was created. The sequence of numeric values is generated in an ascending or descending order at a defined interval and can be configured to restart (cycle) when exhausted. Sequences, unlike identity columns, are not associated with specific tables. Applications refer to a sequence object to retrieve its next value. The relationship between sequences and tables is controlled by the application. User applications can reference a sequence object and coordinate the values across multiple rows and tables.
You can create a sequence using the syntax below:
CREATE SEQUENCE OrderNumber
START WITH 1
INCREMENT BY 1 ;
GO
To check how it can be used in MVC, please check this post.
Hope this helps!

FbId bigint with Model and Eloquent

I have created project with facebook authentication , so the user id in the project is fbid and the length is 17
this mean data type bigint.
First I'm using OS Ubuntu , my team using Win 10
and we use https://github.com/barryvdh/laravel-debugbar for debugging
in Ubuntu every thing Ok, But Windows not working properly
when I use the Eloqunt to get the data I facing 3 issues
some time fbid revert as int Max "2147483647"
when I use join or hasMay the query execute properly but can't merge it ( i see in debugger 2 queries for user and posts)
for fbid 10153262671266093 it is convert to 10153262671266092
after time of searching i got idea to cast the fbid as string and it is work now i want to share it and discuss about this issue

SSIS - Join tables from different servers whose names are based on a variable

I have a simple query based on tables from two different linked servers. I need both servers to be changeable since we're moving from DEV to UAT to Production. I'm using an expression to set the Connection String and Password for server A. So, using that as a base I set a Data Flow Task and an 'OLE DB Source' to extract the data I need. Ultimately I'd like my query to look like this:
Select * from A.Payments p1
Full Outer Join ?.Payments p2 on p1.Id = p2.Id
where p1.OrderDesc is null or p2.OrderDesc is null
Is there a way around it? Can I use a variable or some kind of dynamic query? I haven't managed to parse a project parameter and run one. Thank you very much for your help.
This is done by making the Data Source SQL an expression.
Right click the Data Flow and then click the ellipsis [...] beside "Expressions". In there you will find one of the available properties you can set is the SQLCommand for your Data Flow Source.
It's not the most intuitive thing to be fair.

Enterprise Architect Oracle long field column properties

I have a little problem with Enterprise Architect by Sparx System.
Im trying to model database schema for Oracle. I created table with primary key with data type long. But when im trying to modify column properties (set AutoNum = true) I see empty properties. I read documentation of EA and saw that I need to setup this property to generate sequence syntax.
When I change data type to number, or switch database to mysql (for example) everything is alright, there are properties so Im able to modify AutoNum value.
Did you had similar problem and found solution ? or maybe im doing something wrong.
regards
It's becouse Oracle use sequence instead of autoincrement option. I've checked it and I think you have to use NUMBER column type and then set AutoNum property (you have to select Generate Sequences in options to get proper DDL code too). Instead of LONG data type you can set PRECISION and SCALE options on NUMBER type ie NUMBER(8) mean you can have 8 digits number and it can be set up to 38, so if you don't want to store info about every star in the universe will be enought for your scenario :)

Resources