Column Name in Scrollable RowSet?
Hi,
I have a Scrollable RowSet which included
one column.I need to take the value of this coulmn but i don't know the column name
(obviously the column index is 1).
There is no property for scrollable rowset to take the value where we know the column index. So, how can i take the value?
Thx
Ali
null
Hi,
Correction!!
Since RowsetAccess happens to be the superclass of ScrollableRowsetAccess, all the methods of this class is available to the ScrollableRowsetAccess.
There is a method : getColumnItem(int index),which you could use,if you donot know the name of the column.
So instead of coding, what I had suggested in my previous response, you could try :
ImmediateAccess ia = (ImmediateAccess)rsa.getColumnItem(1);
String s = ia.getValueAsString();
where 1 happens to be the first column in the Rowset.
Ofcourse, you could get count of number of columns in the rowset by coding :
int count = (RowsetAccess)rsa.getColumnCount();
where rsa is object reference of ScrollableRowsetAccess.
Hope this helps,
Sandeep
Similar Messages
-
Simplest way to get column names
i need to retrieve column names in a rowset, let me explain a bit;
i can simply retrieve a column name by using IColumnsInfo::GetColumsInfo, but the problem is when i use "AS" keyword in the select statement such like;
SELECT identification AS id FROM test_table_a
i see alias name of that column instead the internal column name.
as you can guess the qestion is; how can i get both alias and internal name at the same time and of course what is the *usual* way to get it.
thanks in advanceGetting 'real' column names from a table:
Code Snippet
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = N'Products' -
All,
I am a new user of JSC and am hopefully running into a simple issue. I've searched the forums here but so far have not found any postings regarding my problem. Apologies if this has been asked and answered before.
I am building a webapp to display data from a MySQL database. There are several places in the schema where I need to join to the same table multiple times. I have setup the joins in the query builder and also setup a view in the database directly that does the joins. Either way, the query works fine and returns the expected data. The trouble is that the rowset underlying the dataprovider is not returning the metadata using either the table&column aliases from the query builder or the column names from the view, but rather in all cases returning the underlying table and column names. In my table component I am trying to display the data from each table.column alias distinctly but because the metadata visible to the dataprovider is the same (ie table.column), I end up with both table columns showing the same data. I've tried to track down the implementation of the metadata getter method but it is apparently in source that is not provided.
In case it matters, I'm using mysql-connector-java-5.0.3-bin.jar as the driver.
Is there something I'm missing or is there a workaround for this?
Thanks in advance,
ScottThanks,
I should have been more explicit in my description of the problem.
Example of what I have is as follows:
select table1.columnA, table2.columnA as columnX,....
from table_name as table1 join table_name as table2....
where there are other tables and columns in the select clause as well as the join conditions but where the base table and column (in the above table_name.columnA) are used twice with two different aliases. I have done this join directly in the query builder and also created a view, hiding the actual names of the columns. I can execute either query in the query builder and the columns in the result set "spreadsheet" are labeled with the base table column names, not the aliased names or the view's column names. This is causing a problem because the same thing happens when I try to bind the ui:table columns to the dataprovider. It uses the base tables' column names and I have no way to distinguish between the different aliases. If I try to manually change the jsp to refer to the aliased name or the view column name, I get an exception that the aliased tablename and or column is an invalid parameter.
Sorry if that was not clear in my original post. -
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. -
How to find the column name and table name with a value
Hi All
How to find the column name and table name with "Value".
For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
Any help is highly appricatable
Thanks & Regards
Srikkanth.M2 solutions by Michaels (the latter is 11g upwards only)...
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
SQL> select table_name,
column_name,
:search_string search_string,
result
from cols,
xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
columns result varchar2(10) path '.'
where table_name in ('EMP', 'DEPT')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME ES RESEARCH
DEPT DNAME ES SALES
EMP ENAME ES JONES
EMP ENAME ES JAMES
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES PRESIDENT
EMP JOB ES SALESMAN
9 rows selected. -
Creating DOMDocument when column names are not known
I want to make a DOMDocument from a table of which I do not know the column names.
I already got pretty far: I could generate XML elements having the name of each of the columns.
I still have a problem when trying to retrieve the cell values from the table.
The code is below.
The problem I have is situated after the line:
/* QUESTION : HOW DO I REPLACE get_rows.label BY something dynamic, i.e. I want to use the value o col_name as the column name */
I do not know how to retrieve the value from the table but by hardcoding the column name (i.e. get_rows.label where label is a column name). What I want to use is the VALUE of the variable col_name as the column name.
Many thanks in advance.
The code:
set serveroutput on
DECLARE
doc xmldom.DOMDocument;
main_node xmldom.DOMNode;
root_node xmldom.DOMNode;
row_node xmldom.DOMNode;
user_node xmldom.DOMNode;
item_node xmldom.DOMNode;
root_elmt xmldom.DOMElement;
row_elmt xmldom.DOMElement;
item_elmt xmldom.DOMElement;
item_text xmldom.DOMText;
CURSOR DF_ROWS IS SELECT * FROM DF_COUNTRY;
/* get the column names */
CURSOR DF_COLUMNS IS SELECT COLUMN_NAME FROM USER_TAB_COLUMNS WHERE TABLE_NAME = 'DF_COUNTRY';
col_name varchar(20);
cell_value varchar(40);
BEGIN
/* OPEN DF_COLUMNS; */
/* create a DOM document and append a root element */
doc := xmldom.newDOMDocument;
main_node := xmldom.makeNode(doc);
root_elmt := xmldom.createElement(doc, 'ROOT');
root_node := xmldom.appendChild(main_node, xmldom.makeNode(root_elmt));
/* loop over the records */
FOR get_rows IN DF_ROWS LOOP
row_elmt := xmldom.createElement(doc, 'ROW');
/* xmldom.setAttribute(item_elmt, 'num', get_users_rec.rownum); */
row_node := xmldom.appendChild(root_node, xmldom.makeNode(row_elmt));
/* Now loop over all the columns (cells) and create an element for each of them */
FOR get_columns IN DF_COLUMNS LOOP
col_name := get_columns.COLUMN_NAME;
DBMS_OUTPUT.PUT_LINE(col_name);
item_elmt := xmldom.createElement(doc, get_columns.COLUMN_NAME);
item_node := xmldom.appendChild(row_node, xmldom.makeNode(item_elmt));
/* QUESTION : HOW DO I REPLACE get_rows.label BY something dynamic, i.e. I want to use the value o col_name as the column name */
item_text := xmldom.createTextNode(doc, get_rows.label);
item_node := xmldom.appendChild(item_node, xmldom.makeNode(item_text));
END LOOP;
END LOOP;
xmldom.writeToFile(doc, 'C:\ClinCapt\Output\test.xml');
xmldom.freeDocument(doc);
END;I needed to manipulate the XML afterwoods (i.e. combine it with queries to other tables in a single large XML document).Did you try to combine all these subsequent queries into one single query and pass it to the XML packages to generate the XML all at once (instead of doing it in stages).
SQL> select dbms_xmlquery.getxml('select dname,
2 cursor(select empno, ename
3 from scott.emp
4 where rownum < 3) employees
5 from scott.dept where rownum < 3') from dual ;
DBMS_XMLQUERY.GETXML('SELECTDNAME,CURSOR(SELECTEMPNO,ENAMEFROMSCOTT.EMPWHEREROWN
<?xml version = '1.0'?>
<ROWSET>
<ROW num="1">
<DNAME>ACCOUNTING</DNAME>
<EMPLOYEES>
<EMPLOYEES_ROW num="1">
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
</EMPLOYEES_ROW>
<EMPLOYEES_ROW num="2">
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
</EMPLOYEES_ROW>
</EMPLOYEES>
</ROW>
<ROW num="2">
<DNAME>RESEARCH</DNAME>
<EMPLOYEES>
<EMPLOYEES_ROW num="1">
<EMPNO>7369</EMPNO>
<ENAME>SMITH</ENAME>
</EMPLOYEES_ROW>
<EMPLOYEES_ROW num="2">
<EMPNO>7499</EMPNO>
<ENAME>ALLEN</ENAME>
</EMPLOYEES_ROW>
</EMPLOYEES>
</ROW>
</ROWSET>
SQL> -
How can I dynamically specify a Column Name in a Where Clause of a DB
I have a page that query the Database based on the column Name and values entered by the user. on this page I have a drop down list of all the Column names and a text field. The user can choose from any of the dropdown list option to set the column Name and also enter a value.How can I dynamically pass the option choosed by the user from the drop down list to the dataProvider in seesionBean1 as a column Name???Help
Hi,
This is a working example of a search form.
In the JSP page we have several texts box, a table bound to a DataProvider with the rowSet in the SessionBean and a search button.
JSP source:
<ui:body binding="#{PackageAirtime.body1}" id="body1">
<ui:form binding="#{PackageAirtime.form1}" id="form1">
<table border="0">
<tr>
<td>
<table border="0" width="100%">
<tr>
<td>
<ui:label binding="#{PackageAirtime.pageTitle}" id="pageTitle" text="Package Airtime"/>
<br/>
<br/>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="2" cellspacing="2">
<tr>
<td>Package ID:</td>
<td>
<ui:textField binding="#{PackageAirtime.textPackageID}"
id="textPackageID"/>
<ui:button
binding="#{PackageAirtime.buttonPackageID}" id="buttonPackageID"
onClick="handlePackageIDPopup(); return false;" text="..." toolTip="Open package locator"/>
</td>
</tr>
<tr>
<td>Airtime Code:</td>
<td>
<ui:textField binding="#{PackageAirtime.textAirtimeCode}"
id="textAirtimeCode"/>
<ui:button
action="#{PackageAirtime.buttonAirtimeCode_action}"
binding="#{PackageAirtime.buttonAirtimeCode}" id="buttonAirtimeCode"
onClick="handleAirtimeCodePopup(); return false;" text="..." toolTip="Open airtime code locator"/>
</td>
</tr>
<tr>
<td></td>
<td>
<ui:button action="#{PackageAirtime.searchButton_action}" binding="#{PackageAirtime.searchButton}"
id="searchButton" text="Search" toolTip="Search records"/>
</td>
</tr>
</table>
<br/>
<ui:staticText binding="#{PackageAirtime.staticTextSearchResults}" id="staticTextSearchResults"/>
<br/>
<ui:table binding="#{PackageAirtime.searchResults}" id="searchResults" paginationControls="true">
<script>
/* ----- Functions for Table Preferences Panel ----- */
* Toggle the table preferences panel open or closed
function togglePreferencesPanel() {
var table = document.getElementById("form1:table1");
table.toggleTblePreferencesPanel();
/* ----- Functions for Filter Panel ----- */
* Return true if the filter menu has actually changed,
* so the corresponding event should be allowed to continue.
function filterMenuChanged() {
var table = document.getElementById("form1:table1");
return table.filterMenuChanged();
* Toggle the custom filter panel (if any) open or closed.
function toggleFilterPanel() {
var table = document.getElementById("form1:table1");
return table.toggleTableFilterPanel();
/* ----- Functions for Table Actions ----- */
* Initialize all rows of the table when the state
* of selected rows changes.
function initAllRows() {
var table = document.getElementById("form1:table1");
table.initAllRows();
* Set the selected state for the given row groups
* displayed in the table. This functionality requires
* the 'selectId' of the tableColumn to be set.
* @param rowGroupId HTML element id of the tableRowGroup component
* @param selected Flag indicating whether components should be selected
function selectGroupRows(rowGroupId, selected) {
var table = document.getElementById("form1:table1");
table.selectGroupRows(rowGroupId, selected);
* Disable all table actions if no rows have been selected.
function disableActions() {
// Determine whether any rows are currently selected
var table = document.getElementById("form1:table1");
var disabled = (table.getAllSelectedRowsCount()>0)?false : true;
// Set disabled state for top actions
document.getElementById("form1:table1:tableActionsTop:deleteTop").setDisabled(disabled);
// Set disabled state for bottom actions
document.getElementById("form1:table1:tableActionsBottom:deleteBottom").setDisabled(disabled);
}</script>
<f:facet name="title">
<ui:staticText binding="#{PackageAirtime.table1Title}" id="table1Title" text="Package Airtime search results"/>
</f:facet>
<ui:tableRowGroup binding="#{PackageAirtime.tableRowGroup1}"
emptyDataMsg="No records matching the search criteria" id="tableRowGroup1"
sourceData="#{PackageAirtime.s23_package_airtimeDataProvider}" sourceVar="currentRow">
<ui:tableColumn binding="#{PackageAirtime.tableColumn1}" headerText="Package ID" id="tableColumn1" sort="S23_PACKAGE">
<ui:staticText binding="#{PackageAirtime.staticText1}" id="staticText1" text="#{currentRow.value['S23_PACKAGE']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn2}" headerText="Airtime Code" id="tableColumn2" sort="S23_AT_CODE">
<ui:staticText binding="#{PackageAirtime.staticText2}" id="staticText2" text="#{currentRow.value['S23_AT_CODE']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn7}" headerText="Prepaid Value" id="tableColumn7">
<ui:staticText binding="#{PackageAirtime.staticText6}" id="staticText6" text="#{currentRow.value['SUBR_AT_PREPAID_PERIOD_VAL']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn8}" headerText="Prepaid Type" id="tableColumn8">
<ui:staticText binding="#{PackageAirtime.staticText7}" id="staticText7" text="#{currentRow.value['SUBR_AT_PREPAID_TYPE']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn4}" headerText="Start" id="tableColumn4" sort="PRSM_PK_START">
<ui:staticText binding="#{PackageAirtime.staticText3}" id="staticText3" text="#{currentRow.value['PRSM_PK_START']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn5}" headerText="End" id="tableColumn5">
<ui:staticText binding="#{PackageAirtime.staticText4}" id="staticText4" text="#{currentRow.value['PRSM_PK_END']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn6}" headerText="Units" id="tableColumn6">
<ui:staticText binding="#{PackageAirtime.staticText5}" id="staticText5" text="#{currentRow.value['PRSM_PK_UNITS']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn9}" headerText="Carry-over limit" id="tableColumn9" valign="Top">
<ui:staticText binding="#{PackageAirtime.staticText8}" id="staticText8" text="#{currentRow.value['ROM_PLAN_CARRY_LMT']}"/>
</ui:tableColumn>
<ui:tableColumn binding="#{PackageAirtime.tableColumn3}" headerText="Details" id="tableColumn3" width="100">
<ui:hyperlink action="#{PackageAirtime.viewpackageAT_action}" binding="#{PackageAirtime.hyperlink1}"
id="hyperlink1" text="View"/>
</ui:tableColumn>
</ui:tableRowGroup>
</ui:table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ui:form>
</ui:body>
...JAVA source:
public void prerender() {
search_action();
public String search_action() {
try {
String command = "SELECT s23_package, s23_at_code, prsm_pk_start, prsm_pk_end, prsm_pk_units, subr_at_prepaid_period_val, subr_at_prepaid_type, subr_disc_type, subr_disc_rate, subr_disc_value, subr_disc_perm, subr_at_prepaid_bill_per_val, subr_at_prepaid_recurring, s23_package_fwd, s23_at_code_fwd, prsm_pk_start_fwd, subr_ppa_infinite, subr_ppa_carry_over, rom_plan_carry_lmt FROM s23_package_airtime, ROM_23_PPLAN_COMP where rom_23_pack_plan = s23_package";
String where = "";
String packageID = (String)textPackageID.getText();
if (packageID == null) {
packageID = "";
packageID = packageID.replace("'", "''");
if (packageID != "") {
if (where != "") {
where += " AND ";
where += "upper(S23_PACKAGE) LIKE upper('" + packageID + "%')";
String airtimeCode = (String)textAirtimeCode.getText();
if (airtimeCode == null) {
airtimeCode = "";
airtimeCode = airtimeCode.replace("'", "''");
if (airtimeCode != "") {
if (where != "") {
where += " AND ";
where += " upper(S23_AT_CODE) LIKE upper('" + airtimeCode + "%')";
if (where != "") {
command += " AND " + where;
this.getSessionBean1().getS23_package_airtimeRowSet().setCommand(command);
this.staticTextSearchResults.setText(tdi.business.Utils.getRowCountMessage(s23_package_airtimeDataProvider.getRowCount()));
catch (Exception e) {
log("Error during search for packages airtime", e);
return null;
public String searchButton_action() {
search_action();
this.tableRowGroup1.setFirst(0);
return "";
}I put the search_action() call in the prerender() to have data in my table when the page is open. For a large resultset the best aproach is to let the user select some search criteria and then call the search_action() using a button (searchButton_action() ).
I've added a hyperlink column to my table, it is used to display the current record details in a new page.
I have defined in my SessionBean a getRowkey/setRowkey methods.
When the user click on a "View" hiperlink the following code is executed:
public String viewpackageAT_action() {
RowKey row = tableRowGroup1.getRowKey();
this.getSessionBean1().setPackageAirtimeRowKey(row);
return "packageairtime_details";
}I will step over the "Page Navigation".
In the Detail Page I have the following code:
public void init() {
this.s23_package_airtimeDataProvider.setCursorRow(this.getSessionBean1().getPackageAirtimeRowKey());
}Now I have the detail page opened and also the DataProvider opened at the saved RowKey value.
Finally, in the SessionBean:
* Holds value of property packageAirtimeRowKey.
private RowKey packageAirtimeRowKey;
* Getter for property packageAirtimeRowKey.
* @return Value of property packageAirtimeRowKey.
public RowKey getPackageAirtimeRowKey() {
return this.packageAirtimeRowKey;
* Setter for property packageAirtimeRowKey.
* @param packageAirtimeRowKey New value of property packageAirtimeRowKey.
public void setPackageAirtimeRowKey(RowKey packageAirtimeRowKey) {
this.packageAirtimeRowKey = packageAirtimeRowKey;
}Note: You should enable page navigation in the result(s) table.
That's about it :)
Hope this helps,
Catalin Florean. -
Java.sql.SQLException: Invalid column name
hi,
i am using query with join and select column with different aliases,
sqlQuery
SELECT client_data.image as IMAGE, franchise.NAME, franchise.FRANCHISE_ID,
cityH.city_name as h_city,
cityO.city_name as o_city,
cityT.city_name as t_city,
countryH.country_name as h_country,
countryO.country_name as o_country,
countryT.country_name as t_country,
client.* from client_data, city cityH, city cityT, city cityO, country countryH, country countryT, country countryO, client, franchise where
cityH.id = client.home_city and
cityT.id = client.temp_city and
cityO.id = client.office_city and
countryH.id = client.HOME_COUNTRY and
countryO.id = client.office_country and
countryT.id = client.TEMP_COUNTRY and
franchise.franchise_id = client.franchise_id and client_data.client_id = client.id and client.id = ?
while executing that query through JDBC, alias column are not in map like h_city, o_city, t_city are not accessible.
System.out.println("h_city "+rowSet.getString("h_city"));
the exception is java.sql.SQLException: Invalid column name.
Kindly give you valuable comments for that..
Regards,
Kashif BashirHi Balus,
i fixed it by editing jdbc.properties file like
jdbc.url=jdbc:mysql://192.168.100.221:3306/myDb?useOldAliasMetadataBehavior=true
they query is running and returning the whole column i use as allies like h_city (cityH.city_name as h_city).
Thank for your interest.
Kashif Bashir
[email protected] -
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 AMOR is there a way to pass the column headers from OBIEE to a URL? For example, session parameters can be passed using @{parmName}
-
How to rename C00n generic column names in a Dynamic SQL report
I have a an interface whereby the user can select 1 to 60 (upper limit) columns out of 90 possible columns (using a shuttle) from one table before running a report.
To construct the SQL that will eventually execute, I'm using a "PLSQL function body returning SQL query" with dynamic SQL. The only problem is that I have to use "Generic Column Names" option to be able to compile the code and end up with c001 to c060 as the column names.
How can I use the names of the selected columns as the report headings rather than c001, C002... etc?
I do not know beforehand which columns, or how many columns or the order of the selected columns.
I know Denes K has a demo called Pick Columns but I can't access his code. I have a hunch though that he may be just using conditions to hide/show the apropriate columns.
thanks in advance
PaulPHi Paul
I would change the Heading Type in the Report Details screen to PLSQL and use the shuttle item to return the column values. e.g.
RETURN :p1_shuttle;
I'm assuming the shuttle already has a colon separated list of the column headings in the correct order?
I hope that helps
Shunt -
Reading MS Project column names and data on the fly from a selected View
Hi guys,
I have several views on my project file (MSPROJECT 2010) and I want to build a macro so that;
1. User can select any view ( Views can have diffrent columns and the user may add new columns as well)
2. User runs the Macro and all the coulmns along with the tasks displayed in the view will be written to a excel file. ( I don't want to build several macro's for each view, I'm thinking of a common method which would work for any selected view)
The problem I'm facing is that how will i read the column names and data for a particular view on the fly without hard coding them inside the vba code ?
The solution needs to work on a master schedule as well.
Appreciate your feedback.Just to get you started the following code writes the field name and data for the active task to the Immediate window.
Sub CopyData()
Dim fld As TableField
For Each fld In ActiveProject.TaskTables(ActiveProject.CurrentTable).TableFields
If fld.Field >= 0 Then
Debug.Print Application.FieldConstantToFieldName(fld.Field), ActiveCell.Task.GetField(fld.Field)
End If
Next fld
End Sub
Rod Gill
Author of the one and only Project VBA Book
www.project-systems.co.nz -
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. -
What is the order of Column Names in Sqlite query results?
I am writing an application using Adobe Air, Sqlite, and Javascript.
After writing the following select statement:
SELECT field1, field 2, field 3, field 4 FROM TableA;
I would like to get the columnName/data combination from each row -- which I do successfully with a loop:
var columnName="";
for (columnName in selResults.data[i]) {
output+=columnName + ":" + selResultsdata[i][columnName] + ";";
My issue is that the column names come out in a different order every time I run the query and never once have they come out in the desired order -- field 1, field 2, field 3, field 4. If I run the query in Firefox's Sqlite Manager, the columns come out in the "proper" order. When I run them in Adobe Air, the order will be the same if I run the query mulitple times without closing the app. If I make a change such as declaring the columnName variable with "" before the for column, or declare it as (var = columnName in selResults.data) , then the order changes. If I shut down my app and re-open after lunch and run query, it comes out in another order. At this time, I'm not interested in the order of the rows, just the order of the columns in each output row. I've even tried assiging an index to columnName which seems to just pick up a single letter of the columnName.
I'm in the process of changing my HTML presentation of the data to assign a precise columnName to an HTML table title, but I'm reluctant to let go of the above concept as I think my separation of HTML/presentation and Javascript would be better if I could use the solution described above.
So, does anybody know how to force the order of the columnNames in my output -- or what I'm doing to cause it to come out in a different order?
JeaneTechnically there isn't any "order" for the return columns. They aren't returned as an Array -- they're just properties on an Object instance (a "generic object"). The random order you're seeing is the behavior of the for..in loop iterating over the properties of the object. Unfortunately, with a for..in loop there is no guaranteed order for iterating over properties (and, as you've seen, it tends to vary wildly).
The only solution is to create your own list of the column names and sort it the way you want to, then use that to create your output. For example, use the for..in loop to loop over the properties, but rather than actually get the values, just dump the column names into an Array:
var columnName="";
var columns = [];
for (columnName in selResults.data[i]) {
columns.push(columnName);
columns = columns.sort(); // just uses the default alphabetical sort -- you would customize this if desired
var j = 0;
for (j = 0; j < columns.length; j++) {
columnName = columns[j];
output+=columnName + ":" + selResultsdata[i][columnName] + ";"; -
Can we use Column Names in Parameter Cursor
Hi
can we use Column Names in Parameter Cursor??
DECLARE
CURSOR Emp_Cur (P_Deptno NUMBER)
IS
SELECT Empno, Ename
FROM Emp
WHERE Deptno = P_Deptno;
BEGIN
FOR Emp IN Emp_Cur(10)
LOOP
DBMS_OUTPUT.PUT_LINE('The Employee Number is: '||emp.Empno);
DBMS_OUTPUT.PUT_LINE('The Employee Name is: '||emp.Ename);
END LOOP;
FOR Emp IN Emp_Cur(20)
LOOP
DBMS_OUTPUT.PUT_LINE('The Employee Number is: '||emp.Empno);
DBMS_OUTPUT.PUT_LINE('The Employee Name is: '||emp.Ename);
END LOOP;
END;
In the above Program, I send Deptnumber. If i send Column names like Empno, Ename. What can i do??
If Declare Samething Through Parameter Cursor, it doesn't accept VARCHAR2(Size)For parameters you don't use size, just the type (DATE, NUMBER, VARCHAR2, CLOB, ...)
DECLARE
CURSOR Emp_Cur (P_Ename VARCHAR2)
IS
SELECT Empno, Ename
FROM Emp
WHERE Ename = P_Ename;
BEGIN
FOR Emp IN Emp_Cur('SCOTT')
LOOP
DBMS_OUTPUT.PUT_LINE('The Employee Number is: '||emp.Empno);
DBMS_OUTPUT.PUT_LINE('The Employee Name is: '||emp.Ename);
END LOOP;
END; -
Can I use bind variable instaed of writing static COLUMN Name
Hi , I am having a table containing id and column names, the data is stored against that id in other tables. Now I wish to update data into another table so that it goes into apppropriate column without using decode function.
I am trying to do this:
EXECUTE IMMEDIATE 'update TEST set :1 = :2
where PROJECT_ID= :3 and UNIQUE_ID= :4' using P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID;
the values P_DEST_COLUMN, P_TEXT_VALUE, P_PROJ_ID, P_TASK_UID are populated using a cursor in PL/SQl
Is this statement valid? If not can you tell me how to do it as I am getting some error I am unable to comprehend.
thanks
RishabhColumn names cannot be substituted at run-time as bind variables. If you need to specify the column name at run-time, you'd need to construct a new string and execute that string dynamically, i.e.
EXECUTE IMMEDIATE 'UPDATE test SET ' || p_dest_column || ' = :1 ' || ...From a data model standpoint, storing column names as data elements in another table is generally a rather poor idea. It's likely to make ad-hoc reporting nearly impossible and to cause a lot more parsing than would otherwise be required.
Justin
Maybe you are looking for
-
HT204161 Merge & Delete unused Apple IDs & Clear the 1 YR PW memory to use old PWs
I keep getting a note for me to sign into a old Apple ID at "me.com" . I NEVER used this account as far as I know and was probably one that was used a long time ago to initially set up one of my computers. I would like to see if there is anything im
-
Repercussions of importing more than 50 users?
Does anyone know what the repercussions are of importing more than 50 users in the workgroup mode? I have about 250 users to import so that they can use the iCal service, and upon importing my 51st, I was warned that the recommended maximum of import
-
My 4 year old macbook won't boot up. Stays in the same mode . Gray screen, apple logo and spinning wheel. Tried booting in safe mode but reverts back to same. Also tried resetting by removing battery. Nothing is working!! Any advise before I take
-
Can we create roles/permission list based on custom table
I wanted to create Roles and Permission list based on custom table (which holds Business Logic),like if column value is 3 then certain roles and 2 then certain............ is it possible in PS? Thanks
-
Hi Iam using SAP BusinessOne 2005B PL34,Now I need to work on SDK to complete the Clients requirement.I gone through the SDK Sample program in the SDK Help Manual. But , Still Iam confused while taking form and fields references. So I want to know 1.