Help with Dynamic Calc
Hello, could someone help me why after creating the dynamic calc member below, our calc script somehow get stuck/ ran very very slow...
Below is currently our Hierararchy for Division dimension:
Division Dimension
Division Rollup ( Never Share)
Division 1 ( Never Share)
Division a (Never Share) level 0
Division b (Never Share) level 0
Division c (Never Share) level 0
Division 2 (Never Share)
Division d ( Never Share) level 0
Alt_Division without cd (Dynamic Calc) ...and the member formula I did is
="Division Rollup" - "Division c" - "Division d" ;
After I refresh, the Alt_Division without cd went fine, calculated correctly when I retreive in Essbase Escel , however, the big problem was, when we run our aregular Essbase calc scripts, it somehow got stuck with Alt_Division without cd member and the calc went very very slow almost to the point that it just stopped calcing.
Could you please let me know if there is something wrong with my dynamic calc member above... Should the Alt_Division dynamic calc should not be a sibling of the Division Rollup member? or I could not use the "Division Rollup" member .
Could you please recommend a better way of writing the dynamic calc member ( and it's position in the Hierarchy) ... without me aggregarting the dbase ...( I like dynamic calc since it aggs on the fly).
Please advise.
Thanks.
Few Things...
I am assuming Division is a sparse Dimension. A Dynamic Calc member formula on a Sparse dimension member will surely take lots of time.
Suggestion 1:
Create an Alternate hierarchy sharing c and d. Change the consolidation operators to get the C - D at Alt_Hierarchy.
Suggestion 2:
Make the member Store and put the desired calculation in a Calculation script rather than having it as a dynamic calc member formula.
Hope this helps.
Madhavi
Similar Messages
-
Is it possible to make a search help with dynamic selection table?
Hi Experts,
Is it possible to create search helps with dynamic seletion tables means
i dont know the selection table names at the time of creation of search help.
These tables will be determined at runtime.
if yes, Please give an idea how to create and pass the table names at runtime.
Thanks
Yogesh GuptaHi Yogesh,
Create and fill your itab and show it with FM F4IF_INT_TABLE_VALUE_REQUEST
CALL FUNCTION 'F4IF_INT_TABLE_VALUE_REQUEST'
EXPORTING
retfield = 'field to return from itab'
dynpprog = sy-repid
dynpnr = sy-dynnr
dynprofield = 'field on your screen to be filled'
stepl = sy-stepl
window_title = 'some text'
value_org = 'S'
TABLES
value_tab = itab
EXCEPTIONS
parameter_error = 1
no_values_found = 2
OTHERS = 3.
Darley -
Retrive time with Dynamic Calc
Hi Experts,
My users run a large smart view report which works well
However, when they change one of the member on the query to DC member (dense)
Then the retrieve takes forever and they getting network error from smart view.
I try to figure out , how can I improve the retrieve time on my BSO app, focusing on DC issues
I try to increase the data cache, index cache, retrieval buffer and sort.
I add command of DYNCALCCACHEMAXSIZE and the retrieve doesn’t getting better.
In addition, can you pls help me understand the app log file,
Here’s what happen after I ran the report, maybe it will lead
To the problem:
[Mon Aug 06 02:41:03 2012]Local/Orac///1768/Info(1200481)
Formula for member [YTD USD Display] will be executed in [TOPDOWN and CELL] mode
[Mon Aug 06 02:41:03 2012]Local/Orac///1768/Info(1012710)
Essbase needs to retrieve [1] Essbase Kernel blocks in order to calculate the top dynamically-calculated block.
[Mon Aug 06 02:41:03 2012]Local/Orac///1768/Info(1012736)
The Dyn.Calc.Cache for database [Main] can hold a maximum of [242] blocks.
[Mon Aug 06 02:41:03 2012]Local/Orac///1768/Info(1012737)
The Dyn.Calc.Cache for database [Main], when full, will result in [allocation from non-Dyn.Calc.Cache memory].
[Mon Aug 06 02:41:03 2012]Local/Orac///1768/Info(1019018)
Writing Parameters For Database [Main]
[Mon Aug 06 02:41:03 2012]Local/Orac///1768/Info(1019017)
Reading Parameters For Database [Main]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1070013)
Index cache size ==> [307200000] bytes, [37500] index pages.
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1070014)
Index page size ==> [8192] bytes.
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1070081)
Using buffered I/O for the index and data files.
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1070083)
Using waited I/O for the index and data files.
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1019019)
Reading Data File Free Space Information For Database [Main]...
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1006025)
Data cache size ==> [512000000] bytes, [9359] data pages
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1006026)
Data file cache size ==> [0] bytes, [0] data file pages
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1080053)
Free space recovery skipped. Estimated free space recoverable by RecoverDbFreeSpace: [11068706640] bytes
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1024033)
Missing Database Config File [E:\Hyperion\AnalyticServices\APP\Orac\Main\Main.cfg], Query logging disabled
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1203135)
Starting the Data Mining Framework
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1203136)
Data Mining Framework successfully initialized.
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1200551)
Allocated TRIGMAXMEMSIZE: [4096] Bytes.
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1013205)
Received Command [Get Database Volumes]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1013205)
Received Command [Set Database State]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1019018)
Writing Parameters For Database [Main]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1019018)
Writing Parameters For Database [Main]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1013205)
Received Command [Get Database State]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1013205)
Received Command [Get Database Info]
[Mon Aug 06 02:41:05 2012]Local/Orac///1768/Info(1013205)
Received Command [SetApplicationState]
[Mon Aug 06 02:41:06 2012]Local/Orac///1768/Info(1019010)
Writing Application Definition For [Orac]
[Mon Aug 06 02:41:06 2012]Local/Orac///1768/Info(1019011)
Writing Database Definition For [Main]
[Mon Aug 06 02:41:06 2012]Local/Orac///1768/Info(1019022)
Writing Database Mapping For [Orac]
[Mon Aug 06 02:41:06 2012]Local/Orac///5132/Info(1013210)
User [essadmin] set active on database [Main]
Pls help me find out how can I overcome this.
Many thanks,I'll add on to Dan's comment that you very much need to test the dynamic calc (if indeed that is the problem) in the proper context.
Amusing but painful story:
I was once tasked with reducing calc time on a BSO database. i saw long ugly stored member calcs. Hah! I cleverly converted them to dynamic and calc times dropped. No one told me (and I didn't ask) how they were to be reported. There were thousands of instances of this member on the Excel sheet. What had been a nice fast retrieve dropped to five minutes. Whoops.
Take your pain wherever you like -- if you are reading multiple blocks to do the calc (my guess) nothing on earth is going to make it fast. Why make it dynamic in the first place? How many times is the member retrieved? Is it all in the block or, as i guessed, across multiple blocks?
Last comment -- again (this is getting boring) I agree with Dan -- caches are not, usually, the source of any performance joy and it always comes down to design.
Regards,
Cameron Lackpour -
Trouble with Dynamic Calc Scenario
We have built a dynamic Calc scenario in our first 11.1.2 Planning environment that works fine in web forms; Forecast vs Prior Forecast Version. However, when we created our second environment the dyanmic scenario is now causing errors with the web forms. I am getting the generic Data form is invalid, check log for details.
I have isolated the problem to this one scenario. We have three other dynamic scenarios on the form and they work fine.
The formula on the scenario below which is not working does reference another dynamic scenario (Prior Forecast Version, which is working).
Forecast vs Prior Forecast (Scenario not working)
"Forecast" - "Prior Forecast Version";
Prior Forecast Version works fine and here is that formula:
if (@ISMBR("Final"))
"Forecast"->&FcstPF;
elseif (@ISMBR("Final_Jul"))
"Budget"->"Final";
else
@PRIOR("Forecast", 1, @RELATIVE("Version", 0));
endif;
The Prior Forecast Version is before the Forecast vs Prior Forecast in the outline.
I have checked the formulas and settings on each one and they are the same in both environments. We used LCM to build the second environment.
Any suggestions on where to look next?
I am not finding anything in the planning logs that seems to help, do I need to turn on auditing first to get information from the planning logs when you get the generic Check Planning Log for Details message?
Thanks.I haven't check the essbase log but will do so. I thought I checked the correct planning log, but looking at the path I was using, I might have been looking for the log in the wrong place. I was using the path from the troubleshooting guide but it was the diagnostic logs and maybe that is only the correct one when we have auditing turned on.
Help on the path to the correct planning log would be great. I was looking in middleware/user_projects/epmsystem1/diagnostics/logs
Thanks. -
Need help with Dynamic Excel File Name please.
I am try to output an excel file with dynamic date.
Here what I done.
I am using SQL 2012.
Create Execute SQL Task Connect Type: Excel
Create Data Flow Task set to DelayValidation: True
Create OLE DB Sourc
Create Data Converstion
Excel Destination
Excel Connection, Expression, select ExcelFilePath
@[User::sXLFilePath] + @[User::sFileName] + RIGHT("0" + (DT_WSTR, 2) DATEPART("DD", GETDATE()), 2)+ RIGHT("0" + (DT_WSTR, 2) DATEPART("MM", GETDATE()), 2) + RIGHT((DT_WSTR,
4) DATEPART("YYYY", GETDATE()), 2) +".csv"
C:\ExcelOutPut\SOX_CAM_SQL_Report_010215.xls
What I try to accomplish is output the file with each day append to it, date must be DDMMYY.
I google it and found many samples, tested it, and none of them is work for me.
Any suggestions or some examples to share is greatly appreciate.
I am new to SSIS. I found one poster have similar issue and inside the posted below, there was one suggestion to create variable and connection string but how do I bind that variable to Excel Connection manger.
Please help.
Thank you so much in advance.
Ex: SOX_CAM_SQL_Report _020215.csv
SOX_CAM_SQL_Report _030215.csv
--Similar issue:
https://social.msdn.microsoft.com/Forums/en-US/bda433aa-c8f8-47c9-9e56-efd20b8354ac/creating-a-dynamic-excel-file?forum=sqlintegrationservices
Suggestion in the above posted but where can bind this to Excel Connection Manger.
Please help provide step by step. Thanks.
"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\\temp\\" + "ExcelTarget" + (DT_WSTR,4)DATEPART("yyyy",GETDATE()) +
".xls" + ";Extended Properties=\"EXCEL 8.0;HDR=YES\";"
And yes, as you were intimating, the delay validation on the dataflow should be set.Hi NguyenBL,
According to your description, you created ssis package to export data from database to excel, when the package runs, you want to create new excel and name the file with time stamp. If that is the case, we can achieve the goal by following steps:
Create a script task used to create excel files.
Create a data flow task to export data from database to excel.
Add OLE DB source to data flow task.
Add Excel Destination to data flow task.
Create connection manager for OLE DB and Excel.
Click Excel Connection Manager, in Properties window, click (…) button next to Expressions, then set ExcelFilePath with expression like below:
"C:\\ETL Lab\\CreateNewExcel\\ExportData_"+REPLACE((DT_STR, 20, 1252)(DT_DBTIMESTAMP)@[System::StartTime], ":", "")+".xls"
For detail information, please refer to the document:
https://sqljourney.wordpress.com/2013/01/12/ssis-create-new-excel-file-dynamically-to-export-data/
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support -
Problem with Dynamic Calc members in calc script
Hi
i wrote a calc script which calculates the value of acct2 which is dependant on the value of acct1 that is calculated from acct0 as bellow:
FIX(
M1
acct1(
acct1=acct0->M2;
acct2=acct1->M2;
ENDFIX
the value of the intersection of M1->acct0 is 100 as input ,what i wanted from this calc script is the acct2->M1 to be 100 after executing the script once
but the fact is i have to run it twice to get the expected result.
the outline is like this:
M:
M2 Dynamic calc M2=M0+M1
M0 Stored
m1 stored
Account:
acct0 stored
acct1 stored
acct2 stored
Can anyone tell me the reason and how to solve it?
Edited by: user10450070 on 2011-1-25 上午1:38Is acct1 correct after one run of the calculation, but acct2 incorrect? If so, it's because Essbase is calculating them both at the same time (parallel), whereas it has to be forced to calculate acct1 first and acct2 second. You can do this with separate fixes as below:
FIX(M1)
acct1=acct0->M2;
ENDFIX
FIX(M2)
acct2=acct1->M2;
ENDFIX
Or, you can you can force it into calculating in serial mode:
SET CALCPARALLEL 0;
FIX(M1)
acct1=acct0->M2;
acct2=acct1->M2;
ENDFIX
Sabrina
Edited by: SabrinaD on Jan 26, 2011 7:56 AM -
Essbase : Order evalution with dynamic Calc : Account x Scenario
Hi everybody,
I'm trying to calculate a variation N / N-1 in % for All Accounts.
basically : %/ N-1 = (Actual- Actual N-1) / Actual N-1 - I create a scenario.
I create a scenario %_N_1 which is Dynamic Calc.
"%_N_1" = ("ACTUAL" - @MDSHIFT( "ACTUAL" , -1 , "Year" , ))/@MDSHIFT( "ACTUAL" , -1 , "Year" , )*100;
But with agregated Accounts (which are dynamic calc also), Essbase sums the % ... which is wrong !!!
Question : How could we set the priority between Scenario and Account for Dynamic Calculation.
regards,
ps : I want not to put this calculation in Financial Reporting, because there are a lot of reports that use this measure : %_N_1 !Two-pass Calc
You should basically put this on every formula that is a % to make sure it happens after the aggregation stuff.
It get's tricky if you did two-pass on two pass but I believe you aren't using two-pass so you should be good to go -
Help with dynamic page layouts
Hello JSP Gurus,
I'm attempting to dynamically generate the page layout for my site based on the organization a user belongs to. Basically, I'd have certain resources like navigation links, graphics, etc, that are modular. Then I'd like to construct the layout using these "moduls" in a dynamic fashion. Does anyone have any suggestions on techniques or technologies that would be useful? I'm not really looking at the portal/portlet model. Is this something that Cocoon could do by storing the layout for each customer as an XML file or something? Any ideas, suggestions, experiences would be helpful.
Thanks!How does Tiles differ from the JetSpeed apache
project? They both appear to be portal-like
frameworks, or am I incorrect about that? Which is
preferred?Frankly, I can't give you an in-depth answer to that. Maybe someone else can help with more details.
What I can tell you is that JetSpeed seems to be more of a real portal architecture. Emphasis is placed on the framework portion, interfacing with exisiting applications. Visual layout takes second seat to this.
Tiles on the other hand puts more emphasis on visual layout and reuse.
Just looking at JetSpeed's visual interfacing a little bit makes me really dislike it. You build tables and such inside of a servlet, so there's a tight coupling (or at least, much tighter than with Struts/Tiles) between the presentation and logic. (I'm basing this on a JavaWorld article at
http://www.javaworld.com/javaworld/jw-07-2001/jw-0727-jetspeed.html )
Based on your initial question, it would seem to me that tiles is much closer to what you're looking for (and likely easier to just pick up and use).
Anyway, take all this with a grain of salt; I'm not exactly an expert on JetSpeed. =) -
Help with dynamic text and and css !
My second question of the day.
I'm trying to build a feature in my app in which the user can
hide/reveal
bolding and or
italics and or
underlining. The text is being loaded in from an xml file
and I was thinking about styling it with css in order to get the
underlining. My problem is that the only way I can think about
pulling this off is to have a css style sheet that has a defined
bold,italic and underline class defined- - then another one that
just has a italic and underline class defined -- then another one
that has just a bold and underline class defined . . . and so on
and so on. You can see why I would prefer a much more streamlined
system. Unfortunately my experience with dynamic text styling is
somewhat limited. Hopefully someone can help me out here.Perfect. I knew it was some little snippet that I was
forgetting. I made a temporary fix of creating a 0% alpha box over
the button like a fake click area above the text, and that worked
but I know that it was a half-arsed way of working around it.
Thanks. -
Help with this calc; I can't get it to work...
can someone please tell me what is wrong with this calc script in the attached document? It's the field titled "Total Tips" Thank you so much; I've spent a lot of time on it today. This stuff is new to me. Thanks.
Hi,
Not sure if this is what you are referring to, but I noticed that your event.value is being commented out as it sits on the line above, when I moved your event to a new line it started to work out your calculation.
Is this what you were having troubles with? -
URGENT: Help with dynamic borders!
Hello all -
I DESPERATLY need help with this! I am using the code from
kirupa's xml photo gallery with the thumbnails. right now the alpha
changes on mouseover, fine...but my client is demanding that it
draw a border instead. I have been at this for about a week and
have NO idea how to do this...i have looked at things like API's
and things...but my main issue is that the images and MC's are all
created on the fly and i dont know how to code in an on mouseover
draw a border type of function, no idea at all!
This is my code as it sits now, PLEASE SOMEONE HELP ME!!!
thank you in advance!really could use some help quick here guys
-
Retrieval performance become poor with dynamic calc members with formulas
We are facing the retrieval performance issue on our partititon cube.
It was fine before applying the member formulas for 4 of measures and made them dynamic calc.
The retrieval time has increased from 1sec to 5 sec.
Here is the main formula on a member, and all these members are dynamic calc (having member formula)
IF (@ISCHILD ("YTD"))
IF (@ISMBR("JAN_YTD") AND @ISMBR ("Normalised"))
"Run Rate" =
(@AVG(SKIPNONE, @LIST (@CURRMBR ("Year")->"JAN_MTD",
@RANGE (@SHIFT(@CURRMBR ("Year"),-1, @LEVMBRS ("Year", 0)), @LIST("NOV_MTD","DEC_MTD")))) *
@COUNT(SKIPNONE,@RSIBLINGS(@CURRMBR ("Period")))) + "04";
ELSE
IF (@ISMBR("FEB_YTD") AND @ISMBR ("Normalised"))
"Run Rate" =
(@AVG (SKIPNONE, @RANGE (@SHIFT(@CURRMBR ("Year"),-1, @LEVMBRS ("Year", 0)),"DEC_MTD"),
@RANGE (@CURRMBR ("Year"), @LIST ("JAN_MTD", "FEB_MTD"))) *
@COUNT(SKIPNONE,@RSIBLINGS(@CURRMBR ("Period")))) + "04";
ELSE
"Run Rate"
=(@AVGRANGE(SKIPNONE,"Normalised Amount",@CURRMBRRANGE("Period",LEV,0,-14,-12))*
@COUNT(SKIPNONE,@RSIBLINGS(@CURRMBR ("Period"))))
+ "Normalised"->"04";
ENDIF;
ENDIF;
ELSE 0;
ENDIF
Period is dense
Year is dense
Measures (normalised) is dense
remaining all sparse
block size 112k
index cache to 10mb
Rertrieval buffer 70kb
dynamiccalccahe max set to 200mb
Please not that, this is partition cube, retriving data from 2 ASO, 1 BSO underline cubes.I received the following from Hyperion. I had the customer add the following line to their essbase.cfg file and it increased their performance of Analyzer retrieval from 30 seconds to 0.4 seconds. CalcReuseDynCalcBlocks FALSE This is an undocumented setting (will be documented in Essbase v6.2.3). Here is a brief explanation of this setting from development: This setting is used to turn off a method of reusing dynamically calculated values during retrievals. The method is turned on by default and can speed up retrievals when it involves a large number of dynamically calculated blocks that are each required to compute several other blocks. This may happen when there is a big hierarchy of sparse dynamic calc members. However, a large dynamic calculator cache size or a large value of CALCLOCKBLOCK may adversely affect the retrieval performance when this method is used. In such cases, the method should be turned off by setting CalcReuseDynCalcBlocks to FALSE in the essbase.cfg file. Only retrievals are affected by this setting.
-
Help with dynamic statement returning values into collection
Hi All
I am trying to use dynamic statement to return values into a collection using the returning clause. However, I get an ORA-00933 error. Here is a simple setup:
create table t(
pk number,
id_batch varchar2(30),
date_created date,
constraint t_pk primary key ( pk )
create or replace type num_ntt is table of number;
create or replace type vc2_ntt is table of varchar2(30);
create or replace
package pkg
as
type rec is record(
pk num_ntt,
id_batch vc2_ntt
procedure p(
p_count in number,
p_rt out nocopy rec
end pkg;
create or replace
package body pkg
as
procedure p(
p_count in number,
p_rt out nocopy rec
is
begin
execute immediate '
insert into t
select level, ''x'' || level, sysdate
from dual
connect by level <= :p_count
returning pk, id_batch into :pk, :id_batch'
using p_count returning bulk collect into p_rt.pk, p_rt.id_batch;
end p;
end pkg;
declare
r pkg.rec;
begin
pkg.p( 5, r );
end;
/sanjeevchauhan wrote:
but I am working with dynamic statement and returning multiple fields into a collection.And using an INSERT...SELECT statement combined with a RETURNING INTO clause still does not work. Whether it's dynamic SQL or not: it doesn't work. The link describes a workaround.
By the way, I don't see why you are using dynamic SQL here. Static SQL will do just fine. And so you can literally copy Adrian's setup.
Regards,
Rob. -
Hello,
I have the following function that works ok:
CREATE OR REPLACE FUNCTION Get_Partition_Name (sTable VARCHAR2, iImportIndex INTEGER)
RETURN VARCHAR2 IS
cursor c is select A.partition_name from (select table_name, partition_name,
extractvalue (
dbms_xmlgen.
getxmltype (
'select high_value from all_tab_partitions where table_name='''
|| table_name
|| ''' and table_owner = '''
|| table_owner
|| ''' and partition_name = '''
|| partition_name
|| ''''),
'//text()') import_value from all_tab_partitions) A where table_name = sTable and A.import_value = iImportIndex;
sPartitionName VARCHAR(20);
err_num NUMBER;
BEGIN
open c;
fetch c into sPartitionName;
IF c%ISOPEN THEN
CLOSE c;
END IF;
RETURN sPartitionName;
EXCEPTION
WHEN OTHERS THEN
err_num := SQLCODE;
--save error in log table
LOG.SAVELINE(SQLCODE, SQLERRM);
END Get_Partition_Name;
I am trying to replace the cursor statement with dynamic SQL, something like (see below) but it doesn't work any more; I think I am missing some quotes.
CREATE OR REPLACE FUNCTION Get_Partition_Name (sTable VARCHAR2, iImportIndex INTEGER)
RETURN VARCHAR2 IS
TYPE t1 IS REF CURSOR;
c t1;
sSql VARCHAR2(500);
sPartitionName VARCHAR(20);
err_num NUMBER;
BEGIN
sSql := 'select A.partition_name from (select table_name, partition_name,
extractvalue (
dbms_xmlgen.
getxmltype (
''select high_value from all_tab_partitions where table_name=''''
|| table_name
|| '''' and table_owner = ''''
|| table_owner
|| '''' and partition_name = ''''
|| partition_name
|| ''''''),
''//text()'') import_value from all_tab_partitions) A where table_name = :a and A.import_value = :b';
OPEN c FOR sSql USING sTable, iImportIndex;
fetch c into sPartitionName;
IF c%ISOPEN THEN
CLOSE c;
END IF;
RETURN sPartitionName;
EXCEPTION
WHEN OTHERS THEN
err_num := SQLCODE;
--save error in log table
LOG.SAVELINE(SQLCODE, SQLERRM);
END Get_Partition_Name;
Please advise,
Regards,
M.R.Assuming the requirement is to find the partition in the supplied table with the supplied high value and the issue is that dba/all_tab_partitions.high_value is a long, one alternative along the same lines as you've done already is as follows. (I've just used a cursor rather than a function for simplicity of demo).
SQL> var r refcursor
SQL> set autoprint on
SQL> declare
2 ctx dbms_xmlgen.ctxhandle;
3 v_table_name VARCHAR2(40) := 'LOGMNR_USER$';
4 v_value NUMBER := 100;
5 begin
6 ctx := DBMS_XMLGEN.NEWCONTEXT
7 ('select table_name
8 , partition_name
9 , high_value hi_val
10 from dba_tab_partitions
11 where table_name = :table_name');
12 dbms_xmlgen.setbindvalue(ctx,'TABLE_NAME',v_table_name);
13 open:r for
14 with x as
15 (select xmltype(dbms_xmlgen.getxml(ctx)) myxml
16 from dual)
17 select extractvalue(x.object_value,'/ROW/TABLE_NAME') table_name
18 , extractvalue(x.object_value,'/ROW/PARTITION_NAME') partition_name
19 , extractvalue(x.object_value,'/ROW/HI_VAL') hi_val
20 from x
21 , TABLE(XMLSEQUENCE(EXTRACT(x.myxml,'/ROWSET/ROW'))) x
22 where extractvalue(x.object_value,'/ROW/HI_VAL') = v_value;
23 end;
24 /
PL/SQL procedure successfully completed.
TABLE_NAME
PARTITION_NAME
HI_VAL
LOGMNR_USER$
P_LESSTHAN100
100
SQL> I'm sure there are other ways as well. Especially with XML functionality, there's normally many ways to skin a cat. -
Help with dynamic playlist for mpd
Hi guys,
I use mpd with sonata for playing my music, and after trying exaile there is one thing id really like for mpd, and that is the dynamic playlist function.
When you're playing a song in exaile with dynamic playlist enabled, it queries audioscrobbler and automatically adds similar artists/songs to your playlist (if you have them on your pc).
I dont want to use exaile as it just feels too big and slow and bloated (not KISS ), i know a little bit of python so i thought i'll try and make my own little script/program as Sonata has audioscrobbler support, but i dont think there is anyway to query similar artists.
I think im going to try and make this as a daemon type program that will run in the background adding songs to the playlist.
Ive found the code from the exaile source (audioscrobbler.py) which queries lastfm e.g.
>>> lips = AudioScrobblerQuery(artist='The Flaming Lips')
>>> for artist in lips.similar():
... print artist.name, artist.mbid
This will print a list of similar artists to the flaming lips.
I've not done much with python so i thought this would be a good way to try and improve.
Does anyone have any suggestions as to what the best way to go about searching and comparing the results to my mpd database, would the best way just to be to search the mpd.db?
And if anyone else has any ideas/comments id like to hear them.
Edit:
I just found this too, so i may only need to change some things to integrate it with mpd rather than amarok
http://www.kde-apps.org/content/show.php?content=31920
Thanks
Last edited by Kane (2008-06-05 13:24:33)well i just modified the patch into a little script, it does what i need
its here if anyone wants it
import audioscrobbler
import mpd
import random
import time
lastsong = {}
def timer_control():
get_similar()
time.sleep(10)
timer_control()
def get_similar():
audioscrobbler
client = mpd.MPDClient()
client.connect("localhost", 6600)
mpdstatus = client.status()
prevsonginfo = client.currentsong()
global lastsong
if mpdstatus['state'] == "stop": return
if prevsonginfo == lastsong: return
lastsong = prevsonginfo
similarartists = ""
song = prevsonginfo
#if not song: break #No song, do nothing
prevartist = song['artist']
# Is the info already cached?
similar_cache = {}
if similar_cache.has_key(prevartist):
similarartists = similar_cache[prevartist]
else:
#Not cached so fetch from Audioscrobbler
try:
similarartists = [artist.name for artist in audioscrobbler.AudioScrobblerQuery(artist=prevartist).similar()]
# Cache search results and save some time next search
similar_cache[prevartist] = similarartists
except audioscrobbler.AudioScrobblerError:
similar_cache[prevartist] = None # Empty cache
return # Do nothing!
if not similarartists: return # Empty list
# Split list in half and sort upper half
# this means good matches will have priority
# but makes sure artist A does not always result in artist B
half_idx = len(similarartists)/2
upperhalf = similarartists[:half_idx]
lowerhalf = similarartists[half_idx:]
random.shuffle(upperhalf)
artistlist = upperhalf
artistlist.extend(lowerhalf)
# Try each artist in order
for artist in artistlist:
try:
print "Trying:",artist
songs = client.search("artist", artist)
if not songs: continue
selected_song = random.sample(songs, 1)[0]
client.add(selected_song['file'])
print "Added", selected_song['title'],"by",selected_song['artist']
# Delete old song from playlist?
break
except mpd.MPDError, e:
print "MPDError", e.message
continue
except ValueError, e:
print "ValueError:",e.message
continue
timer_control()
Last edited by Kane (2008-06-06 16:22:49)
Maybe you are looking for
-
I'm trying to switch my iTunes account to a different country but I have $0.29 left on my account that iTunes is telling me I must spend before I can change countries. Obviously, 29 cents will not buy me anything in the store, thus the money will be
-
i have a mac pro. when i try to connet to a vedio call. the call doesnt connet. the person on the other side can see me but i cant see them. i updated the new version for adobe flash. but the camra stiil doesnt work.
-
I have a rev D 333mhz imac. It looks like somebody stabed the ati graphics cars, where it connects to the board the metal pieces are missing. The light on the front stays orange. is there any possible fix?
-
Hierarchy problem when creating IDoc with multiple headers
Hi, In general, When you create an inbound IDoc for the IDoc Type FIDCCP02, you have all the data records arranged in hierarchical order (while viewing it in the we02 transaction). Our requirement is to have m number of headers(E1FIKPF) and in turn i
-
How to catch the access to a folder
Dear friends I want to write a program in such a way that,if any body tries to access my folder say E:\\chandu i should get an indication to my hidden program. thanks in advance.