Making XSD element name match the column name/header
The XML format of the answer I created looks like the following. How can I change the element name from C0, C1... to real column name? http://host:port/analytics/saw.dll?Go&searchid provided the XML
<?xml version="1.0" encoding="utf-8" ?>
- <RS xmlns="urn:schemas-microsoft-com:xml-analysis:rowset">
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:saw-sql="urn:saw-sql" targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset">
- <xsd:complexType name="R">
- <xsd:sequence>
<xsd:element name="C0" type="xsd:double" minOccurs="0" maxOccurs="1" saw-sql:type="double" saw-sql:displayFormula=""CUSTOMERS"."SALES"" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="CUSTOMERS" saw-sql:columnHeading="SALES" />
<xsd:element name="C1" type="xsd:string" minOccurs="0" maxOccurs="1" saw-sql:type="varchar" saw-sql:displayFormula=""CUSTOMERS"."CITY"" saw-sql:aggregationRule="none" saw-sql:aggregationType="nonAgg" saw-sql:tableHeading="CUSTOMERS" saw-sql:columnHeading="CITY" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
- <R>
*<C0>0.3</C0>*
*<C1>WILLITS</C1>*
</R>
Edited by: user732932 on Jan 7, 2010 11:38 AM
OR is there a way to pass the column headers from OBIEE to a URL? For example, session parameters can be passed using @{parmName}
Similar Messages
-
Alias name for the column name in Prompt
Hi,
I have a scenario where I am taking column names into prompt. I have used the following SQL in the SQL results under "Show" option of the Prompt.
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' END FROM " Real Time"
UNION ALL
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' END FROM "Real Time"
My problem here is I am getting the column names into the Prompt as "Orders"."By OrderDate" and "Orders"."By ShipDate", which is not acceptable and readable for mat for the user. Is there any way that I can assign an alias name for the column name such as OrderDate and ShipDate in the above SQL.
Your quick respose is appreciated.
Thanks,
Ramahi,
try an alternative one....in your administrator make new columns with alias to ones you want...so you wiil be able to show whatever you want.
Otherwise,is it possible to show
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By OrderDate"' as "xxxxxxxxxxxxx"END FROM " Real Time"
UNION ALL
SELECT CASE WHEN 1=0 THEN AGE.AGE ELSE '"Orders"."By ShipDate"' as "yyyyyyyyyyyyyyyy"END FROM "Real Time"
Ending,you want the data from your columns?or just the name??
hope i helped...
http://greekoraclebi.blogspot.com/ -
How to change the name of the column for dynamic query
I would like to change the name of the column name to bidderone, biddertwo and bidderthree. the only problem is the vendors name unknown when I run the query and sometimes the query returns two vendors. the maximum vendor is three. here is the query and please let me know how this can be done. thank you so much. I am using oracle 10i
FOR lv_rec IN ( SELECT vendor, calcbtot
FROM (SELECT t.*, ROW_NUMBER () OVER (ORDER BY t.calcbtot Asc) rn
FROM ( SELECT DISTINCT
s.vendor,
TO_CHAR (s.calcbtot, '999,999,999.00') calcbtot
FROM bidtabs b, bidders s
WHERE b.CALL = s.CALL
AND b.letting = s.letting
AND b.vendor = s.vendor
AND b.letting = v_letting
AND b.CALL = v_call
ORDER BY 2) t)
WHERE rn <= 3 )
LOOP
lv_sql :=
lv_sql || ', TO_CHAR(MAX(DECODE(TRIM(S.VENDOR),'''|| TRIM (lv_rec.vendor) || ''', S.BIDPRICE)), ''$999,999,999.00'') AS "'|| TRIM (lv_rec.vendor) ||'" ';
END LOOP;thank you so so much for your help on this. I am sorry i did not post the entire code. my intention is to use bidderone, biddertwo,bidderthree as a column name insead of the name of the vendors and also calcuate the average of the three vendors. the maximum vendor will be three but the minumum could be one or two. hope this is enought information to help me out further . thank you
CREATE OR REPLACE PROCEDURE biddersquoteforbridge (
p_spnumber IN VARCHAR2,
p_result OUT sys_refcursor
IS
v_letting VARCHAR2 (40);
v_call VARCHAR2 (40);
lv_sql VARCHAR2 (32767) := NULL;
BEGIN
SELECT DISTINCT L.LETTING, CALL
INTO v_letting, v_call
FROM LETPROP L, PROPOSAL P
WHERE L.LCONTID = P.CONTID AND CPROJNUM= p_spnumber;
lv_sql :=
'SELECT O.PRPITEM "Item Number",
INITCAP(FUNC_GET_ITEM_DESCRIPTION(O.PRPITEM)) "Description",
O.CONTID "Contract Id",O.SECTION "Section" , P.CPROJNUM "SP Number", P.CFACSSUP "District",
FUNCT_GET_SECTION_IDENTIFIER(O.SECTION, O.CONTID) "Section Title", ''Q''||(TO_CHAR(D.DATELET, ''Q-YYYY'')) "Quarter",
O.IPLINENO "Line Number", O.QTY "Quantity" ';
FOR lv_rec IN ( SELECT vendor, calcbtot
FROM (SELECT t.*, ROW_NUMBER () OVER (ORDER BY t.calcbtot Asc) rn
FROM ( SELECT DISTINCT
s.vendor,
TO_CHAR (s.calcbtot, '999,999,999.00') calcbtot
FROM bidtabs b, bidders s
WHERE b.CALL = s.CALL
AND b.letting = s.letting
AND b.vendor = s.vendor
AND b.letting = v_letting
AND b.CALL = v_call
ORDER BY 2) t)
WHERE rn <= 3 )
LOOP
lv_sql :=
lv_sql || ', TO_CHAR(MAX(DECODE(TRIM(S.VENDOR),'''|| TRIM (lv_rec.vendor) || ''', S.BIDPRICE)), ''$999,999,999.00'') AS "'|| TRIM (lv_rec.vendor) ||'" ';
END LOOP;
lv_sql :=
lv_sql
|| '
FROM PROPITEM O ,
PROPOSAL P ,
LETPROP L ,
BIDDERS B ,
BIDTABS S ,
BIDLET D
WHERE O.CONTID = P.CONTID
AND P.CONTID = L.LCONTID
AND L.CALL = B.CALL
AND L.LETTING = B.LETTING
AND B.CALL = S.CALL
AND B.LETTING = S.LETTING
AND B.VENDOR = S.VENDOR
AND S.IPLINENO = O.IPLINENO
AND L.LETTING = D.LETTING
AND O.LINEFLAG =''L''
AND L.LETTING = :B1
AND L.CALL = :B2
GROUP BY
O.CONTID,
O.SECTION,
O.IPLINENO,
O.PRPITEM,
O.QTY,
P.CPROJNUM,
P.CFACSSUP,
O.PRICE ,
D.DATELET
ORDER BY O.IPLINENO ';
-- DBMS_OUTPUT.put_line (lv_sql);
OPEN p_result FOR lv_sql USING v_letting, v_call;
END; -
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 -
Name of the column not displayed
Hi,
My query is made on the Data Provider that has the following fields:
- Notification Numbers(which I get directly from the Data Provider)
-Status ('ACT' for Active and 'INACT' for Inactive)
Now, my report should show:
- Count of all Notification Numbers(which I have avhieved through replacement path)
- Count of non-confimed Notification Numbers; which is the 'Count of all Notification Numbers' for which the status is INACT.- I have tried achieveing this by making a Restricted KF on the 'Count of all Notification Numbers'. However, the problem is that when this is displayed in the Report, it does not show the name of the column.
Need help!
Thx!Hi,
Just select your restricted keyfigure and hit general tab under that description will be there---Enter your desired description there.
I hope it helps.
Regards
AL -
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. -
Select the name of the column from sheet Excel
Hi everyone,
i use vb.net with excel
First, i have a button "browse"
which open a workbook.
Second ,i have a button "get
the names of the sheets" which give me the name of the sheet in a combobox ,then i choose the sheet.
Then i have an other button " get
the column names " which give me the name of the columns of the table in a combobox .
When i select the name of the column a new sheet add named the
name of the column and which has the data of this column
what i want is :
when i select again the same column a messagebox will
be shown "you have already select it "
And when i go back to choose another sheet then another column
will be open without getting any error
this is the code of the combobox :
Public Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
xlWorkSheet = CType(xlWorkBook.Sheets(ComboBox1.Text), Excel.Worksheet)
xlWorkSheet.Activate()
xlApp.Visible = True
With xlWorkSheet
Dim key As String = CStr(DirectCast(ComboBox2.SelectedItem, KeyValuePair(Of Integer, String)).Key)
Dim value As String = DirectCast(ComboBox2.SelectedItem, KeyValuePair(Of Integer, String)).Value
Dim lastrow As Integer = xlWorkSheet.Cells.Rows.End(XlDirection.xlDown).Row
Dim colletter As String = ColumnIndexToColumnLetter(CInt(key))
exWS2 = DirectCast(xlWorkBook.Sheets.Add, Microsoft.Office.Interop.Excel.Worksheet)
exWS2.Name = value
xlWorkSheet.Range("A1:A" & lastrow.ToString).Copy(exWS2.Range("A1"))
End With
End Sub
and if you want to know the code of the button here is :
Public Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim Excols As New Dictionary(Of Integer, String)
xlWorkSheet = CType(xlWorkBook.Sheets(ComboBox1.Text), Excel.Worksheet)
xlWorkSheet.Activate()
If ComboBox2.Items.Count = Nothing Then
With xlWorkSheet
Dim LastCol As Integer = xlWorkSheet.Cells(1, xlWorkSheet.Columns.Count).End(XlDirection.xlToLeft).Column
For x As Integer = 2 To LastCol
Excols.Add(x, xlWorkSheet.Cells(1, x).value.ToString)
Next
ComboBox2.DataSource = New BindingSource(Excols, Nothing)
ComboBox2.ValueMember = "Key"
ComboBox2.DisplayMember = "Value"
AddHandler ComboBox2.SelectedIndexChanged, AddressOf ComboBox2_SelectedIndexChanged
End With
Else
MsgBox("Déja Pleine!", CType(MessageBoxIcon.Error, MsgBoxStyle))
End If
End Sub
please help meHi
>> when i select again the same column a message box will be shown "you have already select it
Each time you select a value in the comobox , you could compare
each cell’s value with the value you just selected in the first row. If it is matched, then show the message box" you have already select it "
>>And when i go back to choose another sheet then another column will be open without getting any error
I am not sure the sentence’s meaning clearly, What do you mean about another column will be open? what's the error , Can you clarify this more
clear?
Best Regards
Lan
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey. -
Help to extract the Column Name depending on the row values
Hello All,
I have a table with below format
Table Name: Employees
Emp Name Monday Tuesday Wednesday Thursday Friday Saturday
John yes NULL yes yes NULL NULL
Michael NULL yes NULL yes yes NULL
Smith NULL yes yes NULL yes yes
In the above I have explicitly mentioned NULL just for better understanding.
I am trying to send an email using HTMLDB_MAIL.SEND which will have the body as following
"John is absent on Tuesday, Friday and Saturday
Michael is absent on Monday, Wednesday and Saturday
Smith is absent on Monday and Thursday"
I am trying to do this using cursor, fetching each row and matching the value with NULL. But I am not able to display the column name.
Can somebody please help me?
Regards,
RS.
Edited by: user8966924 on Jan 24, 2013 4:35 AMHi,
just use Peter's query, collect into a nested table the output and create one CLOB variable from collection to use it as a body:
create or replace function getbodyemp
return clob
is
p_body_out clob;
type tp_tbemp is table of varchar2 (100);
v_tbemp tp_tbemp;
begin
-- collect the output into a nested table
with employees as
select 'John' Emp_Name , 'yes' Monday, null Tuesday, 'yes' Wednesday, 'yes' Thursday, null Friday, null Saturday from dual union all
select 'Michael' Emp_Name , null Monday, 'yes' Tuesday, null Wednesday, 'yes' Thursday, 'yes' Friday, null Saturday from dual union all
select 'Smith' Emp_Name , null Monday, 'yes' Tuesday, 'yes' Wednesday, null Thursday, 'yes' Friday, 'yes' Saturday from dual
select
e.emp_name || ' is absent on ' ||
replace (trim( ',' from nvl2(monday,null, 'Monday')
|| nvl2(Tuesday,null, ',Tuesday')
|| nvl2(Wednesday,null, ',Wednesday')
|| nvl2(Thursday,null, ',Thursday')
|| nvl2(Friday,null, ',Friday')
|| nvl2(Saturday,null, ',Saturday')), ',', ', ') txt
bulk collect into v_tbemp
from
employees e
where
monday is null
or tuesday is null
or wednesday is null
or thursday is null
or friday is null
or saturday is null
for i IN 1 .. v_tbemp.count
loop
p_body_out := p_body_out || v_tbemp(i) || chr(10);
end loop;
return p_body_out;
end getbodyemp;
select getbodyemp() from dual;
GETBODYEMP()
John is absent on Tuesday, Friday, Saturday
Michael is absent on Monday, Wednesday, Saturday
Smith is absent on Monday, Thursday
1 row selected.Regards.
Al -
Oracle 10g - Defining the column name in Non English
Hi Experts,
I have an exisitng application which is developed on Windows using ASP Technology and uses Oracle 10g 10.1.0.2.0.
The application is supported with an instance of Data Base within which multiple tablespaces are created for different clients. The application is developed in such a way that some of the tables arecreated dynamically and the columns are named using the data entered through the UI.
This application needs to be globalized now. The problem is, the column name entered through the UI can be in any language based on the client's settings and those values in turn will be used for naming the columns in the tables.
1) Can I have the column names to be named using non english characters in Oracle 10g DB? If so,
1.1) what should I do to configure the exisiting Oracle instance to support it?
1.2) To what level is that configuration possible, is it per DB instance level (or) can it be done at Tablespace level. I would like to configure each tablespace to host tables with columns defined with different languages, say for example, tablespace 1 will have tables with Japaenese column names and tablespace 2 will have tables with German column names?
2) What should I do to make my entire DB to support unicode data i.e., to accept any language strings. Currently all strings are declared as VarChar2, should I change all VarChar2 to NVarChar2 (or) is there a way to retain the VarChar2 as is and make some database wide setting?
Please note that I do not have an option of retaining the column in English as per the Business Requirement.
Envionment:
OS - Windows 2003 32 bit
Oracle 10g 10.1.0.2.0
UI forms in ASP
TIA,
Prem1. Yes, you can.
SQL> create table ÜÝÞ( ßàá number(10));
Table created.
SQL> insert into ÜÝÞ values (10);
1 row created.1.1 and 1.2 and 2. You can choose UTF as your default character set. It allows the user of non-English characters in VARCHAR columns in your whole database. It is not per tablespace.
SQL> create table ÜÝÞ( ßàá varchar2(100));
Table created.
SQL> insert into ÜÝÞ values ('âãäçìé');
1 row created. -
Need help on getting the column names of Tabletype
I have a table Mapping with the following values: This Mapping table contains the table names (in Tabname) and the column names(colname) of various tables and values(ValuesTobeFilled) for the columns.
I have to insert into the tables present in the Tabname field with the values present in the ValuesTobeFilled in the columns present in the Colname field.
Note: The Mapping table need not contain all the columns of the base table. The columns that are not present can be filled with null. And this mapping table is not fixed i.e. rows can be inserted/deleted frequently.
Sample values in mapping table:
Tabname Colname ValuesTobeFilled
sample_items Eno Corresponding Expression to get the values from XML input
sample_items Ename Corresponding Expression to get the values from XML input
XXX YYY Corresponding Expression to get the values from XML input
Before filling in the actual tables, I have to store the entire data temporarily and I have used a tabletype declared as follows:
TYPE T_sample_items IS TABLE OF sample_items%ROWTYPE INDEX BY BINARY_INTEGER;
l_sample_items T_sample_items;
Where the table sample_items have the following columns:
• Eno
• Ename
• Eaddress
• Eemail
So, the tabletype should be filled as:
Eno Ename Eaddress EEmail
1 XXX - -
I have declared a cursor to select the values from mapping table and I need to fill in the ValuesTobeFilled values to the corresponding table.
CURSOR c_xpath (c_tname mapping.TABNAME%type)
IS
select * from mapping where tabname = c_tname;
CURSOR c_tables
IS
SELECT DISTINCT TABNAME FROM mapping;
FOR crsr IN c_tables
LOOP
p_tname := CRSR.TABNAME;
FOR csr IN c_xpath(p_tname)
LOOP
IF l_xml_doc.EXISTSNODE(CSR.XPATH_EXP) = 1
THEN
l_node_value := l_xml_doc.extract(CSR.XPATH_EXP).getStringVal(); -- This is the value to be stored in the corresponding column
ELSE
l_node_value := NULL;
END IF;
IF CSR.COLUMN_NAME = ‘eno’
THEN
l_sample_items(1).eno := l_node_value;
ELSIF CSR.COLUMN_NAME = ‘ename’
THEN
l_sample_items(1).name := l_node_value;
END IF;
END LOOP;
END LOOP;
And I need to eliminate hard coding while comparing the column names (in the following piece of code) as the Mapping table values are subject to insertion/deletion:
IF CSR.COLUMN_NAME = ‘eno’
THEN
l_sample_items(1).eno := l_node_value;
ELSIF CSR.COLUMN_NAME = ‘ename’
THEN
l_sample_items(1).ename := l_node_value;
END IF;
I need to insert the values directly into the tabletype without this hardcoding. Please suggest me ways to compare the mapping table values with the field (column) names of the tabletype. If it is not possible using tabletype, please suggest any other ways of fixing the problem.
Many thanks,
GopiI take it this isn't going to be a serious production system at the end of the day?
Storing metadata in tables for extraction and insertion of data is just wrong in so many ways. It smells heavily of Entity Attribute Value modelling, which is the most wrong way to use a relational database and is known to have major performance implications and be liable to bugs and issues. The idea that EAV modelling allows for 'generic' databases where new data items can be added flexibly later on without having to change code is usually justified with an excuse of "it means we don't have to update all our tables when we want a new column" which is easily countered with "if you're adding a single column a good relational design wouldn't require you to add it to more than one table anyway in most cases".
Just what exactly are you trying to do and why? There has to be a better way. -
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 -
How to display the column names of a table in the output
Hi,
I want to display the name of the columns of the table without using literals in a abap report.
EX: Consider the table KNA1
KUNNR NAME ADDRESS
I want to display the column names in the above fashion without using hardcoded write statements.
Thanking in anticipationYou can use this FM <b>DDIF_FIELDINFO_GET</b> It gives you all the names related to fields in a table -:)
Greetings,
Blag. -
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,
BalajiIs 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 -
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
Maybe you are looking for
-
Hi, I am using a pricing procedure which includes the condition type "vprs" for cost. However, my Profit Margin shows the sum of my TOTAL and my COST. Can you advice me on how to rectify this? Thanks and Regards, Aditya
-
Column Containing Partition Key Condition Information
I am using 11.2.0.2 on AIX 6.1. I am creating a range partition table as below. CREATE TABLE SALES_RANGE ( prod_id NUMBER(6) , cust_id NUMBER , time_id DATE , channel_id NUMBER(3) PARTITION BY RANGE (time_id) ( PARTITION
-
Using tracing image, then replacing with background image
I am very new to Dreamweaver, and am trying to put together a very simple site. I am using a tracing image for the layout table mode – and am tracing it exactly. However, when I out put it to test in my browser, nothing lines up how it shows in my wo
-
SRM, BBP_SC_TRANSFER_GROUPED Auto grouping by Plant
Hi, We have a requirement to add Plant as a grouping criteria in program BBP_SC_TRANSFER_GROUPED to combine requisition in SRM system. The standard logic only does the grouping based on Vendor and Purchasing group. Do you know any solution to the abo
-
Hi all, I am designing a form.I have three main windows in this form. I have the following code in the text editor for thre windows. /: box frame 10 tw when I check the layout of the form I can see the box only in the main window 00 but not in main w