Getting Variance from dynamic columns
Hi,
My query currently has the characterstics "finanical view" and the under key figures it has "amount" in the columns section.Hence it returns me the amount under each financial view. The number of entries for "financial view " is dynamic based on user entry.
I want to display the variance for the last two financial views.
Now the query displays the amount for each financial view. My requirement is to get the variance for the amounts in the last two columns.
Kindly suggest a way how this can be achieved.
Please help.
Thank you,
Regards,
Rathy
Please provide some pointers.Its very urgent.
Thanks& Regards,
Rathy
Similar Messages
-
How to get values from dynamic component?
Hi:
I am displaying dynamic components based on user selection, where InputText and OutputText display properly. But now i want to read that component value on
button click. Can any body help me in that?
Source code is as follow,
text.xhtml
*<code>*
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:ice="http://www.icesoft.com/icefaces/component"
template="/WEB-INF/includes/templates/page-template.xhtml">
<ui:define name="page-content">
<div class="exampleBox splashContainer"
style="background: url('./xmlhttp/css/rime/css-images/contentContainer_bg.gif') top repeat-x">
<table>
<tr>
<td colspan="2">
<h2>Set Request Process Flow</h2>
</td>
</tr>
<tr>
<td colspan="2"><ice:messages style="color:red;" /></td>
</tr>
<tr>
<td><ice:outputText value="Request Type*"></ice:outputText></td>
<td><ice:selectOneMenu value="#{offlinereq.requestno}"
valueChangeListener="#{offlinereq.requestChange}"
partialSubmit="true">
<f:selectItem itemValue="" itemLabel="--Select--" />
<f:selectItems value="#{offlinereq.requests}" />
</ice:selectOneMenu></td>
</tr>
<tr>
<td>*<h:panelGroup binding="#{offlinereq.panelBind}">*
* </h:panelGroup>*</td>
</tr>
<tr>
<td colspan="4"><ice:commandButton value="Add"
actionListener="#{offlinereq.add}" /> <ice:commandButton
value="Update" actionListener="#{offlinereq.update}" /> <ice:commandButton
value="Delete" actionListener="#{offlinereq.delete}" /> <ice:commandButton
value="Reset" actionListener="#{offlinereq.reset}" /></td>
</tr>
</table>
</div>
</ui:define>
</ui:composition>
*</code>*
bean.java
*<code>*
//ValuechangeListener
public void requestChange(ValueChangeEvent e){
System.out.println("Select Value is::"+e.getNewValue()+"::"+userid);
Connection conn=null;
try {
if(!panelBind.getChildren().isEmpty())
panelBind.getChildren().clear();
Class.forName ("oracle.jdbc.OracleDriver");
conn = JdbcUtil.getConnection();
Statement stmt = conn.createStatement();
String sql="select * from IB_CUSTOMER_REQUEST_PARAMETERS where IB_REQMAST_SRNO='"+e.getNewValue()+"'";
ResultSet rs = stmt.executeQuery(sql);
String out="out";
int i=1;
String ii;
while(rs.next()) {
FacesContext facesContext = FacesContext.getCurrentInstance();
Application application = facesContext.getApplication();
HtmlPanelGrid grid = (HtmlPanelGrid)application.createComponent(HtmlPanelGrid.COMPONENT_TYPE);
grid.setColumns(2);
HtmlOutputText output = (HtmlOutputText)application.createComponent(HtmlOutputText.COMPONENT_TYPE);
output.setValue(rs.getString("IB_CUSTREQSTPARA_NAME"));
ii=Integer.toString(i);
output.setId("a"+ii.toString());
System.out.println("id"+ii);
HtmlInputText input = (HtmlInputText)application.createComponent(HtmlInputText.COMPONENT_TYPE);
//input.setValue(rs.getString(1));
grid.getChildren().add(output);
grid.getChildren().add(input);
panelBind.getChildren().add(grid);
i++;
catch(Exception e1)
System.out.println(e1);
//Action listeners
public void add(ActionEvent e)
System.out.println("ADD");
*</code>*
Thank You,
AnupWhere are you stuck? find the component (UIComponent.findComponent) in the JSF component tree by its ID and get the value from it. This article might help:
http://illegalargumentexception.blogspot.com/2009/02/jsf-working-with-component-ids.html
Note: the code tag is \ -
Get values from dynamic form items
Hi All,
I create a dynamic form with text input component
private function buildForm():void{
var numberOfColumns:Number = 5
var formItem:FormItem = new FormItem();
var hBox:HBox = new HBox();
for(var i:Number=0; i< numberOfColumns; i++) {
var formInput:TextInput = new TextInput();
formInput.text = "test";
formInput.id = "txt_" +i;
hBox.addChild(formInput);
formItem.addChild(hBox);
loansForm.addChild(formItem);
I can see the text input components, update the values.
How can I get the updated values from the input components?
I try this["txt_" + i].text but not working. It's not finding the component with the dynamic value.
Any ideas?
Thanks
JohnnyHi,
Here is the related thread, u will get some help
http://forums.adobe.com/message/3075226
Thanks and Regards,
Kanchan Ladwani | [email protected] | www.infocepts.com -
How to get values from dynamically populated field symbol
Hi all,
I am having a field symbol <fs_table> type standard table, which is getting populated dynamically.
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = i_fieldcat[]
IMPORTING
ep_table = is_eptab.
ASSIGN is_eptab->* TO <fs_table> .
After the ALV display i am making some changes in the ALV and getting a new internal table <fst_table>,which is having changed values.
Now the problem is that i am not able to get the changed values from <fst_table> as it is not of any structure type and cant associate it with any field like we do in normal internal table and work areas like, wa-fieldname.
All the fields are dynamic.
Regards,
AnantHello Anant
You have to access to access the fields of your dynamic outtab dynamically as well.
DATA: ls_fcat TYPE lvc_s_fcat.
FIELD-SYMBOLS:
<ls_struc> TYPE any,
<ld_fld> TYPE any.
LOOP AT <fs_table> ASSIGNING <ls_struc>.
LOOP AT i_fieldcat INTO ls_fcat.
ASSIGN COMPONENT ls_fcat-fieldname OF STRUCTURE <ls_struc> TO <ld_fld>.
... " do processing
ENDLOOP.
ENDLOOP.
Regards
Uwe -
Hi,
I am new to OAF, I am trying to get the value from the table in order to make validation. I have the following PG:
SearchResultsTableRN
itemRow
DetailsCell
DetailsTableLayout
ShortDescRow
ShortDescCell
ShortDesc
LongDescRow
LongDescCell
LongDesc
AttributesRow
AttributesCell
AttributesTableLayout
Attributes1Row
Attribute11Cell
ect...
Can anyone help me please in how to go into the table --> row --> column to retrieve the value from a specific column?
If their is a document or example that can help I will appreciate it. Since I tried searching in devguide and didn't find any results.
Note: I am extending the controller and reached till the following code:
public void processFormRequest(OAPageContext oapageContext, OAWebBean webBean){
super.processFormRequest(oapageContext, webBean);
String event = oapageContext.getParameter("ShortDescRow");
OATableBean advtable = (OATableBean)webBean.findChildRecursive("SearchResultsTableRN");
OARowBean rowtbl = (OARowBean)advtable.findChildRecursive("DetailsCell");
String message = "test:"+event+"|"+advtable+"|"+"|"+"|"+"|";
throw new OAException(message, OAException.INFORMATION);
Thanks and Regards
PatrickPatrick,
My first advice would be go through OAF guide and do tutorial examples, for such basic details.
If ur talking about tablelayout region
u can use pageContext.getParameter(<Item id of UIX bean whose value u want>);
If you are talking about table
You can Iterate through the VO based on primary key ...on which the table is based, and retrive the corresponding Vo attribute value.
--Mukul -
Getting values from dynamic items
I've created some items on my page using APEX_ITEM. This is a really cool feature, it allows extreme flexibility. My problem is, I can not get the value out of the textbox I've created.
It doesn't appear in session state at all. I thought this wasn't going to happen though.
I've tried a computation to get the value into a hidden item. These items appear null upon submittal.
I came across APEX_APPLICATION.G_F01 - but this isn't working for me either... It appears to be used to access an array and I must not be using it correctly.
Anyone got any pointers on how to get the information out??Here is the formatted code (put pre and */pre* before and after blocks, replacing asterisks with matched square brackets):
v_item_desc varchar2(4000);
v_counter number;
cursor v_item_cursor is
{select statement}
begin
v_counter := 1;
htp.p('< table>');
for aRow in v_item_cursor
loop
select X
into v_item_desc
from Y
where Z = v_counter;
htp.p(
'< tr>< td>< span style="line-height:25px;font-size:15px">'|| apex_item.display_and_save(v_counter, null, null, null)||v_item_desc||'< /span>< /td>');
htp.p(
'< td>'||apex_item.text(v_counter, null, 30, 4000, null, 'P6_SUM_SELECT_'||v_counter)|| '< /td>< /tr>');
v_counter := v_counter + 1;
end loop;
htp.p('< /table>');
end;In your after-submit process, loop over apex_application.g_f01 from 1..apex_application.g_f01.count for the array created when you used v_counter=1, etc.
Scott -
Can't Load Schema from Dynamic Feed
Local:
OS - Windows XP
Dreamweaver CS3 + Developer Toolbox
Remote:
Server - Apache 1.3.3 (Unix)
PHP - 4.4.7
MySQL - 4.1.22 (Standard)
My Dreamweaver Remote Server Connection Settings:
URL -
http://www.mydomainname.tld
Server - PHP MySQL
FTP - ftp.mydomainname.tld + myusername + mypassword
Folder - /public_html/
URL of Root Folder -
http://www.mydomainname.tld/
My Dreamweaver Remote MySQL Database Connection settings:
MySQL Server - localhost + prefix_mydatasbaseusername +
mypassword
Database - prefix_databasename
Hi,
I've been following this tutorial (
http://www.adobe.com/devnet/dreamweaver/articles/spry_xml_export.html
through every single steps and following every instructions
to the
letter but I got stuck when I reached page 4 of 5 in the
tutotrial.
I've been searching for an answer/solution to the problem for
the last
couple days but found nothing so far.
On page 1 - 3 of the tutorial, I have succeeded in the
followings:
1) Inserted the sample SQL Tables provided with the tutorial
into my
MySQL Database.
2) Got Dreamweaver to Connected to my MySQL Database.
3) Created a new Recordset with the data from my MySQL
Database.
4) Using Dreamweaver Extension (Developer Toolbox), exported
the newly
created Recordset as XLM using a web page named
"export_test.php"
5) Uploaded the "includes/XMLExport" folders & Contents
to
"/public_html/" folder on my remote server.
6) Previewed the "export_test.php" and it shows exactly as
the tutorial
illustrated. No problem.
Up till this point, all went well.
7) As instructed in the tutorial, I created another web page
named
"spry_sample.html".
8) As instructed, I clicked on the "Spry XML Data Set" and
the prompt
shows up. I entered the followings:
Dataset Name - dsTest
XML Source - export_test.php (on local machine)
When I clicked on "Get Schema", I got a prompt saying:
"Failed to get schema from dynamic feed (export_test.php).
Please make
sure the testing server is configured in the Site
Definition."
I have deleted every files and folder (local and remote)
created by this
tutorial, and re-done the tutorial, but still end up getiing
stuck with
the same problem.
What have I done wrong here?
Any advice would be deeply appreciated.
Thanks in advanced.
Tommy>>
are you running the Spry'ed page that´s pointing to your
"export_test.php" from a (your local) server by the time
you´re previewing it from Dreamweaver ?
>>
I am running the Spry'ed page that's pointing to my
"export_test.php" from my local server, everything is running on my
local server. Also worth noting is that the "export_test.php" page
when previewed in IE, will show the xml file as it would be used,
and i can save that page as an xml file from IE, but when i try to
use that xml file with the "spry XML dataset" and utilize it in a
"spry table" and try to view the page in IE, nothing but a blank
page shows, and the source that does not show is:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="
http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=utf-8" />
<title>Untitled Document</title>
<script src="SpryAssets/xpath.js"
type="text/javascript"></script>
<script src="SpryAssets/SpryData.js"
type="text/javascript"></script>
<script type="text/javascript">
<!--
var ds1 = new
Spry.Data.XMLDataSet("includes/XMLExport/test3.xml",
"export/row",{useCache:false});
//-->
</script>
</head>
<body>
</body>
</html>
HERE IS MY SETUP:
OS - Windows Vista Business
Dreamweaver CS3 + Developer Toolbox
Server - IIS7
PHP - 5.2.4
MySQL - 5.0.45
some info from php info:
dom
DOM/XML enabled
DOM/XML API Version 20031129
libxml Version 2.6.26
HTML Support enabled
XPath Support enabled
XPointer Support enabled
Schema Support enabled
RelaxNG Support enabled
libxml
libXML support active
libXML Version 2.6.26
libXML streams enabled
mbstring
Multibyte Support enabled
Multibyte string engine libmbfl
Multibyte (japanese) regex support enabled
Multibyte regex (oniguruma) version 4.4.4
Multibyte regex (oniguruma) backtrack check On
mbstring extension makes use of "streamable kanji code filter
and converter", which is distributed under the GNU Lesser General
Public License version 2.1.
Directive Local Value Master Value
mbstring.detect_order no value no value
mbstring.encoding_translation Off Off
mbstring.func_overload 0 0
mbstring.http_input pass pass
mbstring.http_output pass pass
mbstring.internal_encoding ISO-8859-1 no value
mbstring.language neutral neutral
mbstring.strict_detection Off Off
mbstring.substitute_character no value no value -
How Can I get multi column values from dynamic search help?
Hi Gurus;
I'm using dynamic search help in my program.
I want to get multi column values from search help. But I dont know solution for this issue.
I'm using F4IF_INT_TABLE_VALUE_REQUEST FM.
How Can I get multi column values from dynamic search help?
Thanks.Believe it or not, the same FM worked for me in a dynpro. I will try to explain here how it works in custom screen and then you can do your work for other screens or program types. I am not going to write my actual work but will explain in general.
I have 4 fields (FLD1, FLD2, FLD3, FLD4) and i made the search based on FLD2 and when user click on a line (could be any field), then this would bring the line on to the screens.
There are like 3 steps.
You have your value_tab for my fields FLD1, FLD2, FLD3 and FLD4. This is just the data that we pass into the FM. (data: IT_VALTAB type table of ZVAL_TABLE)
Next map the screen fields into an internal table (data: It_dynpfld type table of dselc ). I also have other internal tables defined (just to keep it straight, i will be putting here) data: It_return type standard table of ddshretval.
Next step is to call the function module. Make sure you have values in IT_VALTAB.
call function 'F4IF_INT_TABLE_VALUE_REQUEST'
exporting
retfield = 'FLD2'
value_org = 'S'
tables
value_tab = It_VALTAB
return_tab = It_return
dynpfld_mapping = It_dynpfld
exceptions
parameter_error = 1
no_values_found = 2
others = 3.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
else.
perform get_selected_fields tables It_return.
endif.
The code within the perform GET_SELECTED_FIELDS - We need to map the result fields after user selects it. The code goes like this. This is step is to update the dynpro fields.
I need a internal table as well as a work area here. like,
data: lt_fields type table of dynpread,
la_fields type dynpread.
field-symbols: <fs_return> type ddshretval.
so fill out LT_FIELDS from the IT_RETURN table
loop at lt_return assigning <fs_return>.
la_fields-fieldname = <fs_return>-retfield.
la_fields-fieldvalue = <fs_return>-fieldval.
append la_fields to lt_fields.
clear: la_fields.
endloop.
Call the FM to update the dynpro
call function 'DYNP_VALUES_UPDATE'
exporting
dyname = sy-repid
dynumb = '1002' "This is my screen number. You could use 1000 for selection screen (hope so)
tables
dynpfields = lt_fields
exceptions
invalid_abapworkarea = 1
invalid_dynprofield = 2
invalid_dynproname = 3
invalid_dynpronummer = 4
invalid_request = 5
no_fielddescription = 6
undefind_error = 7
others = 8.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
good luck -
Im getting an error when running a procedure that includes this code.
I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql
DECLARE @retval AS DECIMAL(12,2)
DECLARE @MonthVal VARCHAR(20), @SpreadKeyVal INT
DECLARE @sqlcmd AS NVARCHAR(150)
DECLARE @paramdef NVARCHAR(150)
SET @MonthVal = 'Month' + CAST(@MonthNumber AS VARCHAR(2) );
SET @SpreadKeyVal = @SpreadKey; --CAST(@SpreadKey AS VARCHAR(10) );
SET @sqlcmd = N' SELECT @retvalout = @MonthVal FROM dbo.CourseSpread WHERE CourseSpreadId = @SpreadKeyVal';
SET @paramdef = N'@MonthVal VARCHAR(20), @SpreadKeyVal INT, @retvalout DECIMAL(12,2) OUTPUT'
--default
SET @retval = 0.0;
EXECUTE sys.sp_executesql @sqlcmd,@paramdef, @MonthVal = 'Month4',@SpreadKeyVal = 1, @retvalout = @retval OUTPUT;
SELECT @retval
DECLARE @return_value DECIMAL(12,2)
EXEC @return_value = [dbo].[GetSpreadValueByMonthNumber]
@SpreadKey = 1,
@MonthNumber = 4
SELECT 'Return Value' = @return_value
Msg 8114, Level 16, State 5, Line 1
Error converting data type varchar to numeric.Please follow basic Netiquette and post the DDL we need to answer this. Follow industry and ANSI/ISO standards in your data. You should follow ISO-11179 rules for naming data elements. You should follow ISO-8601 rules for displaying temporal data. We need
to know the data types, keys and constraints on the table. Avoid dialect in favor of ANSI/ISO Standard SQL. And you need to read and download the PDF for:
https://www.simple-talk.com/books/sql-books/119-sql-code-smells/
>> I need to select from a dynamic column name and save the result in a variable, but seem to be having trouble with the values being fed to sp_executesql <<
This is so very, very wrong! A column is an attribute of an entity. The idea that you are so screwed up that you have no idea if you want
the shoe size, the phone number or something else at run time of this entity.
In Software Engineering we have a principle called cohesion that says a model should do one and only one task, have one and only one entry point, and one and only one exit point.
Hey, on a scale from 1 to 10, what color is your favorite letter of the alphabet? Yes, your mindset is that level of sillyity and absurdity.
Do you know that SQL is a declarative language? This family of languages does not use local variables!
Now think about “month_val” and what it means. A month is a temporal unit of measurement, so this is as silly as saying “liter_val” in your code. Why did you use “sp_” on a procedure? It has special meaning in T-SQL.
Think about how silly this is:
SET @month_val = 'Month' + CAST(@month_nbr AS VARCHAR(2));
We do not do display formatting in a query. This is a violation of at the tiered architecture principle. We have a presentation layer. But more than that, the INTERVAL temporal data type is a {year-month} and never just a month. This is fundamental.
We need to see the DDL so we can re-write this mess. Want to fix it or not?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
How can we get Dynamic columns and data with RTF Templates in BI Publisher
How can we get Dynamic columns and data with RTf Templates.
My requirement is :
create table xxinv_item_pei_taginfo(item_id number,
Organization_id number,
item varchar2(4000),
record_type varchar2(4000),
record_value CLOB,
State varchar2(4000));
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'USES','fever','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'HOW TO USE','one tablet daily','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'SIDE EFFECTS','XYZ','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'DRUG INTERACTION','ABC','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'OVERDOSE','Go and see doctor','TX');
insert into xxinv_item_pei_taginfo values( 493991 ,224, '1265-D30', 'NOTES','Take after meal','TX');
select * from xxinv_item_pei_taginfo;
Item id Org Id Item Record_type Record_value State
493991 224 1265-D30 USES fever TX
493991 224 1265-D30 HOW TO USE one tablet daily TX
493991 224 1265-D30 SIDE EFFECTS XYZ TX
493991 224 1265-D30 DRUG INTERACTION ABC TX
493991 224 1265-D30 OVERDOSE Go and see doctor TX
493991 224 1265-D30 NOTES Take after meal TX
Above is my data
I have to fetch the record_type from a lookup where I can have any of the record type, sometime USES, HOW TO USE, SIDE EFFECTS and sometimes some other set of record types
In my report I have to get these record typpes as field name dynamically whichever is available in that lookup and record values against them.
its a BI Publisher report.
please suggestif you have data in db then you can create xml with needed structure
and so you can create bip report
do you have errors or .... ? -
How to get the dynamic columns in UWL portal
Hi All,
I am working on UWL Portal. I am new to UWL. I have down loaded uwl.standard XML file and costomized for getting the values for "select a Subview" dropdown and I am able to see the values in the dropdown. Now my requirement is to get the dynamic columns based on the selection from dropdown value.
can any body suggest on how to get the dynamic columns in UWL portal.Hi Manorama,
1) If you have already created a portal system as mentioned in following blog
/people/marcel.salein/blog/2007/03/14/how-to-create-a-portal-system-for-using-it-in-visual-composer
2) If not, then try to create the same. Do not forgot to give the Alias name .
3) After creating a system, log on to the VC, Create one iView.
4) Now Click on "Find Data" button from the list which you can view in right side to Visual composer screen.
5) After clicking on "Find Data" button, it will ask for System. If you have created your system correctly and Alias name is given properly, then your mentioned Alias name is appeared in that list.
6) Select your system Alias name and perform search.
7) It will display all the BAPIs and RFCs in your systems.
8) Select required BAPI and develop the VC application.
Please let me know if you any further problems.
Thanks,
Prashant
Do reward points for useful answers. -
Importing From Flat File with Dynamic Columns
HI
I am using ssis 2008,i have folder in which I have Four(4) “.txt” files each file will have 2 columns(ID, NAME). I loaded 4
files in one destination, but today I receive one more “.txt” file here we have 3 columns (ID, NAME, JOB) how can I get a message new column will receive in source. And how can I create in extra column in my destination table dynamically …please help meHi Sasidhar,
You need a Script Task to read the names and number of columns in the first row of the flat file each time and store it in a variable, then create a staging table dynamically based on this variable and modify the destination table definition if one ore more
new columns need to be added, and then use the staging table to load the destination table. I am afraid there is no available working script for your scenario, and you need some .NET coding experience to achieve your goal. Here is an example you can refer
to:
http://www.citagus.com/citagus/blog/importing-from-flat-file-with-dynamic-columns/
Regards,
Mike Yin
TechNet Community Support -
Dynamic Columns in UWL from the NWBC 3.0?
Hi People
Is there anyone that know how to change the UWL so it uses Dynamic Columns for Worklist . I know that it is possible to do this in the portal by changing the XML's to the UWL. But at the moment i am trying to get this to work from the NWBC 3.0.
When i setup the uwl in NWBC i use the dynpro application SWF_WORKPLACE.
thanks in advance.Hi,
I have the same problem. Does anyone how to do it?
Thanks in advance,
Cecilia.
Edited by: Cecy_Vivar on Jun 22, 2011 12:15 AM -
Get alias name from dynamic query
Hi All,
I would make a plsql function using dynamic query.
And the function takes a whole sql query as a parameter.
The main issue is that the function should get what alias or columns were queried.
For example,
FUNCTION_GET_QUERY_ALIAS('SELECT 1 AS col1, 2 AS col2 FROM DUAL')
Inside the function, it should find the alias name COL1 and COL2.
I'd appreciate for any help.I have modified print_table as function and made it to satisfy your needs.
SQL> CREATE OR REPLACE TYPE my_column_object AS OBJECT(ruw_number integer, column_name VARCHAR2(1000), column_val VARCHAR2(1000))
2 /
Type created.
SQL> CREATE OR REPLACE TYPE my_table_type AS TABLE OF my_column_object
2 /
Type created.
SQL> CREATE OR REPLACE FUNCTION print_table( p_query in varchar2 ) RETURN my_table_type PIPELINED
2 AS
3 l_theCursor INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
4 l_columnValue VARCHAR2(4000);
5 l_status INTEGER;
6 l_descTbl DBMS_SQL.DESC_TAB;
7 l_colCnt NUMBER;
8 l_rcount INTEGER := 0;
9 BEGIN
10 DBMS_SQL.PARSE( l_theCursor, p_query, dbms_sql.native );
11
12 DBMS_SQL.DESCRIBE_COLUMNS( l_theCursor, l_colCnt, l_descTbl );
13
14 FOR i IN 1 .. l_colCnt
15 LOOP
16 DBMS_SQL.DEFINE_COLUMN(l_theCursor, i, l_columnValue, 4000);
17 end loop;
18
19 l_status := DBMS_SQL.EXECUTE(l_theCursor);
20
21 WHILE ( DBMS_SQL.FETCH_ROWS(l_theCursor) > 0 )
22 LOOP
23 l_rcount := l_rcount + 1;
24 FOR i IN 1 .. l_colCnt
25 LOOP
26 DBMS_SQL.COLUMN_VALUE( l_theCursor, i, l_columnValue );
27
28 PIPE ROW(my_column_object(l_rcount,l_descTbl(i).col_name,l_columnValue));
29 END LOOP;
30 END LOOP;
31
32 RETURN;
33 end;
34 /
Function created.
SQL> select * from table(print_table('select * from emp'))
2 /
RUW_NUMBER COLUMN_NAME COLUMN_VAL
1 EMPNO 7369
1 ENAME SMITH
1 JOB CLERK
1 MGR 7902
1 HIREDATE 17-DEC-80
1 SAL 800
1 COMM
1 DEPTNO 20
1 DIV 10
2 EMPNO 7499
2 ENAME ALLEN
RUW_NUMBER COLUMN_NAME COLUMN_VAL
2 JOB SALESMAN
2 MGR 7698
2 HIREDATE 20-FEB-81
2 SAL 1600
2 COMM 300
2 DEPTNO 30
2 DIV 10
3 EMPNO 7521
3 ENAME WARD
3 JOB SALESMAN
3 MGR 7698
RUW_NUMBER COLUMN_NAME COLUMN_VAL
3 HIREDATE 22-FEB-81
3 SAL 1250
3 COMM 500
3 DEPTNO 30
3 DIV 10
4 EMPNO 7566
4 ENAME JONES
4 JOB MANAGER
4 MGR 7839
4 HIREDATE 02-APR-81
4 SAL 2975
RUW_NUMBER COLUMN_NAME COLUMN_VAL
4 COMM
4 DEPTNO 20
4 DIV 10
5 EMPNO 7654
5 ENAME MARTIN
5 JOB SALESMAN
5 MGR 7698
5 HIREDATE 28-SEP-81
5 SAL 1250
5 COMM 1400
5 DEPTNO 30
RUW_NUMBER COLUMN_NAME COLUMN_VAL
5 DIV 10
6 EMPNO 7698
6 ENAME BLAKE
6 JOB MANAGER
6 MGR 7839
6 HIREDATE 01-MAY-81
6 SAL 2850
6 COMM
6 DEPTNO 30
6 DIV 10
7 EMPNO 7782
RUW_NUMBER COLUMN_NAME COLUMN_VAL
7 ENAME CLARK
7 JOB MANAGER
7 MGR 7839
7 HIREDATE 09-JUN-81
7 SAL 2450
7 COMM
7 DEPTNO 10
7 DIV 10
8 EMPNO 7788
8 ENAME SCOTT
8 JOB ANALYST
RUW_NUMBER COLUMN_NAME COLUMN_VAL
8 MGR 7566
8 HIREDATE 19-APR-87
8 SAL 3000
8 COMM
8 DEPTNO 20
8 DIV 10
9 EMPNO 7839
9 ENAME KING
9 JOB PRESIDENT
9 MGR
9 HIREDATE 17-NOV-81
RUW_NUMBER COLUMN_NAME COLUMN_VAL
9 SAL 5000
9 COMM
9 DEPTNO 10
9 DIV 10
10 EMPNO 7844
10 ENAME TURNER
10 JOB SALESMAN
10 MGR 7698
10 HIREDATE 08-SEP-81
10 SAL 1500
10 COMM 0
RUW_NUMBER COLUMN_NAME COLUMN_VAL
10 DEPTNO 30
10 DIV 10
11 EMPNO 7876
11 ENAME ADAMS
11 JOB CLERK
11 MGR 7788
11 HIREDATE 23-MAY-87
11 SAL 1100
11 COMM
11 DEPTNO 20
11 DIV 10
RUW_NUMBER COLUMN_NAME COLUMN_VAL
12 EMPNO 7900
12 ENAME JAMES
12 JOB CLERK
12 MGR 7698
12 HIREDATE 03-DEC-81
12 SAL 950
12 COMM
12 DEPTNO 30
12 DIV 10
13 EMPNO 7902
13 ENAME FORD
RUW_NUMBER COLUMN_NAME COLUMN_VAL
13 JOB ANALYST
13 MGR 7566
13 HIREDATE 03-DEC-81
13 SAL 3000
13 COMM
13 DEPTNO 20
13 DIV 10
14 EMPNO 7934
14 ENAME MILLER
14 JOB CLERK
14 MGR 7782
RUW_NUMBER COLUMN_NAME COLUMN_VAL
14 HIREDATE 23-JAN-82
14 SAL 1300
14 COMM
14 DEPTNO 10
14 DIV 10
126 rows selected.
SQL>Thanks,
Karthick.
Edited by: Karthick_Arp on Sep 23, 2008 12:11 AM -
From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?
Hi,
Use NVL or COALESCE:
NVL (col_a, col_b)
Returns col_a if col_a is not NULL; otherwise, it returns col_b.
Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002
Maybe you are looking for
-
Urgent - help with Text direction in InDesign CS4
Hello, I use InDesign CS4 on Windows 7. It's a standard version (without options for right-to-left languages). Whenever I make a new text frame, it seems to have a right-to-left "logic" of the text. The text types left to right, but the period in the
-
ABAP Runtime Error CONV_NO_NUMBER
Dear all, I am calling transaction F-02 for posting G/L Account from an FM. I tried with the Header Data and Account and Cost Centre but it says ABAP Runtime Error CONV_NO_NUMBER. I undersood that its because of the Number interpretation and coded ac
-
Formating issue after export crystal report to excel format
Hi Everyone, I have a crystal report devloped in crystal 8.5 and i am calling this report from my .net windows application. I have a problem when i export the report in excel format. One of the column size(which is report footer) gets increased beca
-
SCM Issues with Sales Orders Created through CRM
Hi All, I'm trying to ascertain any issues with ERP processing that will not update orders created through CRM, i see there was a OSS Note some time back informing that the backorder reschedule program would not update orders created in the CRM syste
-
Installed os x 10.6.8 and office 2008 excel not enough memory on start
I just installed OS 10.6.8 and when I try to run Office 2008 Excel I get a "Not Enough Memory" pop-up and it will not open any files. Any ideas on how to resolve this? If not how do I revert back to original operation system?