Strange query behavior oracle 11g - performance

I have a query as:
SELECT ps_node_id,name
FROM cz_ps_nodes WHERE cz_ps_nodes.ps_node_type=261
START WITH NAME = 'Bundle Rule Repository',cz_ps_nodes.devl_project_id = P_devl_project_id AND cz_ps_nodes.deleted_flag = 0
CONNECT BY PRIOR ps_node_id = parent_id.
This query works.
But if I just remove the name from the select part like:
SELECT ps_node_id
FROM cz_ps_nodes WHERE cz_ps_nodes.ps_node_type = 261
START WITH NAME = 'Bundle Rule Repository',cz_ps_nodes.devl_project_id = P_devl_project_id AND cz_ps_nodes.deleted_flag = 0
CONNECT BY PRIOR ps_node_id = parent_id.
The query just hangs but was working on oracle 10 g and the problem started when we upgraded to oracle 11g.
Could anyone explain why?

Got the issue solved by using : alter session set optimizer_features_enable='10.2.0.4' –

Related

Very slow connection to Snowflake from Databricks

I am trying to connect to Snowflake using R in databricks, my connection works and I can make queries and retrieve data successfully, however my problem is that it can take more than 25 minutes to simply connect, but once connected all my queries are quick thereafter.
I am using the sparklyr function 'spark_read_source', which looks like this:
query<- spark_read_source(
sc = sc,
name = "query_tbl",
memory = FALSE,
overwrite = TRUE,
source = "snowflake",
options = append(sf_options, client_Q)
)
where 'sf_options' are a list of connection parameters which look similar to this;
sf_options <- list(
sfUrl = "https://<my_account>.snowflakecomputing.com",
sfUser = "<my_user>",
sfPassword = "<my_pass>",
sfDatabase = "<my_database>",
sfSchema = "<my_schema>",
sfWarehouse = "<my_warehouse>",
sfRole = "<my_role>"
)
and my query is a string appended to the 'options' arguement e.g.
client_Q <- 'SELECT * FROM <my_database>.<my_schema>.<my_table>'
I can't understand why it is taking so long, if I run the same query from RStudio using a local spark instance and 'dbGetQuery', it is instant.
Is spark_read_source the problem? Is it an issue between Snowflake and Databricks? Or something else? Any help would be great. Thanks.

How to access a single field of the logstash metadata event?

