No more data to read from socket - for long query with multiple IN clause - oracle19c

I have a very long query
select commonreso0_.ID_PK as col_0_0_, commonreso0_.DISPLAY_PATH as col_1_0_, commonreso0_.OBJECT_TYPE as col_2_0_, commonreso0_.SD_NAME as col_3_0_
from nms_perf_linux.state_common_resource commonreso0_ where commonreso0_.SD_NAME in
(e1 ,'e2', e3, .....e990) or commonreso0_.SD_NAME in (e1,e2,....e900) or commonreso0_.SD_NAME in (e1,e2,....e900).....10x.....or commonreso0_.SD_NAME in (e1,e2,....e900)
When I run this query from SQL developer, I am getting "No more data to read from socket"
I am using oracle19c, with ojdbc11.
On tnsNames.ora I have: SERVER = SHARED
Also, I tried with oprim_peek_user_binds as TRUE and also as FALSE.
If I am running this query on oracle12c, everything is working fine

Related

PowerBI Query contains transformations that can't be used for DirectQuery

I am using PowerBI Desktop (2.96.1061.0) to connect to a local MS SQL server so I can prepare some visualizations. It is important to mention that all data connections (Tables, SQL queries) are using the DirectQuery option.
It's been quite a smooth experience so far. No issues at all. Now I am trying to get some new data, again, through a direct SQL query:
SELECT BillId, string_agg(PGroupName, ', ')
FROM
(SELECT bm.ImportedBillsId as BillId, pg.Name as PGroupName
FROM [BillMp] bm
JOIN [Mps] m on bm.ImportersId = m.Id
JOIN [PGroups] pg on m.PoliticalGroupId = pg.Id
GROUP BY bm.ImportedBillsId, pg.Name) t
GROUP BY BillId
but for some reason, it is not letting me re-create the model and apply the new changes. No matter that the import wizard is able to visualize the actual data prior to the update. This is the error that I am getting:
I have also tried to import only the data from the internal/nested query
SELECT bm.ImportedBillsId as BillId, pg.Name as PGroupName
FROM [BillMp] bm
JOIN [Mps] m on bm.ImportersId = m.Id
JOIN [PGroups] pg on m.PoliticalGroupId = pg.Id
GROUP BY bm.ImportedBillsId, pg.Name
and process (according to this article) the other/outer query through PowerBI but I am still getting the same error.

Regex not working in APEX, working on RegexPlanet

