Need to know the column names in my dynamic select clause
Dear All,
Please go through the following code. While executing the following code i am getting an error saying that dbms_sql.describe_columns overflow, col_name_len=35. Use describe_columns2.
Please guide me how to proceed further. Or please help me, how can i get the column names when i issue a dynamic select clause.
DECLARE
CUR INTEGER;
COL_CNT INTEGER ;
A INTEGER;
SEL_CLAUSE VARCHAR2(2000);
DESC_T DBMS_SQL.DESC_TAB;
REC DBMS_SQL.DESC_REC;
b number;
BEGIN
SEL_CLAUSE := 'SELECT 1,2,DECODE(1,1,''ONE'',2,''TWO'',3,''THREE'') FROM DUAL';
--'SELECT ROWID,PARA_SUB_CODE,DECODE('||''''||'ENG'||''''||','||''''||'ENG'||''''||',PARA_NAME,PARA_BL_NAME),NULL,NULL FROM PCOM_APP_PARAMETER';
--'SELECT 1,2,DECODE(1,1,''ONE'',2,''TWO'') FROM DUAL';
DBMS_OUTPUT.PUT_LINE( SEL_CLAUSE );
CUR := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(CUR,SEL_CLAUSE,DBMS_SQL.NATIVE);
DBMS_SQL.DESCRIBE_COLUMNS(CUR,COL_CNT,DESC_T);
B := desc_t.first;
FOR J IN 1..COL_CNT
LOOP
DBMS_OUTPUT.PUT_LINE('J := '||J || ' COL CNT ' || COL_CNT);
END LOOP;
BEGIN
A := DBMS_SQL.EXECUTE(CUR);
EXCEPTION
WHEN OTHERS THEN
NULL;
END;
END;
Regards,
Balaji
Is there any way can i have it directly??It does not work with static SQL either. Dynamic SQL is no different.
SQL> select 1 x from dual where x = 1 ;
select 1 x from dual where x = 1
ERROR at line 1:
ORA-00904: "X": invalid identifier
SQL>As suggested already, you will need to use alias if you want your select expression to be referred in the where clause.
SQL> BEGIN
2 FOR rec IN (SELECT *
3 FROM (SELECT 1,
4 2,
5 DECODE(1, 1, 'ONE', 2, 'TWO', 3, 'THREE') "DECODE(1, 1, 'ONE', 2, 'TWO', "
6 FROM DUAL)
7 WHERE "DECODE(1, 1, 'ONE', 2, 'TWO', " = 'ONE')
8 LOOP
9 NULL;
10 END LOOP;
11 END;
12 /
PL/SQL procedure successfully completed.
SQL>Message was edited by:
Kamal Kishore
Similar Messages
-
How To Know The Column Name Of The Internal Table
HI ,
i have an internal table .
f1 f2 f 3 f4 f5
matnr mbrsh mtart meins minbe
i want to know the column name which depending on the value i.e . if it is matnr then f1 , if mbrsh it is f2 ..so on
Thanks.Hi ,
thanks for your replies . i am elaborating my query .
I have an internal table with 80 fields i.e.f1,f2,f3......f80 . In the first index i will be having the fieldnames
i.e.matnr , mbrsh , meins , mtart ..... . From second index onwards i will be having the corresponding data for the field name. i need to display a particular field in a table control . Here i will be knowing the fieldname. If i can get to know the column name i.e whether f1 or f2 or ... .i Can populate the data into the table control.
Wht i have done is taken a field symbol and used the following code.
read table i_upload index 1 assigning <lv_upload>.
here i will get the initial first record i.e
F1 MATNR
F2 MBRSH
F3 MTART
F4 WERKS
F5 LGORT
F6 VKORG
F7 VTWEG
F8 MAKTX
F9 MEINS
F10 MATKL
F11 BISMT
F12 BRGEW
F13 GEWEI
F14 NTGEW
F15 GROES
F16 KLART
F17 CLASS
F18 SPART
F19 VRKME
F20 UMREN
now i want to the field name .
Hope it is clear this time .
Thanks. -
How to know the column name using the index name for a particular table
Hi All,
I have small query regarding, I have index name and table name so by using this how can I know the column name associated with that index of that particular table specific to Oracle9i.
Thanks
Sudheerselect *
from user_ind_columns -- or all_ind_columns
where table_name = UPPER('&table_name')
and index_name = UPPER('&index_name');
Regards
Arun
Gurgaon -
How to know the Column name which contains some value?
Suppose if a table contains 30 columns, and I want to know the name of the Column that contains my search text(Value).
For Eg. I have a Table named Allowances contains 20 columns for referencing 20 types of allowances. The columns are named like Allw_1,Allw_2,...etc..I know the allowance name(Like "Incentive") and I want to know the Column name on which this allowance name presents.
Pls. help me.Change your DB model.
A Table with columns called allw_1, allw_2, ... begs to be normalized. -
Need to know the exact name and P/N of a spare part, cannot find it anywhere.
Hello,
I would like to know the exact name and P/N of the -Touch Panel Control Assembly- for the HP Pavilion dv3510nr?.
or is it -Touch Panel Kit-?
or is it -Multimedia Touch Control Panel-?
Recently, mine got physically damaged and none of the touch buttons work, I cannot even turn the WiFi on. So I need to replace it, but I cannot find this spare part anywhere.
It does not appear on the list of spare parts for this laptop, with any of those names.
Does anybody know where can I find this spare part?
Thanks very much.
GlendyIn case it was not very clear, the spare part that I am referring to is the panel placed above the keyboard, that has touch sensitive buttons for multimedia functions and for enabling the wireless device.
Buttons appear In this order:
MediaSmart button
Audio on/off button
Volume control
Skip backward button
Play/Pause button
Skip forward button
Stop button
WiFi enable/disable
Glendy -
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 -
Dynamically Pass the Column Name cursor. || Dynamic Column Name
Hi,
I need to dynamically pass the column name based on a Mapping table in a loop ( Right now i have hardcoded stuff )just like using Execute immediate.... Inside the procedure, I have commented as where i hit the problem.
Thanks for all of your time...
Thanks
Muthu
CREATE OR REPLACE PROCEDURE xml_testing_clob AS
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
user_node xmldom.DOMNode; item_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
item_elmt xmldom.DOMElement;
item_text xmldom.DOMText;
item_test xmldom.DOMText;
nodelist xmldom.DOMNodeList;
sub_variable varchar2(4000);
x varchar2(200);
y varchar2(200);
sub_var varchar2(4000);
CURSOR get_users IS
SELECT FIRST_NAME,LAST_NAME,ROWNUM FROM USER_INFO_TBL WHERE WEIN_NUMBER = '1234' ;
CURSOR get_cdisc_name IS
select CTS_COL_NAME,CDISC_NAME from CTS2CDISC_DICTIONARY where CTS_TABLE_NAME = 'USER_INFO_TBL';
BEGIN
-- get document
doc := xmldom.newDOMDocument;
doc := xmldom.NewDomDocument;
xmldom.setVersion(doc, '1.0');
xmldom.setStandalone(doc, 'no');
xmldom.setCharSet(doc, 'ISO-8859-1');
-- create root element main_node := xmldom.makeNode(doc);
root_elmt := xmldom.createElement(doc,'AdminData');
root_node := xmldom.appendChild(main_node,xmldom.makeNode(root_elmt));
FOR get_users_rec IN get_users LOOP
item_elmt := xmldom.createElement(doc,'User');
xmldom.setAttribute(item_elmt,'OID' , get_users_rec.rownum);
user_node := xmldom.appendChild(root_node,xmldom.makeNode(item_elmt));
FOR cv_get_cdisc_name IN get_cdisc_name LOOP
EXIT WHEN get_cdisc_name%NOTFOUND;
sub_var := cv_get_cdisc_name.cts_col_name;
sub_variable := 'get_users_rec.';
sub_variable := 'get_users_rec.'||cv_get_cdisc_name.cts_col_name;
x := sub_variable;
dbms_output.put_line(x); -------------- Here i just see the literal string
y := get_users_rec.FIRST_NAME;
dbms_output.put_line(y); -------------- Here i just see actual value ( data )
item_elmt := xmldom.createElement(doc,cv_get_cdisc_name.cdisc_name);
item_node := xmldom.appendChild(user_node,xmldom.makeNode(item_elmt));
item_text := xmldom.createTextNode(doc,x ); ---- This is the place i am hitting with an error .
If i use variable X then i am able to see only the literal
string in the output. BUT if i put cursor name.coulmname,
then the resumt (XML) is fine.I wanted acheive this
dynamically just like execute Immediate
item_node := xmldom.appendChild( item_node , xmldom.makeNode(item_text));
END LOOP;
END LOOP;
-- write document to file using default character set from database
xmldom.WRITETOCLOB(doc,);
xmldom.writeToFile(doc, 'c:\ash\testing_out.xml');
-- free resources
xmldom.freeDocument(doc);
END;
+++++++++++++++++++++++++++++++++++ XML OUTPUT +++++++++++++++++++++++++++++++++++++++++
<?xml version="1.0" ?>
- <AdminData>
- <User OID="1">
<FirstName>get_users_rec.FIRST_NAME</FirstName>
<LastName>get_users_rec.LAST_NAME</LastName> </User>
- <User OID="2">
<FirstName>get_users_rec.FIRST_NAME</FirstName>
<LastName>get_users_rec.LAST_NAME</LastName>
</User>
- <User OID="3">
<FirstName>get_users_rec.FIRST_NAME</FirstName>
<LastName>get_users_rec.LAST_NAME</LastName>
</User>
- <User OID="4">
<FirstName>get_users_rec.FIRST_NAME</FirstName>
<LastName>get_users_rec.LAST_NAME</LastName>
</User>
- <User OID="5">
<FirstName>get_users_rec.FIRST_NAME</FirstName>
<LastName>get_users_rec.LAST_NAME</LastName>
</User>
++++++++++++++++++++++++++++++++++++++++++++++++++++ MAPPING TABLE DETAILS +++++++++++++++++
CTS_COL_NAME CDISC_NAME CTS_TABLE_NAME XML_TAG -----------> Column Name
FIRST_NAME FirstName USER_INFO_TBL Element -----------> Records
LAST_NAME LastName USER_INFO_TBL Element -----------> RecordsMy scenario is little different, let me explain:
My columns will remain same but values changes (based on column formula) according to the selected prompt value
If I select 'Oct' from prompt then
Curr will contain data for 'Oct' only
Next1 will contain data for 'Nov' only
Next2 will contain data for 'Dec' only
Next3 will contain data for 'Jan' of next year only.
Later if I select 'Jul' from prompt then
Curr will contain data for 'Jul' only
Next1 will contain data for 'Aug' only
Next2 will contain data for 'Sep' only
Next3 will contain data for 'Oct' only.
I don't have different columns for each months but the columns are capable to reflect data for any month.
So, how can I reflect the column name as month name for which that contains data.
Regards,
S Anand -
Can the column names be changes dynamically in OBIEE presentation
Hi,
Is thr any way through which I can change the column names depending on the value of a column.
the table structure is
Plan_name Character1 Character2 Character3 ....
so here according to plan_name the meaning of each character column changes. And I want to display each type of meaning on the presentation layer.
I cannot create aliases as the number of different plan name is 1200.
Any help will be appreciated.
Regards,
Akansh AgarwalHi,
I haven't tested these options, but you might. Maybe you try to supress the header for your table with data. After that, create a second table, which will be used as the header, and insert the same number of columns as the first table.
So on the 'header' table, create a conditional style (Criteria, Column Properties, Conditional Formatting), pointing to the values on shown in the first table. (You maybe need the data to be queried in both).
If this does't work, you can try to adapt the javascript shown in this blog: DELIVER BI OBIEE 11g &amp; 10g , ODI , OBIA: OBIEE Table make a row BOLD with JAVA
And instead of making the row bold, change the value.
Hope this helps. Sorry if it does't work.
Best regards. -
We use a Bluecoat device that must be authenticated on a time schedule, before a user can browse off site. This breaks the updater on Firefox if the end user has not yet authenticated.
I can add the Firefox update servers or domains to an exclusion list so the Bluecoat will not interfere. I need to know those names.
I did some network sniffing and noticed aus2-mozilla-org.geo.mozilla.com but I assume there are more.Maybe it would be easier to setup a local update server.<br />
See https://developer.mozilla.org/en/Setting_up_an_update_server -
Need to know the program names to which the table is used
Hi,
I am using a table <table1>.
For Example : MARA table. I need to know in what are all the program's the MARA table is used .
Please let me know in which tcode can I know the details.
Thanks,
Karthikhi ,
use program
RS_ABAP_SOURCE_SCAN
passs 'MARA' IN search field
and program name field '*'
will give all program .
regards
Deepak. -
I need to know the department column in Oracle Application
Hi there:
Can somebody tell me how can I get the employee department information from oracle application.
I need to know the table name and column name.
Thanks and regards,
ZeeshanI think this is not the best forum, to ask such a question. One that deals with Oracle Applications would be better suited.
Maybe have a look [url http://forums.oracle.com/forums/forum.jspa?forumID=410]here. Not sure if it is the right one. -
Need to create a dynamic caption(column name) in a dynamic table
Hi All,
I have created dynamic table .But the dynamic column is not showing.I have created two column name that is name and empId .I have tried with following code
IWDCaption nameCap=(IWDCaption)view.createElement(IWDCaption.class,"nameCap");
nameCap.setText("Name");
tabColumn1.setHeader((IWDCaption)nameCap);
IWDCaption addCap=(IWDCaption)view.createElement(IWDCaption.class,"addCap");
addCap.setText("Address");
tabColumn2.setHeader((IWDCaption)addCap);
I m getting internal server error...But When i m comented the above code i can able to see tha dynamic table withput column name..Can anyone help me
SumanHi
IWDTableColumn tabColumn1 = (IWDTableColumn)view.createElement(IWDTableColumn.class,"N_Co");
IWDTableColumn tabColumn2 = (IWDTableColumn)view.createElement(IWDTableColumn.class,"A_Co");
IWDInputField nameText = (IWDInputField)view.createElement(IWDInputField.class,"N_Text");
nameText.bindValue(attrib1);
tabColumn1.setTableCellEditor((IWDTableCellEditor)nameText);
IWDInputField addText = (IWDInputField)view.createElement(IWDInputField.class,"A_Text");
addText.bindValue(attrib2);
tabColumn2.setTableCellEditor((IWDTableCellEditor)addText);
<b>I need to see the column name.....</b>
for that i have written the following code...
while writting the following code i m getting internal server error
IWDCaption nameCap = (IWDCaption)view.createElement(IWDCaption.class,"nameCap");
nameCap.setText("contribution_area");
tabColumn1.setHeader((IWDCaption)nameCap);
IWDCaption addCap=(IWDCaption)view.createElement(IWDCaption.class,"addCap");
addCap.setText("SUM");
tabColumn2.setHeader((IWDCaption)addCap); -
Displaying the column names in a spreadsheet
Hello All,
I am downloading data from SAP into a spreadsheet using the FM MS_EXCEL_OLE_STANDARD_DAT. The data is coming fine.
But I need to display the column names too in the spreadsheet. Could anyone please tell me how to do that.
Thanks in advance.
Regards
IndrajitHi Pawan,
I am using the following piece of code.
TYPES: BEGIN OF ty_fieldname,
text(20) TYPE c,
END OF ty_fieldname.
DATA: gs_fieldname TYPE ty_fieldname.
gt_fieldname TYPE STANDARD TABLE OF ty_fieldname.
gs_fieldname-text = 'Material'.
APPEND gs_fieldname TO gt_fieldname.
gs_fieldname-text = 'Ad Size'.
APPEND gs_fieldname TO gt_fieldname.
gs_fieldname-text = 'Classification Group'.
APPEND gs_fieldname TO gt_fieldname.
gs_fieldname-text = 'Old Ceiling'.
APPEND gs_fieldname TO gt_fieldname.
gs_fieldname-text = 'Message Type'.
APPEND gs_fieldname TO gt_fieldname.
gs_fieldname-text = 'Message'.
APPEND gs_fieldname TO gt_fieldname.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = p_file
data_sheet_name = text-014
TABLES
data_tab = gt_rate
fieldnames = gt_fieldname
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_pivot_fields = 6
download_problem = 7
OTHERS = 8.
I am getting a short dump on this which says -
"Only flat, character-type data objects are supported at the argument
position "dest" for the statement
"WRITE src TO dest".
In this case, the operand "dest" has the non-character-type or deep type
"P". The current program is flagged as a Unicode program. In the Unicode
context, type X fields are seen as non-character-type, as are
structures that contain non-character-type components."
Indrajit -
Hello,
Can anyone help me out to write a vb.net script.
I need to read the column names from excel and based on that column names I need to create a table in database(I have more than one sheet in excel).
For each sheet columns will be changing and should create a table dynamically for each sheet.
Any help would be appreciated.Refer the below script to read columns in each sheet.
Dim excelfile As String = Dts.Variables("ExcelPath").Value.ToString
Dim connectionstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=" + excelfile + ";Extended Properties=Excel 8.0"
Dim oledbcon As New OleDb.OleDbConnection(connectionstring)
oledbcon.Open()
Dim dt As DataTable
Dim schemaTable As DataTable
Dim OLEDBCMD As New OleDb.OleDbCommand
Dim oledbdatareader As OleDb.OleDbDataReader
Dim columns As String = ""
dt = oledbcon.GetSchema("Tables")
Dim TABCOMMAND(20) As String
Dim TABCOUNT As Integer = 0
For Each row As DataRow In dt.Rows
TABCOMMAND(TABCOUNT) = "SELECT * FROM [" & row.Item("TABLE_NAME").ToString & "]"
OLEDBCMD.CommandText = TABCOMMAND(TABCOUNT)
OLEDBCMD.Connection = oledbcon
oledbdatareader = OLEDBCMD.ExecuteReader(CommandBehavior.KeyInfo)
schemaTable = oledbdatareader.GetSchemaTable()
For Each myfield As DataRow In schemaTable.Rows
For Each myproperty As DataColumn In schemaTable.Columns
If myproperty.ColumnName = "ColumnName" Then
columns = columns & myfield(myproperty).ToString & ","
MsgBox(myfield(myproperty).ToString)
End If
Next
Next
oledbdatareader.Close()
OLEDBCMD.Dispose()
Next
oledbcon.Close()
Regards, RSingh -
When double clicking on alv ,want to get the column name
Hello there,
I'm displaying the value of internal table in an alv using Reuse_alv_grid_display method ,using fieldcatalog.I want to know the column name when double clicking on a particular line .If the the fieldname is 'MATNR' then i want to check that column name.
If anybody have any idea plz terply me.
Thanking you neonfor that you have to use the USER_COMMAND event.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
IT_FIELDCAT = it_fcat
TABLES
t_outtab = itab
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
FORM USER_COMMAND using ucomm type sy-ucomm
selfield type slis_selfield.
data: fieldname(30).
case ucomm.
when '&IC1'.
case selfield-fieldname.
when 'MATNR'.
message 'clicked on Matnr' type 'I'.
when 'POSNR'.
endcase.
endcase.
ENDFORM.
Maybe you are looking for
-
Just Updated iTunes/Quicktime and it still won't open...
Ok so I have Windows XP and I went to open iTunes a little bit ago and it told me that iTunes couldnt open because I had Quicktime 7.0 and i needed at least 7.1. So I downloaded a the newer version of iTunes and Quicktime 7.1 or whatever and it still
-
Lumia 520 standard ringtones - demo?
Hi, I have a Lumia 520. From Settings>ringtones&sounds there is a long list of the standard Nokia and Windows ringtones available. But how can I hear a demo of them? I expected that selecting one would either play a demo or give me a demo option t
-
Budget checking for services with "Unlilmited" indicator set
hi friends, Under normal cases, the budget checking is happening properly for the services in a project. But I have certain service activities where I require to set the "Unlimited" indicator set (in the service specification screen)and some other se
-
Is Developer 2000 release 2.1 works under Oracle 9.2.05.
Is Developer 2000 release 2.1 works under Oracle 9.2.0.5. If anyone can answer this will be real help. Thanks in advance.
-
i've never had a mac before so i'm only familiar with windows. i'm getting a laptop for college and i'm considering buying a mac. a couple of my friends have them and they only say good thigns about them. however my dad is really hesitant on me buyin