I am using logastash 7.6 with the output-jdbc plugin, but I get an error and I understand that it is because in the event it sends me all the fields to be indexed that are part of #metadata.
Probe just putting the event name without # and it works for me.
How can I get a single field within a #metada set?
ERROR:
ERROR logstash.outputs.jdbc - JDBC - Exception. Not retrying {:exception=>#, :statement=>"UPDATE table SET estate = 'P' WHERE codigo = ? ", :event=>"{\"properties\":{\"rangoAltura1\":null,\"rangoAltura2\":null,\"codigo\":\"DB_001\",\"rangoAltura3\":null,\"descrip\":\"CARLOS PEREZ\",\"codigo\":\"106\",\"rangoAltura5\":null,\"active\":true},\"id\":\"DB_001_555\"}"}
My .conf:
statement => ["UPDATE table SET estate = 'A' WHERE entidad = ? ","%{[#metadata][miEntidad]}"]
{[#metadata][miEntidad]} -----> map['entidad_temp'] = event.get('entidad')
According to the output jdbc plugin README you have it set correctly/
Maybe try the following as a work-around:
statement => ["UPDATE table SET estate = 'A' WHERE entidad = ? ","[#metadata][miEntidad]"]

What's wrong with this UPDATE SQL JOIN syntax? [duplicate]

This question already has answers here:
Oracle SQL: Update a table with data from another table
(7 answers)
Oracle SQL update based on subquery between two tables
(4 answers)
Closed 3 years ago.
Trying to update a column in a table based on the value in another table as part of a data migration. All the columns exist in both tables in the join, but am receiving an unexpected error message when I run the following:
UPDATE CSB
SET IFS10_SCHEDULE = CS.SCHEDULE_NO
FROM IC_U_CUSTOMER_SCHED_B CSB
JOIN CUST_SCHED CS
ON CSB.CUSTOMER_NO = CS.CUSTOMER_NO
AND CS.SHIP_ADDR_NO = CSB.SHIP_ADDR_NO
AND CSB.CUSTOMER_PART_NO = CS.CUSTOMER_PART_NO
AND CSB.DOC_NO = CS.DOC_NO
AND CSB.AGREEMENT_ID = CS.AGREEMENT_ID
AND CSB.CUST_SCHEDULE_TYPE = CS.CUST_SCHEDULE_TYPE;
I receive the error:
Error at Command Line : 3 Column : 1
Error report -
SQL Error: ORA-00933: SQL command not properly ended
00933. 00000 - "SQL command not properly ended"
*Cause:
*Action:
I'm sure it's got to be a syntax issue, but can't see where. Any ideas?
EDIT - thanks, solution obtained. For learning purposes (I've done T-SQL for the last 20 years and only just learning PL-SQL), I also re-wrote the query as a MERGE INTO - but this also failed. Any obvious issues here?:
MERGE INTO IC_U_CUSTOMER_SCHED_B CSB
USING CUST_SCHED CS
ON (CSB.CUSTOMER_NO = CS.CUSTOMER_NO
AND CS.SHIP_ADDR_NO = CSB.SHIP_ADDR_NO
AND CSB.CUSTOMER_PART_NO = CS.CUSTOMER_PART_NO
AND CSB.DOC_NO = CS.DOC_NO
AND CSB.AGREEMENT_ID = CS.AGREEMENT_ID
AND CSB.CUST_SCHEDULE_TYPE = CS.CUST_SCHEDULE_TYPE)
WHEN MATCHED THEN UPDATE SET CSB.IFS10_SCHEDULE = CS.SCHEDULE_NO
WHERE CSB.IFS10_SCHEDULE != CS.SCHEDULE_NO;
Should be
UPDATE ic_u_customer_sched_b csb
SET csb.ifs10_schedule =
(SELECT cs.schedule_no
FROM cust_sched cs
WHERE csb.customer_no = cs.customer_no
AND cs.ship_addr_no = csb.ship_addr_no
AND csb.customer_part_no = cs.customer_part_no
AND csb.doc_no = cs.doc_no
AND csb.agreement_id = cs.agreement_id
AND csb.cust_schedule_type = cs.cust_schedule_type);

VBScript to `drop` and `create` new table in microsoft access

I have VBScript to drop and create new table in microsoft access.
My vb script is :
Set dbeng = CreateObject("DAO.DBEngine.120")
strMdbFile = "amw\db_amw.accdb"
Set db = dbeng.OpenDatabase(strMdbFile)
strSql1 = "DROP TABLE amw"
StrSql2 = "SELECT * INTO amw FROM MPN_V WHERE (((Format([tgl_bayar],'yyyy')) Between Format(Now(),'yyyy')-2 And Format(Now(),'yyyy')))"
strSql3 = "DROP TABLE UPDATE"
strSql4 = "SELECT * INTO update FROM UPDATE6 WHERE id="1""
db.Execute(strSql1)
db.Execute(strSql2)
db.Execute(strSql3)
db.Execute(strSql4)
when the script runs the line db.Execute(strSql1) and db.Execute(strSql2), no error Happen. but, when the script runs the line db.Execute(strSql3) and db.Execute(strSql4), error Happen : Expected end of statement, code 800A0401, source Microsoft VBScript compilation error. Please correct my Script? thank you verymuch
The problem is with the number of quotes on the last SQL statement.
strSql4 = "SELECT * INTO [update] FROM UPDATE6 WHERE id="1""
If "id" is an integer, use the following:
strSql4 = "SELECT * INTO [update] FROM UPDATE6 WHERE id=1"
If "id" is a string, use the following:
strSql4 = "SELECT * INTO [update] FROM UPDATE6 WHERE id=""1"""
Doubling the quotes are necessary when working with a string within a string.

code running in oracle 11g

I am having 3 tables case_details, codehead and case_staus. I am trying to fetch the values from database. Code mentioned below is running well in oracle 10 xe, but in oracle 11g 32 bit it is showing 0 rows...the code is
select a.case_id
,a.case_description
,a.case_contract_value
,b.sub_codehead
,c.case_status_name
from case_details a
,codehead b
,case_status c
where a.case_codehead = b.code_id
and a.case_status = c.case_status_id
and joint_directorate = 85
and case_status < 2
order by case_id;
I am unable to understand that well running code is not executing in oracle 11g...please help me out..

Resources