Oracle V$Session.SQL_ID is not populating - oracle

My organization recently upgraded form Oracle 10g to 11g. I had the following query that was working, but it no longer works because the V_$SESSION.SQL_ID field is not populated to link to.
SELECT SESS.OSUSER
,SESS.MACHINE
INTO v_USERID
,v_USERNAME
FROM SYS.V_$SQLAREA SEQL
JOIN SYS.V_$SESSION SESS ON SEQL.SQL_ID = SESS.SQL_ID
WHERE SEQL.SQL_TEXT LIKE 'DELETE%'
AND SEQL.SQL_TEXT LIKE '%ACCTLOG%';
Is there a work around I could use to obtain the same information?
Thanks all

Related

Can't get Oracle SQL Developer to display specific values from object table

I've started learning SQL and playing with Oracle SQL Developer v22. For some reason I'm not able to retrieve value from an object table by using SELECT VALUE(A). It only gives my user ID.object_name as in the below screenshot. Any tips why?
SELECT VALUE(A) FROM table A;
If I use SELECT * FROM table; all is fine.
SELECT * FROM table A;
I've tried printing using dmbs_output, same problem.
Tried with other object tables, same behaviour.
Please share your table DDL and DML for a more accurate answer, but setting this preference should do what you're looking for
'Display Struct Value in Grid'
I talk about that here
Disclaimer: I work for Oracle and am the product manager for SQL Developer.

delphi: ROW-00025: Invalid RowSetHandle when executing a query on an oracle db

I've created a small 64-Bit application and I want to execute a simple query
select field1, field2 from table where field1 = 'xyz' order by 1
on an oracle db.
I am using:
Windows 10
Oracle Database 11g Client (x64)
Delphi 10.1.2 Berlin
TADOQuery with the connection string:
Provider=OraOLEDB.Oracle;Password=XYZ;User ID=XYZ;DataSource=XYZ;Persist Security Info=True
When executing the query I get the error:
ROW-00025: Invalid RowSetHandle
I have never seen any error like this before.
Do you have any ideas? If you need more information, let me know in the comments below.
Thanks for your suggestions and comments. Meanwhile we found a solution...
We need to set the CursorLocation from the ADOQuery from clUseServer to clUseClient. With this change our query works. I guess our oracle server has some issues.
can you try in this way,
select field1, field2 from table where field1 = 'xyz' and rownum=1;

Query working in native Oracle sql but not through odbc. Alias from subquery is an invalid identifier

A collegue needs to work with this data in Excel. I wrote the query below. It runs fine when I run it from sql developer. But when I want to use it in Microsoft Query which apparently uses ODBC to connect to the Oracle database, I get an error that says that the identifier "due" is invalid.
But how can I name the sum from the subquery in the select part of the sql?
SELECT cl.clid, cl.cl_name, s.due, con.oid, con.contract_status
FROM clientinfo cl
LEFT OUTER JOIN
(SELECT clid, sum(dueamount) as due
from account GROUP BY clid) s
ON s.clid = cl.clid
LEFT OUTER JOIN contract con
ON con.clid = cl.clid
ORDER BY cl.clid
I translated the names into english so that the query makes a bit more sense to you. I want to show the client id and their names along with the due amount and an object number with the status of the contract.
Create a view in the Oracle DB and let your colleague query that view through ODBC.

Strange results with in Oracle Apex using Pivot showing nulls and n

Im running a oracle 11g with Apex 4.2.6. Im trying to run a script but giving back nulls in apex but showing correct results in SQL developer
select "ENG_ID","ENG_ID1","roles","Region","1","2","3","4","5","6","7","8","9","10","11","12","13","14","15" ,"16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31" from (
select M.ENG_ID as ENG_ID,
M.ENG_ID as ENG_ID1,
e.ROLE_ID as "roles",
e.REGION_AREA_ID as "Region",
EXTRACT(DAY FROM M.MS_DATE) as DOM,
MD.MD_ID
--MD.JOB_TYPE_ID
from MD_TS_DETAIL MD,
MD_TS_MAST M,MAN_ENGINEERS e
where
m.eng_id = 542 and
M.ENG_ID = e.ENG_ID and
M.MAST_ID=MD.MD_ID and
M.MS_DATE between trunc(sysdate,'MM') and last_day(sysdate)
)pivot (
max(MD_ID)
for DOM in (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31)
)
which gives me the correct result of
SQL Dev view
Yet running the same script within Apex you get nulls.
apex view.
I'm completely stumped do you guys have any ideas
Ok after checking what the max records where both records where both on APEX and the database directly.
. In SQL workshop > selected MD_TS_MAST > statistics > analyse > estimate statistics change to 100% > next >finish.
all records came back. Why apex did not run from the database directly I don't know. So basicily if doing inserts in SQL developer, You must do a update via analyse.

Where is all_nested_table_cols in 9i?

Oracle 9i has nested tables, however it doesn't have the all_nested_table_cols sysview (like 10g and 11g) which lets me see what the columns are for these nested tables. How can I find this information on a 9i database?
I don't have a 9i instance to test with, but maybe this can get you started:
SELECT nt.owner, nt.table_name, nt.parent_table_name, nt.parent_table_column, ct.owner, ct.type_name, ta.*
FROM all_nested_tables nt, all_coll_types ct, all_type_attrs ta
WHERE ct.type_name = nt.table_type_name
AND ta.type_name = ct.elem_type_name
The attr_name column should be something like the column_name column in all_nested_table_cols. I know it's not the real thing... but it's a start.
Making this CW in case anyone wants to improve it.

Resources