How to get the Column names of output that is displaying in Sql Developer(Oracle 11g).
Hi,
I am using OCCI to interact with DB through code, which means I am writing a vc++ file to interact with Data Base and execute the Stored Procedure which I am calling from the C++ Code. And also displaying the output of the Stored Procedures to the Front End. I am succeeded in this, but now I should be able to display the Column names of the output to Front End. Can any one help me on this.
Example:
Sno | Sname
------- |-------------
1 ABC
2 DEF
I am getting (1,ABC) and (2,DEF) as the output of the Stored Procedure but I need the Column names also to display. How to get them.
Thanks in Advance..:)
Look at Re: exporting csv via pl/sql - select statement?
It has an example how to extract the column name from a cursor. You have to check, whether you can use DBMS_SQL.DESCRIBE_COLUMNS
Your procedure might need another out parameter, that returns the column names , e.g. as comma separated list or as varray.
Similar Messages
-
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 -
Reading csv file how to get the Column name
Hi,
I am trying to read a csv file and then save the data to Oracle.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection c = DriverManager.getConnection("jdbc:odbc:;Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=.;Extensions=csv,txn");
Statement stmt = c.createStatement();
ResultSet rs = stmt.executeQuery("select * from filename.csv");
while(rs.next())
System.out.println(rs.getString("Num"));
My csv file looks like this:
"CHAM-23","COMPANY NAME","Test","12",20031213,15,16
Number,Environ,Envel,Date,Time
"1","2",3,"4",5
"6","7",8,"9",9
Now is there anyway using the above code I start processing the file from the second row that holds the names of the columns and skip the first row. And also can I get the name of the column using ResultSet something like:
if columnName.equals("Number")
Because I may have a csv file that could have more columns:
"CHAM-24","COMPANY NAME","Test","12",20031213,16,76
Number,Environ,Envel,Date,Time,Total,Count
"1","2","3","4","5",3,9
"6","7","8","9",9",,2
So I want to get the column name and then based on that column I do some other processing.
Once I read the value of each row I want to save the data to an Oracle Table. How do I connect to Oracle from my Application. As the database is on the server. Any help is really appreciated. ThanksThe only thing I could think of (and this is a cluj) would be to attempt to parse the first element of each row as a number. If it fails, you do not have a column name row. You are counting on the fact that you will never have a column name that is a number in the first position.
However, I agree that not always placing the headers in the same location is asking for trouble. If you have control over the file, format it how you want. If someone else has control over the file, find out why they are doing it that way. Maybe there is a "magic" number in the first row telling you where to jump.
Also, I would not use ODBC to simply parse a CSV file. If the file is formatted identically to Microsoft's format (headers in first row, all subsequent rows have same number of columns), then it's fine to take a shortcut and not write your own parser. But if the file is not adhering to that format, don't both using the M$ ODBC driver.
- Saish
"My karma ran over your dogma." - Anon -
How to get the column name and table name with value
Hi All
I have one difficult requirement
I have some column values and they have given some alias column names but i need to find the correct column name and table name from the database.
For example value is "SRI" and i dont know the table and exact column name so is there any possibilities to find the column name and table name for the given value
Thanks & Regards
Srikkanth.MSearching all the database for a word...
Courtesy of michaels...
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
11g upwards
SQL> select table_name,
column_name,
:search_string search_string,
result
from (select column_name,
table_name,
'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
from cols
where table_name in ('EMP', 'DEPT')),
xmltable (str columns result varchar2(10) path '.')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME es RESEARCH
EMP ENAME es JAMES
EMP JOB es SALESMAN
EMP JOB es SALESMAN
4 rows selected. -
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 -
How to get the column name and table name from xml file
I have one XML file, I generated xsd file from that xml file but the problem is i dont know table name and column name. So my question is how can I retrieve the data from that xml file?
Here's an example using binary XML storage (instead of Object-Relational storage as described in the article).
begin
dbms_xmlschema.registerSchema(
schemaURL => 'my_schema.xsd'
, schemaDoc => xmltype(bfilename('TEST_DIR','my_schema.xsd'), nls_charset_id('AL32UTF8'))
, local => true
, genTypes => false
, genTables => true
, enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_CONTENTS
, options => dbms_xmlschema.REGISTER_BINARYXML
end;
genTables => true : means that a default schema-based XMLType table will be created during registration.
enableHierarchy => dbms_xmlschema.ENABLE_HIERARCHY_CONTENTS : indicates that a repository resource conforming to the schema will be automatically stored in the default table.
If the schema is not annotated, the name of the default table is system-generated but derived from the root element name :
SQL> select table_name
2 from user_xml_tables
3 where xmlschema = 'my_schema.xsd'
4 and element_name = 'employee';
TABLE_NAME
employee1121_TAB
(warning : the name is case-sensitive)
To annotate the schema and control the naming, modify the content to :
<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xdb="http://xmlns.oracle.com/xdb">
<xs:element name="employee" xdb:defaultTable="EMPLOYEE_XML">
<xs:complexType>
Next step : create a resource, or just directly insert an XML document into the table.
Example of creating a resource :
declare
res boolean;
doc xmltype := xmltype(
'<employee>
<details>
<emp_id>1</emp_id>
<emp_name>SMITH</emp_name>
<emp_age>40</emp_age>
<emp_dept>10</emp_dept>
</details>
</employee>'
begin
res := dbms_xdb.CreateResource(
abspath => '/public/test.xml'
, data => doc
, schemaurl => 'my_schema.xsd'
, elem => 'employee'
end;
The resource has to be schema-based so that the default storage mechanism is triggered.
It could also be achieved if the document possesses an xsi:noNamespaceSchemaLocation attribute :
SQL> declare
2
3 res boolean;
4 doc xmltype := xmltype(
5 '<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6 xsi:noNamespaceSchemaLocation="my_schema.xsd">
7 <details>
8 <emp_id>1</emp_id>
9 <emp_name>SMITH</emp_name>
10 <emp_age>40</emp_age>
11 <emp_dept>10</emp_dept>
12 </details>
13 </employee>'
14 );
15
16 begin
17 res := dbms_xdb.CreateResource(
18 abspath => '/public/test.xml'
19 , data => doc
20 );
21 end;
22 /
PL/SQL procedure successfully completed
SQL> set long 5000
SQL> select * from "employee1121_TAB";
SYS_NC_ROWINFO$
<employee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceS
<details>
<emp_id>1</emp_id>
<emp_name>SMITH</emp_name>
<emp_age>40</emp_age>
<emp_dept>10</emp_dept>
</details>
</employee>
Then use XMLTABLE to shred the XML into relational format :
SQL> select x.*
2 from "employee1121_TAB" t
3 , xmltable('/employee/details'
4 passing t.object_value
5 columns emp_id integer path 'emp_id'
6 , emp_name varchar2(30) path 'emp_name'
7 ) x
8 ;
EMP_ID EMP_NAME
1 SMITH -
How to get the query result of improvement (Before and After ) using sql de
how to get the query result of improvement (Before and After ) using sql developer.
Check
http://www.oracle.com/technetwork/articles/sql/exploring-sql-developer-1637307.html -
How to get the table name and bind columns names in an INSERT statement ?
I have an INSERT statement with input parameters (for example
INSERT INTO my_table VALUES (:a, :a, :a)) and I want to know
without parsing the statement which is the name of table to
insert to and the corresponding columns.
This is needed to generate the SELECT FOR UPDATE statement to
refetch a BLOB before actually writing to it. The code does not
know in advance the schema (generic code).
Thanks in advance,
Joseph CanedoOnce you have prepared your statement, you can execute the
statement with the OCI_DESCRIBE_ONLY mode before binding any
columns. Then you can use OCIParamGet to find out about each
column (column index is 1-based). You should get OCI_NO_DATA or
ORA-24334 if there are no more columns in the statement. Note
that the parameter descriptor from OCIParamGet is
allocated/freed internally by OCI; you do not need to manage it
explicitly. The parameter descriptor is passed to OCIAttrGet in
order to obtain for instance the maximum size of data in the
column OCI_ATTR_DATA_SIZE. You can also get the column name in
this way, although I do not remember the #define off the top of
my head. Getting the table name appears to be much more
difficult; I have never had to do that yet. Good luck. -Ralph -
How to use the column names generated from Dynamic SQL
Hi,
I have a problem with Dynamic SQL.
I have written an SQL which will dynamically generate the Select statement with from and where clause in it.
But that select statement when executed will get me hundreds of rows and i want to insert each row separately into one more table.
For that i have used a ref cursor to open and insert the table.
In the select list the column names will also be as follows: COLUMN1, COLUMN2, COLUMN3,....COLUMNn
Please find below the sample code:
TYPE ref_csr IS REF CURSOR;
insert_csr ref_csr;
v_select VARCHAR2 (4000) := NULL;
v_table VARCHAR2 (4000) := NULL;
v_where VARCHAR2 (4000) := NULL;
v_ins_tab VARCHAR2 (4000) := NULL;
v_insert VARCHAR2 (4000) := NULL;
v_ins_query VARCHAR2 (4000) := NULL;
OPEN insert_csr FOR CASE
WHEN v_where IS NOT NULL
THEN 'SELECT '
|| v_select
|| ' FROM '
|| v_table
|| v_where
|| ';'
ELSE 'SELECT ' || v_select || ' FROM ' || v_table || ';'
END;
LOOP
v_ins_query :=
'INSERT INTO '
|| v_ins_tab
|| '('
|| v_insert
|| ') VALUES ('
|| How to fetch the column names here
|| ');';
EXECUTE IMMEDIATE v_ins_query;
END LOOP;
Please help me out with the above problem.
Edited by: kumar0828 on Feb 7, 2013 10:40 PM
Edited by: kumar0828 on Feb 7, 2013 10:42 PM>
I Built the statement as required but i need the column list because the first column value of each row should be inserted into one more table.
So i was asking how to fetch the column list in a ref cursor so that value can be inserted in one more table.
>
Then add a RETURNING INTO clause to the query to have Oracle return the first column values into a collection.
See the PL/SQL Language doc
http://docs.oracle.com/cd/B28359_01/appdev.111/b28370/returninginto_clause.htm#sthref2307 -
Get the column names of a query (in own plugin)
Hi,
I'm developing my first plugin. It is a region plugin where the plugin-user passes a sql query as the source that the plugin will turn into a formated report.
I found how to retreive the query result by using APEX_PLUGIN_UTIL.GET_DATA functions. Since it is an array, it is simple to cycle through the data rows. But how can i figure out
1) how many columns the query returns
2) whats the name of the columns is?
Thanks a lot in advance for any hint...
Cheers, HansHi Hans,
the package APEX_PLUGIN_UTIL provides everything you need. No need to do your own DBMS_SQL handling!
Have a look at the API documentation and the example of GET_DATA at http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_plugin_util.htm#BABFBIJD
The t_column_value_list record type is a two dimensional array defined as
type t_column_value_list is table of wwv_flow_global.vc_arr2 index by pls_integer;The first array contains an entry for each column.
l_column_value_list.COUNTcan be used to get the number of columns.
l_column_value_list(1).COUNTcan be used to get the number of rows. An example to iterate over all columns and rows:
for l_column in 1 .. l_column_value_list.count loop
for l_row in 1 .. l_column_value_list(l_column).count loop
sys.htp.p('column#=' || l_column || ' row=' || l_row || ' value: ' || l_column_value_list(l_column)(l_row));
end loop;
end loop;If you need the name of the columns and maybe the original data type and not everything converted to VARCHAR2 you have to use the more sophisticated GET_DATA2. See http://docs.oracle.com/cd/E23903_01/doc/doc.41/e21676/apex_plugin_util.htm#BABFJHAI
This function returns the record type t_column_value_list2 which is defined as
type t_value is record (
varchar2_value varchar2(32767),
number_value number,
date_value date,
timestamp_value timestamp,
timestamp_tz_value timestamp with time zone,
timestamp_ltz_value timestamp with local time zone,
interval_y2m_value interval year to month,
interval_d2s_value interval day to second,
blob_value blob,
bfile_value bfile,
clob_value clob );
type t_value_list is table of t_value index by pls_integer;
type t_column_values is record (
name varchar2(32767),
data_type varchar2(20), /* use c_data_type_* constants to compare */
value_list t_value_list );
type t_column_value_list2 is table of t_column_values index by pls_integer;Again, it's some kind of two dimensional array. The first dimensions are the columns. But this time you also get some details of the parsed column. For example:
for l_column in 1 .. l_column_value_list2.COUNT loop
sys.htp.p('Column Name: ' || l_column_value_list2(l_column).name || ' Data Type: ' || l_column_value_list2(l_column).data_type );
end loop;Will return you all the columns of the SQL statement. Using "name" and "data_type" you can get the column name and the data type. To access the values you can use
for l_column in 1 .. l_column_value_list2.COUNT loop
sys.htp.p('Column Name: ' || l_column_value_list2(l_column).name || ' Data Type: ' || l_column_value_list2(l_column).data_type );
for l_rows in 1 .. l_column_value_list2(l_column).value_list.COUNT loop
sys.htp.p(
'row=' || l_row || ' value: ' ||
apex_plugin_util.get_value_as_varchar2 (
p_data_type => l_column_value_list2(l_column).data_type,
p_value => l_column_value_list2(l_column).value_list(l_row) );
end loop;
end loop;I used apex_plugin_util.get_value_as_varchar2 to always get a VARCHAR2, independent of the actual data type of the column. If you need the original data type, use "number_value", ... of the t_value record type.
Hope that gives you a direction
Patrick
Regards
Patrick
My Blog: http://www.inside-oracle-apex.com
APEX Plug-Ins: http://apex.oracle.com/plugins
Twitter: http://www.twitter.com/patrickwolf -
Getting the column names dynamically
hi gurus,
i have list item populated with many table names from a schema.
i have grid in oracle forms 10g and i want to fill the grid with the data that should come at least four/more columns.
i want to fire the list change trigger when each time any one table name is selected/changed.
how can i get the column names dynamically
please give me the step by step process
for filling the grid..hi ,
by getting column names dynamically i am creating a record group
using this below query
SELECT COLUMN_NAME, DATA_TYPE FROM USER_TAB_COLUMNS WHERE TABLE_NAME = <table_name>
but when timestamp datatype is there then it is showing error cannot create group groupname
but the record group is running successful on varchar2,number,date dayatypes
if any alternative is there i mean to say without using record group then tell me or where is the problem -
How to get the Text name to pass in the parameter header in save_text
Hi,
I am trying to change the long text of operation for historical order by using the flat file.I am using the save_text to do this.I would like to know how to get the text name in order to pass the parameter header in save_text.
I went to the tcode iw62 to get the header information of the long text.300100000009200000001
i would like to know what this 1000000092 indicates and where is this value updated in the table so that i can link it thru the order no to get the link and pass it in the text_name.
can anyone help me out?
krishnanHi,
Your query is.
I went to the tcode iw62 to get the header information of the long text.300100000009200000001
i would like to know what this 1000000092 indicates
In above number
300 - Client
1000000092 - AUFPL - Routing number of operations in the order (You can fetch this from table HIVG)
00000001 - APLZL - General counter for order ( You can fetch this from table HIVG).
BR,
Vijay -
How to get the column index inside a dataTable
Hello,
before I get staked, there are multiple threads handling familiar topics to the one I'm questioning about but none gives an anwer. If there is one, I'm propably to less skilled to see it.
So here is my Problem: I've build a web-interface to a time-recording system. The hours worked on a certain project are displayed in a dataTable component which is generated out of a mySQL Query. Each entry (column/row) contains a inputText component to display and edit the specific value.
Editing one of these inputText elements now fires a valueChangeEvent which reads the new value and stores it in the database. For that cause I need to know the row- and column-index of the inputText component that fired the event.
Using the getClientId method from the valueChangeEvent I get some Information which makes it possible to calculate the row/column index. A typical clientID looks like "form_table:mainTable:0:_id14". "form_table" is the ID of the form the dataTable is in. "mainTable" is the id of the dataTable component. "0" is the row the component is in. And finally "_id14" stands for the id randomly given to the inputText component by JSF.
My Problem is now, that though I can calculate the column out of the[i] "_id14", this calculation is hardcoded. So everytime I add a component in before the dataTable, the calculation needs to be adjusted in the code.
The Questions:
- How to force a sensefull id indicating a column-index for the inputText components inside the columns of a dataTable?
- Nicer since no workaround: How to get the column-index inside the dataTable on a natural way? (e.g. out of the valueChangeEvent the specific inputText component fires)
After some investigation here on the board and on the net I know multiple ways to get the row index, (Things like component-binding and so on) but I can't find a answer on how to get the column-index.
Thanks to all answers and/or links to things my eyes missed while searching for one....then index 0 becomes index 1 and my program doesn't work properlyThe program works properly, just not as you expect it to.
As you've noticed the table gives you the flexibility to move columns around. So if you move column 0 to column 1, why would you expect to still use 0 as the index? The table manages the reordering of columns for you to make sure the data being displayed in each table column comes from the correct column in the data model.
You can manage this yourself using one of the following methods (I forget which one):
table.convertColumnIndexToModel(int viewColumnIndex)
table.convertColumnIndexToView(int modelColumnIndex)
Or, you can get data from the data model directly:
table.getModel().getValueAt(row, 0); -
Dear Expert,
I have one requirement like to read the selected workset name in portal by the current user.I have read two documents regarding how to retrieve the PCD contents (iViews, Pages, Worksets and Roles) and its properties like Created by, Changed by, Last changed by and others using PCD API.
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/6112ecb7-0a01-0010-ef90-941c70c9e401?overridelayout=true
http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/508baf88-9335-2d10-efa6-c6ad61e5fc4b?quicklink=index&overridelayout=true
But I am not able to understand how to get the specific name of the workset which is currently selected by the user.Can you please help me.
I am using portal 7.0.
Thanks & Regards,
PatralekhaHi Expert,
I found that we can use Interface INavigationHelperService to read Portal Role selected by user at runtime from http://scn.sap.com/thread/52194
But this class is available in SAP NetWeaver 7.30 Enterprise Portal .
But in SAP NetWeaver 7.0 Enterprise Portal that interface is not available.
INavigationService is available there.
But didn't get any proper discussion on this interface for the same requirement.
Can you please help me.
Thanks & Regards,
Patralekha -
How to get the VARIANT name in the program
Hi Guys,
Can somebody tell me how to get the VARIANT name in a program.
I have to perform some code with specific variant only. So I want to check in program which variant has been used to call the program.
Thanks,Hi,
Variants are stored in table VARI and VARID.
You can use RS_ALL_VARIANTS_4_1_REPORT to get all the variants for a report program.
please check out the link below it will be helpful to you
Re: Programs for a transaction variant
Hope this helps.
ashish
Maybe you are looking for
-
Cannot access backup made before last iOS update
This past Saturday (the 16th) I plugged my iPhone into my computer for it to get the latest update. It showed it was backing up then went on to do the update. It was taking forever so I left to get dinner. Came back and the phone was bricked. No erro
-
API TO MIGRATE PERSON FROM ONE BUSINESS GROUP TO THE OTHER
Good afternoon guys, Please can I have a sample API to move a person from a business group to another. Thanks for your response. Warmest regards, Olivet
-
I'm trying to install iTunes64Setup.exe (10.7.0.21) version on my Windows 7 system and nothing happens with I try to run the exe. If I run as admin, I get the UAC dialog andclick ok - and nothing happens after that. When I downloaded the exe, I went
-
Report 9i like PDF instead of CSV
Hi, i'm launching my report (on ORACLE 9iAS) on the web and even if i had set up in the form DESFORMAT = DELIMITED and even if i had set up in the report DEFORMAT = DELIMITED when i call my report from the web i obtain a PDF file.... but when i try t
-
Alright, I have a bit of a situation here. I'm wanting to get an iPhone to manage everything. All of my music, photos and videos are on my MacBook Pro at home. I also have email there as well. At work, we use Windows XP, Office 2004 and 2007. Is it p