Actual Column Name for Index when Function is used?
Hi,
We have some indeces where the column in oracle is actually a function in the form UPPER('column-name'). When I query user_ind_columns I get something like SYS_NC0012$ for the column name. Where would I be able to actually query the actual column it's using in the index? So that I can query the exact column name if need be. Don't ask why cause this is a developer asking me this and they are doing some sort of a comparison between indexes between two application.
Here is the SQL for the Index and the Table associated with it
create table BATCH_HEADER2
PAYMENT_TYPE VARCHAR2(17),
BATCH_TYPE VARCHAR2(40) not null,
BATCHNUM NUMBER not null,
BRANCH VARCHAR2(16),
BATCH_TIME NUMBER,
USER_LOB VARCHAR2(16),
PAYEE_TYPE VARCHAR2(40),
PROGRESS_RECID NUMBER,
CHEQUE_TYPE VARCHAR2(60),
SCANNERBATCHNO NUMBER,
RECEIPTCOUNT NUMBER
alter table BATCH_HEADER2
add constraint PK_BATCH_HEADER2 primary key (BATCH_TYPE, BATCHNUM)
using index
tablespace FT1_DATA;
--Inxes
create unique index FT1DSTINT.BATCH_HEADER2##BYNUM on FT1DSTINT.BATCH_HEADER2 (UPPER(BATCH_TYPE), BATCHNUM)
tablespace FT1_DATA
pctfree 10
initrans 2
maxtrans 255
storage (initial 64K
minextents 1
maxextents unlimited);
From Oracle's standpoint, though, it isn't indexing BATCH_TYPE. It's indexing an arbitrary function that happens to take BATCH_TYPE as an input. As far as Oracle is concerned, you might just as easily be indexing an expression that took a dozen column names as parameters, so it doesn't really make sense for Oracle to try to break down anything beyond the function.
Of course, you could always parse the expression and extract the column name, but I would be dubious that's the right answer... If a developer is comparing indexes between columns, there is a heck of a lot of difference between an index on BATCH_TYPE, and index on UPPER(BATCH_TYPE) and an index on SOME_OTHER_FUNCTION( BATCH_TYPE ).
Justin
Similar Messages
-
Policy name and column name inside a policy function
I have the following function associated with a policy in the employee table for SSN and SALARY columns
FUNCTION empid_policy_fn (object_schema IN VARCHAR2, object_name VARCHAR2)
end;
When the policy fires, the schema name and the name of the table are passed onto this function which we can use inside this function but is there a way to get the policy name and the column name which invokes this function?. The problem here is, I'm using same function (common) for multiple policies in different tables and that's why I need to get these details.
Thanks
-KrishnamurthyInside your policy function you can query V$VPD_POLICY along with V$SESSION, V$SQL and USER_SEC_RELEVANT_COLS
to get the fired policy name and column_names.
Something like
SELECT v.POLICY, .........
FROM v$session ss, v$sql s, v$vpd_policy v
WHERE ss.SID = (SELECT SID
FROM v$mystat
WHERE ROWNUM = 1)
AND s.address = ss.sql_address
AND s.address = v.paraddr
AND s.hash_value = v.sql_hash
AND s.child_number = 0HTH -
Finding source database table/column name for a column in a view
Hi i need to be able to identify the original database table/column name for a column in a view.
e.g. say i have a view like this
create v1 as select a.name fname, b.name bname, c.name cname,......
from u1.names a, u2.names b. u3.names c
where .....
Now I want to find out that the database table/column name for the fname, bname and cname columns in the view v1, which in this instance is u1.name.name, u2.names.name, u3.names.name.
But i need to be able to do it for any view. Short of parsing the SQL is there an easy way of doing this?
Now obviusly I can't do this for virtual columns but I will know my column is not virtual as it has an index on it.But i need to be able to do it for any view. Short of
parsing the SQL is there an easy way of doing this?No, parsing the SQL is the only way. Good luck it is not something I would want to attempt. -
Dynamically pass Table name, Column Name and rownum to function
Hi Guys
I wanted to pass the table name, column name and rownum to function and get the relevant value for it. Please guide me to achieve this task
Thanking You
Regards
LakmalThanks,
Here is my test function
CREATE or replace FUNCTION GET_COLUMN_VALUE (tab_name VARCHAR2,column_name VARCHAR2) RETURN varchar2 AS
strsql varchar2 (500);
ColVal varchar2;
BEGIN
strsql:='select '||column_name||' from '||tab_name|| ' Where rownum = 1' ;
EXECUTE IMMEDIATE strsql into ColVal;
RETURN ColVal ;
END;
Message was edited by:
Lakmal Marasinghe -
How can I get actual table name for Bom_Bo_Pub.Bom_Revision_Tbl_Type? I am trying to confirm if this particular table has a "REVISION_LABEL" column in 11.5.9.
Duplicate post.
Need to know actual table name for actual table name for Bom_Bo_Pub.Bom_Rev
Need to know actual table name for actual table name for Bom_Bo_Pub.Bom_Rev -
Table Name and Column name for Product Family Field under the Product Famil
Hi,
Please help me finding the table name and the column name for the 'Product Family' field and the 'Item' field under the Product families form. The navigation to this form is as follows:
Material Planner Responsibility -> Setup -> Product Family
Please help.
Thanks,
KM2 months ago, you asked a very similar question... and Markus gave you a good answer. His 2-months old answer still applies here.
I recommend that you read it a again at Table name for backorder qty on sales order.
When you have read his answer, please close both threads. -
Is there a way to get the actual column name from a result set metadata? For this query "select registration_date as fff from ggg" both getColumnName and getColumnLabel both return 'fff' where I expected getColumnName to return 'registration_date'.
TrevorColumn name is obtained as follows.
ResultSet columns = metadata.getColumns(null, "%", tableName, "%");
while (columns.next()) {
String columnName = columns.getString("COLUMN_NAME");
} -
How to get column names for a specific view in the scheme?
how to get column names for a specific view in the scheme?
TIA
Don't have DD on the wall anymore....or this?
SQL> select text from ALL_VIEWS
2 where VIEW_NAME
3 ='EMP_VIEW';
TEXT
SELECT empno,ename FROM EMP
WHERE empno=10 -
I am using SSIS to extract fixed width data into a flat file destination and I keep getting below error. I have tried almost everything in this forum but still no solution. can anyone help me out to solve this problem.
[Flat File Destination [220]] Error: Failed to write out column name for column "Column 2".
[SSIS.Pipeline] Error: component "Flat File Destination" (220) failed the pre-execute phase and returned error code 0xC0202095
ThanksHi Giss68,
Could you check the Advanced tab of the Flat File Connection Manager to see whether the InputColumnWidth and the OutputColumnWidth properties of the Column2 has the same value? Please refer to the following link about the same topic:
http://stackoverflow.com/questions/10292091/how-do-i-fix-failed-to-write-error-while-exporting-data-to-ragged-right-flat-fil
If it doesn’t work, please post the sample data and the advanced settings of Column2 for further analysis.
Regards,
Mike Yin
If you have any feedback on our support, please click
here
Mike Yin
TechNet Community Support -
Getting column names for resultMap - Ibatis
Hi friends,
I need to get the column names for the properties specified in sqlMap.xml in my code .
for example: <resultMap id="resmap" class="java.util.HashMap">
<result property="custId" column="cust_id"/>
<result property="routerId" column="router_id"/>
<result property="routerName" column="router_name" jdbcType="CLOB"/>
<result property="device_type" column="device_type"/>
</resultMap>
i need to get the column values in code.........
is there anyway to access the sqlMap.xml file as an instance in Ibatis.I always use jaxb2 to unmarshall/marshall, works like a charm
-
Function module to get the name of all the function module used
I want to populate a internal table with the name of all function module used in the submitted program?? Is there any function module which return the name of all the function module used?
Hi Priya
Try this one RPY_FUNCTIONMODULE_READ.
Ranga -
How to get the owner name for the file in ftp using abap ?
Hi folks ,
How to get the owner name for the file in ftp using abap ? please help me very ugernt . I tried with all standard FTP commands
but doest work out me . Helping in this regard highly appreciated ...
Thanks and regards,
Swarupa VanarchiHi
dont you have used the os user while calling the FTP_CONNECT FM?
Hope you are not talking about the user executing the FTP program.
Else If you are talking about the FTP file creator then its not related to abap as you can handle it by maintaining the user in file name itself.
May be i am going too far with if and elses here as your question possesses no clarity.
Plz elaborate your requirement before anybody can help.
Regards
sateesh -
Need to return dynamic column names for a function returning nested table
I am having a pl/sql function which is returning a nested table.
For this i have defined an object which is having 4 attributes- 1 number type, 3 varchar2 type -p1,p2,p3.
My function is taking input parameter v1,v2,v3 all of varchar2 type.Inside the function body,i am using these (v1,v2,v3) to filter data from an sql query and i am also
using pivot function in this sql query.
At the end my function is returning the object as defined in the starting .
When i am excuting this function,thru select statement :
select * from table(f1_test('A','B','C'));
i am geting p1,p2,p3 as column name ,which are names used when i had defined object type.Instead i want column name to be dynamic (wotever i am passing in function as
parameter while executing the function ,here A,B,C)
Please help me in geting column names dynamic as passed in input parameter (i.e A,B,C for this case )
Sample code for the problem:
create or replace TYPE obj1 AS OBJECT
( id number(5,0)
,p1 varchar2(10),
,p2 varchar2(10)
,p3 varchar2(10)
create or replace TYPE tt1 AS TABLE OF OBJ1;
create or replace
function f1_test (v1 varchar2,v2 varchar2,v3 varchar2)
return tt1 as
v_return tt1 ;
v_str varchar2(30000);
begin
v_str:='
select
cast(
multiset(
select * from
select
aa.report_id
,cc.name
,e.amount
from
aa,cc,e
where
<join conditions>
and cc.name in ('''||v1||''','''||v2||''','''||v3||''')
pivot (sum (amount) for name in ('''||v1||''' as '||v1||','''||v2||''' as '||v2||','''||v3||''' as '||v3||'))
as tt1)
from
dual';
dbms_output.put_line(v_str);
execute immediate v_str
into
v_return ;
return v_return;
end;
Edited by: 845831 on 20 Mar, 2011 12:15 PMselect id,p1 A,p2 B,p3 C from table(f1_test('A','B','C'));
drop function f1_test;
drop type tt1;
drop type obj1;
create or replace TYPE obj1 AS OBJECT
( id number(5,0)
,p1 varchar2(10)
,p2 varchar2(10)
,p3 varchar2(10)
create or replace TYPE tt1 AS TABLE OF OBJ1;
CREATE OR REPLACE
FUNCTION f1_test(
v1 VARCHAR2,
v2 VARCHAR2,
v3 VARCHAR2)
RETURN tt1
AS
v_return tt1 ;
v_str VARCHAR2(30000);
BEGIN
v_str:='select cast(multiset(select 1,''20'',''30'',''40'' from dual) as tt1) from dual';
dbms_output.put_line(v_str);
EXECUTE immediate v_str INTO v_return ;
RETURN v_return;
END;
/ -
Getting error "Column is not indexed " when executing query on ORACLE 10g
Hi all,
When executing the below query im getting the error "ORA-20000:Column is not indexed"
query:
select xmlelement("nexml:result",xmlattributes('http://namespaces.nextance.com/nex/xml' as "xmlns:nexml"),xmlelement("nexml:value",count(*))).getClobVal()
from "permission"
where ( ((contains(object_value,'(searchDocument) inpath(/permission/action)') > 0)) and ((existsNode(object_value,'/permission[resource/resourcekey/@type[. = "document"]]') = 1)) and ((contains(object_value,'(GeneralUser) inpath(/permission/principal/@name)') > 0)) and ((existsNode(object_value,'/permission[principal/@type[. = "group"]]') = 1)) and ((existsNode(object_value,'/permission[type[. = "allow"]]') = 1)) and ((contains(object_value,'(nexip) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(Corporate) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(ProcurementAgreement) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(Procurement) inpath(/permission/resource/resourcekey/field/@value)') > 0) or (contains(object_value,'(SalesAgreement) inpath(/permission/resource/resourcekey/field/@value)') > 0)) )
Then after checking some forum, i replaced "contains" with "ora:contains" and executed the query. Now im not getting the first error but got a new error "invalid relational operator"
So please help me in resolving the errors?
Thanks in advance.Anil kumar wrote:
Hi,
Thanks for your reply. Could you please explain your solution in detail?Hi,
I just have a try...
create table t (id int,my_lob clob)
begin
insert into t values(101,'Oracle redwood shores USA');
insert into t values (102,'HP palo alto USA');
insert into t values(103,'Capgemini FRANCE');;
end;
create index my_idx on t(my_lob) indextype is ctxsys.context
select *
from t
where contains(my_lob,'USA',1)>0
Output
ID MY_LOB
101 Oracle redwood shores USA
102 HP palo alto USA Hope it helps,
CKLP -
Just new to this and unable to find answers
My solution
Public Function GetTableColumnNames() As Boolean
Form1.ListBox1.Items.Clear()
_MDFFileName = String.Format("{0}.mdf", _DatabaseName)
_sqlConnectionString = String.Format("Data Source=(LocalDB)\v11.0;AttachDBFileName={1};Initial Catalog={0};Integrated Security=True;", _DatabaseName, Path.Combine(_DatabaseDirectory, _MDFFileName))
Dim cn As New SqlConnection(_sqlConnectionString)
'put the table name in brackets in case it has spaces in it
Dim SQLString As String = "SELECT * FROM [" & _TableName & "]"
Try
cn.Open()
Dim cmd As New SqlCommand(SQLString, cn)
Dim rdr As SqlDataReader =
cmd.ExecuteReader(CommandBehavior.KeyInfo)
Dim tbl As DataTable = rdr.GetSchemaTable
'This shows all of the information you can access about each column.
For Each col As DataColumn In tbl.Columns
Form1.ListBox1.Items.Add(col.ColumnName)
Debug.Print("col name = " & col.ColumnName & ", type = " & col.DataType.ToString)
Next
'Get each column.
For Each row As DataRow In tbl.Rows
Form1.ListBox1.Items.Add(row("ColumnName"))
Next
rdr.Close()
Catch
MessageBox.Show("Error opening the connection to the database.")
Finally
cn.Close()
End Try
Return _Success
End Function
Maybe you are looking for
-
Lumia 810 (T-mobile) - SD card issue, any updates?
As I've found by searching around, it seems like the new Nokia Windows 8 phones have issues when using Class 10 micro-SD cards. I'm using a 32GB Aopen Class 10 micro-SD card in my Lumia 810, and I'm experiencing the following issues: *Attempting to
-
Some problems about database connection
I am working on oracle9i. The problem is that I have to specify the "host string" in the login window of SQL*PLUS to connect to database (I can't use the command-line GUI). But I don't know how to specify "Host String" in JDBC connection string and S
-
Non-built-in type contained in a java.util.List creates a SoapFaultException
I have created a web service that utilizes non-built-in types which uses other non-built-in types...(simplified example follows) public class MyService { public Foo getFoo( String id ) { Foo foo = ...; // get persisted foo return foo; package mypacka
-
IPad2 connects at home, not at work
OK, this is a strange one. We have several users, both Mac and PC using iPad2's as part of our testing before we make them available for anyone to use. One user is having issues when she tries to sync at work. When she takes her work laptop home and
-
Hi people, it been ages since I log in and ask for help and now I have a major problem... You see, I'm going to do my final year project for my IT course and is attached to a company. This company wishes to create a UML design toolkit which create th