I am trying to create a validation for a field where the user should enter an Oracle JDBC Thin connection URL, like:
jdbc:oracle:thin:#//192.168.2.1:1521/XE
jdbc:oracle:thin:192.168.2.1:1521:X01A
jdbc:oracle:thin:#//192.168.2.1:1521/COM.EXAMPLE
I tried testing the regex with RegexPlanet and it says it's working (the regex I am using):
^jdbc:oracle:thin:[#//]*[.\w]+:\d+[:]*[/]*[a-zA-Z0-9.]*$
But when I try to validate the form using this regex it shows the error message, even when I am using the exact same URL's as the one's above. Other validations are working just fine.
A JDBC Thin Driver Connection string can take one of these formats:
jdbc:oracle:thin:#[HOST][:PORT]:SID
jdbc:oracle:thin:#//[HOST][:PORT]/SERVICE
jdbc:oracle:thin:[USER/PASSWORD]#[HOST][:PORT]:SID
jdbc:oracle:thin:[USER/PASSWORD]#//[HOST][:PORT]/SERVICE
Where HOST can be an IP Address or a name.
If you ignore the username/password then a regular expression to match is something like:
^jdbc:oracle:thin:#(//)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\w+):\d+[:/][a-zA-Z0-9.]+$
(although it's not perfect - but a perfect regular expression to match this would be huge)
Query:
WITH connections ( conn ) AS (
SELECT 'jdbc:oracle:thin:#//192.168.2.1:1521/XE' FROM DUAL UNION ALL
SELECT 'jdbc:oracle:thin:#192.168.2.1:1521:X01A' FROM DUAL UNION ALL
SELECT 'jdbc:oracle:thin:#//192.168.2.1:1521/COM.EXAMPLE' FROM DUAL
)
SELECT *
FROM connections
WHERE REGEXP_LIKE( conn, '^jdbc:oracle:thin:#(//)?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\w+):\d+[:/][a-zA-Z0-9.]+$' );
Results:
CONN
------------------------------------------------
jdbc:oracle:thin:#//192.168.2.1:1521/XE
jdbc:oracle:thin:#192.168.2.1:1521:X01A
jdbc:oracle:thin:#//192.168.2.1:1521/COM.EXAMPLE

SQL Error ORA-01002 not autocommit and loop

I'm using pro c/c++ in a unix environment. Inside a c function I create a simple select statement which is not inside a loop and autocommit is disabled.
This is the dynamic sql;
char sql_statement[200];
int num1, num2;
...
snprintf(sql_statement, sizeof(sql_sattement), "select column1, column2 from '%s' where num = '%d' and code_cfg = '%d'", "customer", 0, 0);
exec sql prepare instruction_to_execute from :sql_statement;
exec sql declare crs cursor for instruction_to_execute;
exec sql open crs;
exec sql fetch crs into :num1, :num2;
...
Executing this code gives me ORA-01002 error. As I said before, this code is not inside a loop and autocommit is off.
But if I write this code statically, works fine. Below the code:
EXEC SQL
SELECT column1, column2
INTO :num1, :num2
FROM CUSTOMER
where num = 0
AND code_cfg = 0;
SQL instruction is simple. For my understanding this code should be executed fine.
In SO I found some answers:
ORA-01002: fetch out of sequence C++
ORA-01002: fetch out of sequence
Hibernate error “ORA-01002” when persisting entity with custom Sequence Generator
ORA-01002: fetch out of sequence
java.sql.SQLException: ORA-01002: fetch out of sequence

App connection with Sqlite in my app developed in qt

In my app in QT5 I have this code
QString sql = "Select * from table";
QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
db.setDatabaseName("./au.sqlite");
db.open();
QSqlQuery query(sql);
query.exec();
But when I get the results only get one result, the select query only give me one result and I don't know how fix this. If I add query.next() in a while loop I only get one iteration.
There is a bool function that returns true if the query succeeded. Looking back to the docs:
Successfully executed SQL statements set the query's state to active so that isActive() returns true. Otherwise the query's state is set to inactive.
This is the way you can check the result. If it's false, then You should try to rewrite your sql query text so that functional sql words (such as SELECT, FROM and etc.) are in the upper case (the way it's shown in the docs) and try to execute the query once again.
Here's an example from the docs again:
QSqlQuery query("SELECT country FROM artist");
while (query.next()) {
QString country = query.value(0).toString();
doSomething(country);
}
You might check sqlbrowser example that is included with Qt5 distribution. Run your query there on your db.

Update a table by using multiple joins

I am using Java DB (Java DB is Oracle's supported version of Apache Derby and contains the same binaries as Apache Derby. source: http://www.oracle.com/technetwork/java/javadb/overview/faqs-jsp-156714.html#1q2).
I am trying to update a column in one table, however I need to join that table with 2 other tables within the same database to get accurate results (not my design, nor my choice).
Below are my three tables, ADSID is a key linking Vehicles and Customers and ADDRESS and ZIP in Salesresp are used to link it to Customers. (Other fields left out for the sake of brevity.)
Salesresp(address, zip, prevsale)
Customers(adsid, address, zipcode)
Vehicles(adsid, selldate)
The goal is to find customers in the SalesResp table that have previously purchased a vehicle before the given date. They are identified by address and adsid in Customers and Vechiles respectively.
I have seen updates to a column with a single join and in fact asked a question about one of my own update/joins here (UPDATE with INNER JOIN). But now I need to take it that one step further and use both tables to get all the information.
I can get a multi-JOIN SELECT statement to work:
SELECT * FROM salesresp
INNER JOIN customers ON (SALESRESP.ZIP = customers.ZIPCODE) AND
(SALESRESP.ADDRESS = customers.ADDRESS)
INNER JOIN vehicles ON (Vehicles.ADSId =Customers.ADSId )
WHERE (VEHICLES.SELLDATE<'2013-09-24');
However I cannot get a multi-JOIN UPDATE statement to work.
I have attempted to try the update like this:
UPDATE salesresp SET PREVSALE = (SELECT SALESRESP.address FROM SALESRESP
WHERE SALESRESP.address IN (SELECT customers.address FROM customers
WHERE customers.adsid IN (SELECT vehicles.adsid FROM vehicles
WHERE vehicles.SELLDATE < '2013-09-24')));
And I am given this error: "Error code 30000, SQL state 21000: Scalar subquery is only allowed to return a single row".
But if I change that first "=" to a "IN" it gives me a syntax error for having encountered "IN" (Error code 30000, SQL state 42X01).
I also attempted to do more blatant inner joins, but upon attempting to execute this code I got the the same error as above: "Error code 30000, SQL state 42X01" with it complaining about my use of the "FROM" keyword.
update salesresp set prevsale = vehicles.selldate
from salesresp sr
inner join vehicles v
on sr.prevsale = v.selldate
inner join customers c
on v.adsid = c.adsid
where v.selldate < '2013-09-24';
And in a different configuration:
update salesresp
inner join customer on salesresp.address = customer.address
inner join vehicles on customer.adsid = vehicles.ADSID
set salesresp.SELLDATE = vehicles.selldate where vehicles.selldate < '2013-09-24';
Where it finds the "INNER" distasteful: Error code 30000, SQL state 42X01: Syntax error: Encountered "inner" at line 3, column 1.
What do I need to do to get this multi-join update query to work? Or is it simply not possible with this database?
Any advice is appreciated.
If I were you I would:
1) Turn off autocommit (if you haven't already)
2) Craft a select/join which returns a set of columns that identifies the record you want to update E.g. select c1, c2, ... from A join B join C... WHERE ...
3) Issue the update. E.g. update salesrep SET CX = cx where C1 = c1 AND C2 = c2 AND...
(Having an index on C1, C2, ... will boost performance)
4) Commit.
That way you don't have worry about mixing the update and the join, and doing it within a txn ensures that nothing can change the result of the join before your update goes through.