JPA not able to return get query data - spring-data-jpa

We are trying to get data from database postgress via JPA, but code is not returning any data. But when I run same query manually on database we are getting data. We are making query on double precision column with value of 0.33 .
Eg ->
select * from table1 where code='0.33'
when ran directly on postgres gives us data, but through code it returns 0 rows.

Related

nextval on sequence returns all nextval values for all table rows in typeORM on postgresql table

I have a sequence in postgreSQL database, and when I run NEXTVAL(sequence_name) query inside pgAdmin 4 it returns only one value that is correct.
However inside NestJS project that's bootstrapped with TypeORM when I run this.repo.createQueryBuilder().select("NEXTVAL(sequence_name)").execute()
It returns array of objects with all next values generated.
Example: If I have 500 rows inside the table, it will return 500 NEXTVAL values for some reason.
I've tried my best to find a solution online, but no luck.
Any ideas?
The solution was fairly simple, thanks #nbk for the comment.
This was a solution:
this.repo
.createQueryBuilder()
.where('id = (select MAX(id) FROM table_name)')
.select("nextval('sequence_name")
.getRawOne();

How to Fix Postgres Numeric Auto Become 6 Decimal Places When Using Insert Into OPENQUERY from SQL Server

I found an issue of Postgres decimal places auto become 6 places when try to insert data from SQL Server into Postgres using OPENQUERY.
I have searched many references that suggested using CAST or Convert to limit decimal places from SQL Server, everything is work fine when I just tried select from the SQL Server side (It is 0.001), but whenever run the query like below, in Postgres (for example the 'Rounding' will become 0.001000).
For example:
INSERT INTO OPENQUERY(RND,
'SELECT
name,
rounding
FROM test.public.product_uom')
SELECT
UoMID,
0.001
FROM dbo.tUoM
WHERE UoMID IN ('YEAR', 'ZAK');
The expected result that I would like is to have the same value of Rounding when Insert into from SQL Server to Postgres that is 0.001. Any help or suggestions will be appreciated and thanks in advance.

SAS SQL Pass Through

I would like to know what gets executed first in the SAS SQL pass thru in this code:
Connect To OLEDB As MYDB ( %DBConnect( Catalog = MYDB ) ) ;
Create table MYDB_extract as
select put(Parent,$ABC.) as PARENT,
put(PFX,z2.) as PFX,*
From Connection To MYDB
( SELECT
Appointment,Parents,Children,Cats,Dogs
FROM MYDB.dbo.FlatRecord
WHERE Appointment between '20150801' and '20150831'
And Children > 2);
Disconnect from MYDB;
Since MS SQL-Server doesn't support the PUT function will this query cause ALL of the records to be processed locally or only the resultant records from the DBMS?
The explicit pass-through query will still process and will return to SAS what it returns (however many records that is). Then, SAS will perform the put operations on the returned rows.
So if 10000 rows are in the table, and 500 rows meet the criteria in where, 500 records will go to SAS and then be put; SQL will handle the 10000 -> 500.
If you had written this in implicit pass through, then it's possible (if not probable) that SAS might have done all of the work.
First the code in the inline view will be executed on the server:
SELECT Appointment,Parents,Children,Cats,Dogs
FROM MYDB.dbo.FlatRecord
WHERE Appointment between '20150801' and '20150831' And Children > 2
Rows that meet that WHERE clause will be returned by the DBMS to SAS over the OLDEB connection.
Then SAS will (try and) select from that result set, applying any other code, including the put functions.
This isn't really any different from how an inline view works in any other DBMS, except that here you have two different database engines, one running the inner query and SAS running the outer query.

Select * from filled table returns unexpected result in InfluxDB

I have a setup with an InfluxDB instance that regularly gets values inserted into. When I run the following query in the InfluxDB Administration Interface, it returns 30000:
select count(values) from my_table
When I run this query, though, it says, that there are no results:
select * from my_table
I can remember, though, that this query used to work, when there were less values in there. Is this a known and normal behavior or am I missing something?

Query for PostgreSQL Server status variable?

In my project i want to collect PostgreSQL server's performance counter. For that i want query to collect it from the database. i am new to postgreSQL. when i am searching, i got something like,
SELECT * FROM pg_stat_database
but when i am use this in java in the following manner, Here Map_PostgreSQL is a hashmap.
while(rs.next())
{
Counter_Name.add(rs.getString(1).trim());
Map_PostgreSQL.put(rs.getString(1).trim(), rs.getString(2));
}
I got output like
{12024=template0, 1=template1, 12029=postgres}
What is the actual query to collect its status variables like "SHOW GLOBAL STATUS" in MySQL.
Thanks in advance..
1st, try to launch the sql query in your PostgreSQL Shell to see exactly which data are returned and how it is organised in rows and columns.
You'll see that the hashmap keys are your datid (database ids) and the values are your databases names.
I think you assumed that statistics were structured in "rows" whereas they are structured in columns.
Don't forget : PostgreSQL is a database server which means it can handle several databases (and in fact, it has several databases because some of them are already created such as the 'postgres' database itself - which Postgres (the server) uses internally, or 'template0').
By launching :
SELECT * FROM pg_stat_database;
You're asking the server to return statistics for every databases (provided you're allowed to get them)
If you want to only have stats for your own database, do :
SELECT * FROM pg_stat_database WHERE datname='your_database_name';
Hope this helped