How to return column name in some table?
Hi All,
I know :system.cursor_value which returns the value of the current text item in the form.
But Is there a way to return the column name and its value in some table?
Note: I'm using Oracle DB 10g
Thank you
Did you read the original post? [...] You don't understand what I want and you don't say antthing useful for my goal!
This is the SQL and PL/SQL forum. You need the Mind-Readers' forum down the hall.
First you asked "Is there a way to return the column name and its value in some table?", and were told you can get the former from the data dictionary (you can get the latter from the table itself).
Then you say you "want to create a trigger on a table", which tells us nothing about your problem.
Finally you say "but suppose the table contains 50 columns then I have to write 50 columns names three times", which is essentially true - but the process can be automated. What you (probably) need to do is write queries based on the data dictionary tables that generates the PL/SQL that you ultimately put in your triggger - you then use that output to build the trigger(s).
I don't think there's any way, at run time, to generically fish out all the columns of a table with their :new and :old values - you have to write (or auto-generate) specific code for each table.
Similar Messages
-
How to find column names in a table
Am learning the basics of SQL Plus.
Have entered the following query:
SELECT * FROM t_ebb_session;
This gives me the following output.
USER_ID SESSION_ID LAST_ACCE
However LAST_ACCE is not the full name of the column as I get 'Invalid column name when I use it in a select statement.
How do I display the full name?By default, SQL*Plus will set the column display width of a character column to its size in the database, and the heading will be the column name in uppercase, truncated to fit that width if necessary. (There is a different rule for numeric columns.)
You can override this with the COLUMN command, e.g:
COLUMN some_column_name FORMAT a30 HEADING "Alternative Name"
Check out the SQL*Plus documentation for all the COLUMN options. -
How to get only column names from different tables as single table columns
Hi All,
I have one requirement in which we want only column names from different tables.
for example :
I have three tables T1 ,T2, T3 having
col1 clo2 clo3 --> T1 ,
col3 col5 ,clo6 --> T2 ,
Clo6 col8 col9 --> T3
columns i want to get only all Column names from all table as single Resultset not any data from that how can i get that empty resultset
because this empty result i want to bind in datagridview(front end) as Empty resultset
Please tell me anyways to do this
Niraj SevalkarIf I understand you want an empty result set, just with metadata. SET FMTONLY do the trick:
SET FMTONLY ON
SELECT Col1, Col2, Col3, ....., Coln
FROM
T1 CROSS JOIN T2 CROSS JOIN T3
SET FMTONLY OFF
Another alternative is to include an imposible contition
SELECT Col1, Col2, Col3, ....., Coln
FROM
T1 CROSS JOIN T2 CROSS JOIN T3
WHERE 1 = 0
If you are using a SqlDataAdapter in your client application. You can use the FillSchema method. the select command may be any select statement that returns the columns you want. Under the covers FillSchema will call SET FMTONLY ON.
If you are using SqlCommand.ExecuteReader you can pass SchemaOnly to CommandBehavior argument. SET FMTONLY ON is called under the covers. Again the select command may be any select statement that returns the columns you want.
"No darás tropezón ni desatino que no te haga adelantar camino" Bernardo Balbuena -
How to rename a column name in a table? Thanks first!
I tried to drop a column age from table student by writing the
following in the sql plus environment as :
SQL> alter table student drop column age ;
but I found the following error
ORA-00905: 缺少关键字 (Lack of Key word)
I have oracle enterprise edition 8.0.5 installed at windows 2000
thank you
And I want to know how to rename a column name in a table?
thanksIn Oracle 8i, your syntax would have worked. However, if I
recall correctly, in Oracle 8.0, you can't rename or drop a
column directly. One way to get around that problem is to
create another table based on a select statement from your
original table, providing the new column name as an alias if you
want to change the column name, or omitting that column from the
select statement if you just want to drop it. Then drop the
original table. Then re-create the original table based on a
select statement from the other table. Then you can drop the
other table. Here is an example:
CREATE TABLE temporary_table_name
AS
SELECT age AS new_column_name,
other_columns
FROM student
DROP TABLE student
CREATE TABLE student
AS
SELECT *
FROM temporary_table_name
DROP TABLE temporary_table_name
Something that you need to consider before doing this is
dependencies. You need to make a list of all your dependecies
before you do this, so that you can re-create them afterwards.
If there are a lot of them, it might be worthwhile to do
something else, like creating a view with an alias for the
column or just providing an alias in a select. It depends on
what you need the different column name for. -
How to get the column names of the table into the Dashboard prompt
how to get the column names of the table into the Dashboard prompt
Thanks & Regards
Kishore PHey john,
My requirement is as follows
I have created a Rank for Total sales by Region wise i.e RANK(SUM(Dollars By Region)) in a pivot table.
My pivot table looks like this
COLUMN SELECTOR: TOTAL US , REGION , DISTRICT , MARKET
---------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK REGION DOLLARS DOLLARS DOLLARS DOLLARS
1 CENTRAL 10 20 30 40
2 SOUTHERN 10 30 30 70
3 EASTERN 20 20 20 60
4 WESTERN 10 20 30 40
When i select the District in column selector
Report has to display rank based on Total Sales by District. i.e
------------------------------------------------- JAN 2009 FEB 2009 MAR 2009
RANK DISTRICT DOLLARS DOLLARS DOLLARS DOLLARS
for this i need to change the fx of rank i.e RANK(SUM(Dollars By Region)) to RANK(SUM(Dollars By District)) and fx of Region i.e Markets.Region to Markets.District dynamically.
so , i need to capture column name of the value selected from the column selector and dynamically i need to update the fx 0f RANK & fx of region.
do you have any solution for this?
http://rapidshare.com/files/402337112/Presentation1.jpg.html
Thanks & Regards
Edited by: Kishore P on Jun 24, 2010 7:24 PM
Edited by: Kishore P on Jun 24, 2010 7:28 PM -
How to get column names in table maintenance dialog?
I created a new Z table and created a maintanance dialog so that I can maintain the table through sm30. i don't see columns names on maintenance screen, just a "+" sign for each column! Could someone please tell me how to display column name?
Thanks.
MithunHello Mithun
The column texts are taken from the field descriptions of the data elements used in your z-table. A "+" sign usually indicates that none of the field descriptions of the data element has been maintained.
Regards
Uwe -
How to know primary key column name form a table name in sql query
Suppose I only know the table name. How to get its primary key column name from the table name?
ThanksViews don't have primary keys though their underlying tables might. You'd need to pick apart the view to determine where it's columns are coming from.
You can select the text of the view in question from user_views. -
How to get the constraintlist and column name in a table?
Hi,
can anyone please tell me how to get the constraint type ,and it's imposed on columns names in a table.
Thanks,
DeekayDeekay wrote:
can anyone please tell me how to get the constraint type ,and it's imposed on columns names in a table.To get constraint type:
select constraint_type from user_constraints where constraint_name = 'YOUR CONSTRAINT NAME';To get constraint columns:
SELECT column_name from user_cons_columns where constraint_name = 'YOUR CONSTRAINT NAME';SY. -
How to rename column name of table?
Hello...
How to rename column name of table?
The column have data.
Thanks.
Martonio.The following should work in 9i release 2 and above.
SQL> create table mytable(col1 varchar2(2),
2 col2 date);
Table created.
SQL> insert into mytable values('t1',sysdate);
1 row created.
SQL> select * from mytable;
CO COL2
t1 30-NOV-04
1 row selected.
SQL> desc mytable
Name Null? Type
COL1 VARCHAR2(2)
COL2 DATE
SQL> alter table mytable rename column col2 to mydate;
Table altered.
SQL> desc mytable
Name Null? Type
COL1 VARCHAR2(2)
MYDATE DATE
SQL> select * from mytable;
CO MYDATE
t1 30-NOV-04
1 row selected.
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.3.0 - Productionhttp://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/wnsql.htm#972698 -
How to select even the column names of a table?
Hello All,
Is there a way to select even the column names of a table in the select statement?
My select from a table (say X) is in a SQL* Plus script that gets invoked by application tier and displays data in the application tier window. User's can then copy the data into a spreadsheet and do their processing. However, I need to give them the column names too along with the data.
Thanks,
ChiruIf there is a middle tier that is selecting and
displaying the data, and that's what the users are
copying from, the middle tier would have to address
its presentation of the data to allow users to
include column names. If this is a common task, the
application should probably be modified to give users
the option of downloading the data in a spreadsheet
directly rather than forcing them to copy and paste
data.Thanks for the reply.
The users don't have to copy paste. The application tier has an options in the "Tools" menu item which allows them to copy the entire output to a file (in my case a txt file which is a pipe delimited). Then they have to do text to columns to get the data into each column of the spreadsheet. I could have directly called the stored procedures from the application tier and created ".csv" files and FTP'd them to the user's folders. However, I am having to go this round about because, I am not getting enough support from the LAN team in FTP'ing etc.
OK I'll think of another workaround.
Thanks,
Chiru -
How to read the column name of a table from sap system using C#?
Hi!!
I am using SAP .NET connector and creating a windows application.
Now I wanna read the column name when a table name is given....
Connection is done, but I don't know the code to read the column names alone...
Can anyone help me with the code??fine!!
So if i give the table name, which the RFC_READ_TABLE function module have, will it run properly? or i wanna change all the codes in order to support RFC_READ_TABLE function module?
Because from the beginning I was using BAPI_CUSTOMER_GETLIST function, but my client requirement is to use ERP function module RFC_READ_TABLE, he didn't give any table name also..
This is my code: What I have to change in this???
ECCDestinationConfig ECCDestination = new ECCDestinationConfig();
RfcDestinationManager.RegisterDestinationConfiguration(ECCDestination);
RfcDestination rfcDest = null;
rfcDest = RfcDestinationManager.GetDestination(a);
RfcRepository repo = rfcDest.Repository;
IRfcFunction customerList = repo.CreateFunction("BAPI_CUSTOMER_GETLIST");
IRfcTable addressData = customerList.GetTable("AddressTable"));
int j = addressData.Metadata.LineType.FieldCount;
for (int i = 0; i < j; i++)
RfcElementMetadata metadata = addressData.GetElementMetadata(i);
listallcolumn.Items.Add(metadata.Name);
Message was edited by: Jeswin Rebil -
How can I list all the column names of a table by programming?
Hi,
Now I want to write an function which has the following features:
Firstly, The function was given a parameter as table name.
Then, it will lists all the columns names of the table.
e.g
table: person
---firstName------lastName----+
Michale Jackson
We can get the columns 'firstname' and 'lastName' by calling the function with table name 'person'.
And I also wonder that where I can get reference book or any other materials?
Thanks.
Edited by: wenjing wang on Feb 15, 2008 6:42 AM
Edited by: wenjing wang on Feb 15, 2008 6:57 AMhi,
hope the below code helps u. Just take the headee which contains the field name and split it like below and compare it with the field name u want here 'last name'.
here,
'First name' will be in wt_filedata1 and remaining field names in wt_filedata2, so 'do' continues.
c_tab must be the separator, either , or + or tab etc..
CODE:
read table person into wl_header index 1.
do.
split wl_header at c_tab into: wt_filedata1 wt_filedata2.
if wt_filedata1 <> 'lastname'.
cnt1 = cnt1 + 1.
wl_header = wt_filedata2.
else.
exit.
endif.
enddo.
Please reward if it is useful.
regards,
sri -
Column names from another table
Hi All,
I have a scenario where i need to get names of a column from another table
for eg,
Table EMP
EmpNo EmpName EmpContact EmpPhone
1 xyz [email protected] 345
2 abc [email protected] 897
3 ttp [email protected] 345
The column names of this table can be configurable from some other place and its value is stored in another table like
Table Config (2 Columns)
Column_Name Value
EmpName First name
EmpContact Email
EmpPhone Mobile
Now i want to fetch the values from Emp table but with column headers that are changed and have a value in Config table.
If a column name is not there in config table then the original column name should come.
As shown below
EmpNo First name Email Mobile
1 xyz [email protected] 345
2 abc [email protected] 897
3 ttp [email protected] 345
Another eg, If EmpName is not changed and entered in second table , then i want to have the same name as the original EMP table has as shown below.
EmpNo EmpName Email Mobile
1 xyz [email protected] 345
2 abc [email protected] 897
3 ttp [email protected] 345
In other words something like this,
select empno,
EmpName as (select value from config where column_name=EmpName),
EmpContact as (select value from config where column_name=Empcontact),
EmpPhone as (select value from config where column_name=EmpPhone)
From EMP
Can some one please help me in providing a solution for this.
Edited by: 941386 on May 30, 2013 6:20 AMUnfortunately, I think this is a job for dynamic sql ...
Build your "query" first:
(note this won't work "as is", fix the syntax - but you get the idea.)
lv_str := 'select empno,
EmpName as ' || (select value from config where column_name=EmpName) || ',
EmpContact as ' || (select value from config where column_name=Empcontact) || ',
EmpPhone as ' || (select value from config where column_name=EmpPhone) || '
From EMP;';
execute immediate lv_str;Not sure if there's a better way or not.
Only other way I can think of is to leverage the way UNION [ALL] works.
So the following query:
select a, b, c from dual
union all
select d, e, f from dual
/returns data in columns "named" : "a, b, c"
Effectively renaming columns d, e, f. You just need to turn your data on edge in that first query, then throw out the rows (I don't know how to get it to work, but perhaps somebody else does?)
[edit]
another thought is create a view over top of the table, query that view, then drop the view :P
that would work nicely - avoid the dynamic SQL. shrug
[edit]
Edited by: Greg.Spall on May 30, 2013 9:37 AM -
How to pass column name as a values from one page to another
hi
i have created a report(pivot) from a table
SQL> SELECT * FROM T;
C1 C2 C3 D SEQ
A AA 2 1
A AB 3 2
A AC 2 3
B AB 5 4
B AC 6 5
SQL> SELECT C1
2 ,NVL(MAX(CASE WHEN C2='AA' THEN C3 END),'') AA
3 ,NVL(MAX(CASE WHEN C2='AB' THEN C3 END),'') AB
4 ,NVL(MAX(CASE WHEN C2='AC' THEN C3 END),'') AC
5 ,SUM(C3) FROM T GROUP BY C1;
C1 AA AB AC SUM(C3)
A 2 3 2 7
B 5 6 11
SQL>
my requirement in Apex is like this(reverse)
eg-
when i click on cell values '2' then,it should return
C1 C2 C3 D SEQ
A AA 2 1
{quote}how to pass column name as a values from one page to another
for example i have to pass 'c2' as a value to next page{quote}for report pivot you can reffer below link
Report
Amuthanks for your reply
i 'm doing what exactly you mention here .
my problem here is
i have 15 columns
i am executing a query based on the values of the column(column name) in the target page
1)here i am passing(all) the column values to the next page-but i want to pass only one column values(column name)
when i click on any cell of that column
OR
2)i can pass all column name to target page -there(in the target page) i can filter out
i think option 1 would good if you filter out the unwanted columns
Regards
Amul -
Hi,
how can I make Oracle ODBC Driver (8.01.72.00) returning column name in small letters ?
Thanks for any help.Pardon my stupidity, but I'm still a little confused. Perhaps it's too early in the morning...
If you create a table foo in Oracle, i.e.
create table foo (
col1 varchar2,
col2 integer )
col1 & col2 are stored as uppercase in the database, although queries against the table are case-insensitive. For instance
select col1 from foo;
select COL1 from foo;
select cOl1 from foo;
all return the same thing
If you instead create a table
create table foo (
"col1" varchar2,
"col2" integer )
col1 & col2 are stored as case-sensitive column names, in this case lower case. Because the column names are case-sensitive,
the SQL statement
select "col1" from foo;
will return the correct data, while
select col1 from foo;
will cause an error.
Is this helpful to you? I guess I'm not sure where it is that you're generating or gathering column names, so I'm not sure how much control you have.
If you're gathering column names by making calls to catalog functions like SQLTables, I assume you can simply use the appropriate LOWER() function call to create lowercase column names.
If you can explain in a little more detail, preferrably with reference to the particular ODBC calls you're making, I might be able to help a little more.
Justin
Maybe you are looking for
-
Download service manual for dv7-1243cl
Where can I download the service manual for a dv7-1243cl I have just been informed that the fan assembly is not an end user replaceable item. The laptop is out of warranty and I am an experienced tech. I have been able to download the manual for bo
-
Punch-out: Bringing data back to SRM screen
Hi Gurus, I need to understand exact steps involved in Punch-out customization for a catalog. My problem is, I can access the catalog (after maintaining respective parameters in OCI structure) but I am unable to understand the config part to bring th
-
ITunes displaying asian languages one day, boxes the next
My music is almost entirely made up of Japanese and Korean music. A lot of the song titles/band titles are in kanji and hangul, which iTunes used to not have a problem with. It just recently started displaying boxes instead of the characters and in m
-
While using Firefox i cannot reply to messages in my gmail account. Please advise.
While using Firefox i cannot reply to messages in my Gmail account. Please advise.
-
Hi, As always thank you for your help. I am keen to try dw ftp in order to load site folders, as I have had to resort to loading png image individually via File Manager in order for them not to go corrupt. However, I keep getting an error message and