Report with multiple COUNT columns with counts from same table
I am new to discoverer so I am a bit lost.
I am working to create a report to show usage data from the eBusiness Knowledge Base. I have the query written in SQL using subqueries that is in the format:
Solution Number | Soultion Title | Solution Views | Positive Feedback | Negative Feedback
12345 ___________ Title ________ 345 ____________ 98 _______________ 34
The 'Views', 'Positive' and 'Negative' entries are stored in the same table so i am doing a count where setid=setid and usedtype=VS, then counting where usedtype=PF and usedtype=NF
In discoverer I can get the solution number, title and ONE of the totals but I can't seem to figure out how to get a COUNT for three different things from the same table in columns on the same row.
When I go to edit sheet -> select items once I select the COUNT option for the UsedType column in the table CS_KB_SET_USED_HISTS I can't select it again. I also have found now way to add a column based on an entered query.
If anyone could help it would be much appreciated.
Thanks
Edited by: Toolman21 on Dec 2, 2010 2:17 PM
added ______ to correct spacing.
Hi,
You can separate the column by using a case or decode.
for example create 2 calculations:
case
when usedtype='PF'
then <you original column> --- the one contain them both
else 0
end
case
when usedtype='NF'
then <you original column> --- the one contain them both
else 0
end
after that you can create the count aggregation over those.
Tamir
Similar Messages
-
mail with multiple gmail accounts sending messages from wrong email, other than the one i select:
i'm using mail on osx 10.7 with multiple gmail accounts. when i create an email, i check to be sure i'm sending/replying from the correct account. after i send it, somehow it actually sends it from a different account, other than the one i've selected "from." this is evidenced by the reply email i receive. how can i fix this?
in preferences, i have "send new messages from : account of selected mailbox"From the Mail menu bar, select
Mail ▹ Preferences...
The Mail preference dialog opens. Select the Composing tab from the row of icons at the top. From the menu labeled
Send new messages from:
choose
Account of selected mailbox
Note that this setting may have no effect if you start a new message while a VIP or smart mailbox is selected in the mailbox list. Those are saved searches, not actual mailboxes.
If the problem remains, select the Accounts tab in the preference dialog, then select the affected account in the list on the left.
In the Account Information pane, select the correct server in the menu labeled
Outgoing Mail Server (SMTP)
If there's only one server in the menu, select
Edit SMTP Server List...
and add a new server with the correct settings. If you're not sure how to do that, try the Mail Settings Lookup.
Another possibility is that the wrong card in your address book is selected as yours. Select your card in the Contacts application. Then select
Card ▹ Make This My Card
from the menu bar. -
How can a digital copy be used in a household with multiple apple ids, synced on the same computer? I want to put a digital copy on my device, and on my wife's device.
Please help.you're welcome.
actually, unless you take an extra step, the first opened swf will close. if you want the 2nd to close, the initial receiving lc will send a message to sender that causes the sender to close. -
How to set Tile count column or count row?
How to set Tile count column or count row? If not can do, How
to adjust count row or count column?
Thx for all idea.The Tile container's number of columns and rows is calculated
based on each child's width and height (or based on tileWidth and
tileHeight which you can set). If you need more control over the
layout, use Grid. -
Combine 2 Queries (from SAME table) into a SINGLE query
I have this two queries (from SAME table), and want to combine into one SINGLE query, how?
How can we use CASE WHEN THEN for such situation?
Query1:
SELECT t_inner.*,
Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min:' AS Productive_Time,
Floor(t_inner.OperatorDownTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.OperatorDownTime,3600) / 60),2,0) || 'min:' AS OperatorDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_TEST + TIME_STEP) AS ProductiveTime,
sum(TIME_IDLE) AS OperatorDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO != '9999999999'
GROUP BY SYSTEMTYPE ) t_inner
Query 2:
SELECT t_inner.*,
Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_IDLE) AS MachineDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO = '9999999999'
GROUP BY SYSTEMTYPE) t_inner
see http://postimg.org/image/koq87iyyz/ and
http://postimg.org/image/fv3zxa38nwith the first query,
SELECT t_inner.*,
Floor(t_inner.ProductiveTime/ 3600) || 'hr:' || LPAD(Floor(Mod(t_inner.ProductiveTime,3600) / 60),2,0) || 'min' AS Productive_Time
FROM
(SELECT SYSTEMTYPE,
--sum(TIME_TEST) AS TIME_TEST,
--sum(TIME_SYSTEM) AS TIME_SYSTEM,
--sum(TIME_STEP) AS TIME_STEP,
--sum(TIME_IDLE) AS TIME_IDLE,
sum(TIME_TEST + TIME_STEP) AS ProductiveTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO != '9999999999'
GROUP BY SYSTEMTYPE) t_inner
it gives output as from
http://postimg.org/image/koq87iyyz/
with the second query,
SELECT t_inner.*,
Floor(t_inner.MachineDownTime/ 3600) || 'hr ' || LPAD(Floor(Mod(t_inner.MachineDownTime,3600) / 60),2,0) || 'min' AS MachineDown_Time
FROM
(SELECT SYSTEMTYPE,
sum(TIME_IDLE) AS MachineDownTime
FROM PFODS.PPL_TESTSYSTEMS_UTILISATION
WHERE (SYSTEMTYPE = '0005-072')
AND (TS_START >= to_date('13/01/2014', 'DD/MM/YYYY'))
AND TS_End <= to_date('17/01/2014', 'DD/MM/YYYY') + 1 + (1/1440) +(59/86400)
AND MONO = '9999999999'
GROUP BY SYSTEMTYPE) t_inner
it gives output as from
http://postimg.org/image/fv3zxa38n/
I want to come those 2 queries into a single query, such that it gives both outputs as above. Let me know if you need any other information. thanks. -
Cross tab with multiple repeating columns
Hi All,
I'm developing a cross tab report.. my sample xml file is
<?xml version="1.0" encoding="UTF-8"?>
<ROWSET>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Back Office</DD_CODE>
<NOTE_DATE>12</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Back Office</DD_CODE>
<NOTE_DATE>11</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Back Office</DD_CODE>
<NOTE_DATE>14</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Back Office</DD_CODE>
<NOTE_DATE>112</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Monitoring</DD_CODE>
<NOTE_DATE>121</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Monitoring</DD_CODE>
<NOTE_DATE>122</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Monitoring</DD_CODE>
<NOTE_DATE>131</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Call - Monitoring</DD_CODE>
<NOTE_DATE>111</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Back Office</DD_CODE>
<NOTE_DATE>11</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Back Office</DD_CODE>
<NOTE_DATE>143</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Back Office</DD_CODE>
<NOTE_DATE>122</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Back Office</DD_CODE>
<NOTE_DATE>111</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Monitoring</DD_CODE>
<NOTE_DATE>1432</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Monitoring</DD_CODE>
<NOTE_DATE>112</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Monitoring</DD_CODE>
<NOTE_DATE>121</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Site Visit - Monitoring</DD_CODE>
<NOTE_DATE>123</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Visit - WDE Office</DD_CODE>
<NOTE_DATE>123</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Visit - WDE Office</DD_CODE>
<NOTE_DATE>1321</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Visit - WDE Office</DD_CODE>
<NOTE_DATE>1312</NOTE_DATE>
</ROW>
<ROW>
<NAME>Product</NAME>
<DATE>2008-05-01T00:00:00.000-05:00</DATE>
<TYPE_CODE></TYPE_CODE>
<MOST_RECENT_NOTE_DATE>1</MOST_RECENT_NOTE_DATE>
<DD_CODE>Visit - WDE Office</DD_CODE>
<NOTE_DATE>211</NOTE_DATE>
</ROW>
</ROWSET>
If I use the cross tab wizard ...I'm get the following output..
-------------Call - Back Office-------Call - Monitoring-------Site Visit - Back Office-------Site Visit -Monitoring-----Visit - WDE Office
product 12 121 11 1432 123
but I'm looking for output like...
-------------Call - Back Office-----Call - Monitoring------Site Visit - Back Office------Site Visit -Monitoring-------Visit - WDE Office
product-------12 11 14 112-----------121 122 131 111----------11 143 122 111------------------1432 112 121 123 ---------123 1321 1312 211The numbers under each column are dynamic ..I might be getting 2,3,4..(In this case all are four)...I looked at the below link but it had static 2 repeating columns..but in my case the repeating columns are unknown...
http://winrichman.blogspot.com/2008/09/crosstab-with-multiple-repeating.html
Is is possible to build a cross tab like that..?
Thanks in Advance..Hi..
Thanks alot for your time..
can I e-mail you my actual xml file..? becuase if there are multiple rows(multiple <?NAME?>)...the column headers(DD_CODE) are repeating for every row(<?NAME?>)..also is it possible to get each NOTE_DATE in a cell(here all the NOTE_DATE are displaying in a table)....
present output...
-------------Call - Back Office-----Call - Monitoring------Site Visit - Back Office------Site Visit -Monitoring-------Visit - WDE Office
product-------12 11 14 112-----------121 122 131 111----------11 143 122 111------------------1432 112 121 123 ---------123 1321 1312 211
-------------Call - Back Office-----Call - Monitoring------Site Visit - Back Office------Site Visit -Monitoring-------Visit - WDE Office
product1-------11 15 13 12-----------00 111 132 444----------12 434 123 171------------------1832 162 221 124 ---------143 1231 1311 241
looking for output like..
-------------Call - Back Office-----Call - Monitoring------Site Visit - Back Office------Site Visit -Monitoring-------Visit - WDE Office
product-------12 11 14 112-----------121 122 131 111----------11 143 122 111------------------1432 112 121 123 ---------123 1321 1312 211
product1-------11 15 13 12-----------00 111 132 444----------12 434 123 171------------------1832 162 221 124 ---------143 1231 1311 241Thanks in Advance... -
ORA-1461 with multiple NVARCHAR2 columns
Hi,
I use version 10.2.0.1 version of ojdbc with an Oracle9i database and get ORA-1461 (can bind a LONG value only for insert into a LONG column) when updating multiple NVARCHAR2 columns in the same table.
What is strange is:
if I set column1=value1 and column2 null it works
if I set column2=value2 and column1 null it works
But if i set column1=value1 AND column2=value2 I have this exception.
I assume that because using UTF8 I can have an exception for one column if less than 4000 because of nb bytes used by one character but can't understand why different columns sizes interact...
Database parameters :
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET UTF8
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE (don't know if usefull)
Can anyone tell me out to make it work ?
I tried with driver 10.2.0.3 and have the same issue.
Thanks for your help.
Message was edited by:
user610168Hi,
I use version 10.2.0.1 version of ojdbc with an Oracle9i database and get ORA-1461 (can bind a LONG value only for insert into a LONG column) when updating multiple NVARCHAR2 columns in the same table.
What is strange is:
if I set column1=value1 and column2 null it works
if I set column2=value2 and column1 null it works
But if i set column1=value1 AND column2=value2 I have this exception.
I assume that because using UTF8 I can have an exception for one column if less than 4000 because of nb bytes used by one character but can't understand why different columns sizes interact...
Database parameters :
NLS_CHARACTERSET AL32UTF8
NLS_NCHAR_CHARACTERSET UTF8
NLS_LENGTH_SEMANTICS BYTE
NLS_NCHAR_CONV_EXCP FALSE (don't know if usefull)
Can anyone tell me out to make it work ?
I tried with driver 10.2.0.3 and have the same issue.
Thanks for your help.
Message was edited by:
user610168 -
Find and replace with multiple files and with a watch folder
I am trying to create a watch folder that uses red_menace script to:
1. Have a folder that receives multiple xml files that run the script one by one.
2. then move the files to an output folder.
I tried modifying the set TheFIle to choose file -- the original text file to:
with multiple selections allowed
But that doesn't seem to work. I know i'm missing a step. Any help is much appreciated!
Thanks!
The way i'd like to setup things is having an input folder on the desktop (or just have the application on the desktop and I can drag the files onto it), and let it do it's thing. Once it's done have it export the xml files into an output folder.
Here's what i got so far:
on open
set TheFIle to choose file -- the original text file
set TheFolder to ("Macintosh HD:Users:user1:Desktop:out") -- the folder for the output file
set TheName to (GetUniqueName for TheFIle from TheFolder) -- the name for the output file
set TheText to read TheFIle -- get the text to edit
set Originals to {"KPCALDATE", "KPCALEVENT", "KPCALDAY", "KPCALBODY", "obituaries name", "" & return & "</cstyle></pstyle>" & return & "<pstyle name=\"obituaries text\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\" font=\"ADV AGBook-Medium 2\">", "<pstyle name=\"Recipe Ingredients\"><cstyle>", " .com", " .net", " .org", " .edu", "www .", "www. ", "Ho- nolulu", "<pstyle name=\"kicker 12\"><cstyle allcaps=\"1\">fashion news</cstyle><cstyle allcaps=\"1\">" & return & "</cstyle></pstyle>" & return & "", "<component name=\"Headline 1\" type=\"Headline\">" & return & "<header>" & return & "<field name=\"Component name\" type=\"string\" value=\"Headline 1\"/>" & return & "<field name=\"Component type\" type=\"popup\" value=\"Headline\"/>" & return & "</header>" & return & "<body>" & return & "<pstyle name=\"hed STANDARD 36\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle allcaps=\"1\">", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\">", "<pstyle name=\"tagline\"><cstyle>-", "-", "
Per serving:", "<pstyle name=\"Titlebar - mini, red\"><cstyle allcaps=\"1\">NATION & World </cstyle><cstyle allcaps=\"1\">Report</cstyle><cstyle allcaps=\"1\">" & return & "</cstyle></pstyle>" & return & "", "</cstyle></pstyle>"} -- the terms that can be replaced
set Replacements to {"subhed", "subhed", "subhed", "Normal", "obituaries text", ", ", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\" font=\"ADV AGBook-Medium 2\">", "<pstyle name=\"Recipe Ingredients\"><cstyle>
", ".com", ".net", ".org", ".edu", "www.", "www.", "Honolulu", "", "<component name=\"Headline1\" type=\"Headline\">" & return & "<header>" & return & "<field name=\"Component name\" type=\"string\" value=\"Headline1\"/>" & return & "<field name=\"Component type\" type=\"popup\" value=\"Headline\"/>" & return & "</header>" & return & "<body>" & return & "<pstyle name=\"hed STANDARD 27\"><cstyle>", "<pstyle name=\"obituaries text\"><cstyle allcaps=\"1\">", "<pstyle name=\"obituaries text\"><cstyle name=\"Graphics Bold leadin\">", "<pstyle name=\"tagline\"><cstyle>", " ", "
Per serving:", "","" & return & "</cstyle></pstyle>"} -- the replacement terms
repeat with AnItem from 1 to count Originals
set TheText to (replaceText of TheText from (item AnItem of Originals) to (item AnItem of Replacements))
end repeat
try -- write a new output file
tell application "Finder" to make new file at TheFolder with properties {name:TheName}
set OpenFile to open for access (result as alias) with write permission
write TheText to OpenFile starting at eof
close access OpenFile
on error errmess
try
log errmess
close access OpenFile
end try
end try
end open
to GetUniqueName for SomeFile from SomeFolder
check if SomeFile exists in SomeFolder, creating a new unique name if needed
parameters - SomeFile [mixed]: a source file path
SomeFolder [mixed]: a folder to check
returns [text]: a unique file name and extension
set {Counter, Divider} to {"00", "_"}
-- get the name and extension
set {name:TheName, name extension:TheExtension} to info for file (SomeFile as text)
if TheExtension is missing value then set TheExtension to ""
set TheName to text 1 thru -((count TheExtension) + 2) of TheName
set NewName to TheName & "." & TheExtension
tell application "System Events" to tell (get name of files of folder (SomeFolder as text))
repeat while it contains NewName
set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- leading zero
set NewName to TheName & Divider & Counter & "." & TheExtension
end repeat
end tell
return NewName
end GetUniqueName
to EditItems of SomeItems given Title:TheTitle, Prompt:ThePrompt
displays a dialog for multiple item edit (note that a return is used between each edit item)
for each of the items in SomeItems, a line containing it's text is placed in the edit box
the number of items returned are padded or truncated to match the number of items in SomeItems
parameters - SomeItems [list]: a list of text items to edit
TheTitle [boolean/text]: use a default or the given dialog title
ThePrompt [boolean/text]: use a default or the given prompt text
returns [list]: a list of the edited items, or {} if error
set {TheItems, TheInput, TheCount} to {{}, {}, (count SomeItems)}
if TheCount is less than 1 then return {} -- error
if ThePrompt is in {true, false} then -- "with" or "without" Prompt
if ThePrompt then
set ThePrompt to "Edit the following items:" & return -- default
else
set ThePrompt to ""
end if
else -- fix up the given prompt a little
set ThePrompt to ThePrompt & return
end if
if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" Title
set TheTitle to "Multiple Edit Dialog" -- default
else
set TheTitle to ""
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SomeItems, AppleScript's text item delimiters} to {SomeItems as text, TempTID}
set TheInput to paragraphs of text returned of (display dialog ThePrompt with title TheTitle default answer SomeItems)
repeat with AnItem from 1 to TheCount -- pad/truncate entered items
try
set the end of TheItems to (item AnItem of TheInput)
on error
set the end of TheItems to ""
end try
end repeat
return TheItems
end EditItems
to replaceText of SomeText from OldItem to NewItem
replace all occurances of OldItem with NewItem
parameters - SomeText [text]: the text containing the item(s) to change
OldItem [text]: the item to be replaced
NewItem [text]: the item to replace with
returns [text]: the text with the item(s) replaced
set SomeText to SomeText as Unicode text -- TID's are case insensitive with Unicode text
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, OldItem}
set {ItemList, AppleScript's text item delimiters} to {text items of SomeText, NewItem}
set {SomeText, AppleScript's text item delimiters} to {ItemList as text, TempTID}
return SomeText
end replaceText
Message was edited by: gamebreakersWhen you use the open or adding folder items to handlers, you need to add the parameters for the file items passed to them.
I'll go ahead and post the applet/droplet version of my original script from the previous topic for reference:
<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px; height: 340px;
color: #000000;
background-color: #FFEE80;
overflow: auto;"
title="this text can be pasted into the Script Editor">
-- search and replace multiple items applet/droplet/folder action
-- the terms to replace - edit as needed
property EditableItems : {¬
"one", ¬
"two", ¬
"three", ¬
"four", ¬
"five", ¬
"six", ¬
"seven", ¬
"eight", ¬
"nine", ¬
"ten", ¬
"eleven", ¬
"twelve", ¬
"thirteen", ¬
"fourteen", ¬
"fifteen", ¬
"sixteen", ¬
"seventeen", ¬
"eighteen", ¬
"nineteen", ¬
"twenty"}
-- the folder for the output file(s) - change as needed
property TheFolder : (path to desktop)
property LastEditItems : EditableItems
on run
the applet/droplet was double-clicked
open (choose file with multiple selections allowed)
end run
on open TheItems
items were dropped onto the applet/droplet
parameters - TheItems [list]: a list of the items (aliases) dropped
returns nothing
repeat with AnItem in TheItems
ReplaceMultipleItems from AnItem
end repeat
end open
on adding folder items to this_folder after receiving these_items
folder action - items were added to a folder
parameters - this_folder [alias]: the folder added to
these_items [list]: a list if items (aliases) added
returns nothing
repeat with AnItem in these_items
ReplaceMultipleItems from AnItem
end repeat
end adding folder items to
to ReplaceMultipleItems from SomeFile
replace multiple text items in SomeFile
parameters - SomeFile [alias]: the file to replace items in
returns nothing
set TheName to (GetUniqueName for SomeFile from TheFolder) -- the name for the output file
set TheText to read SomeFile -- get the text to edit
set Originals to (choose from list EditableItems default items LastEditItems with prompt "Select the terms to replace:" with multiple selections allowed) -- the specific terms to replace
set LastEditItems to Originals
set Replacements to (EditItems of Originals with Title given Prompt:"Edit the following replacement terms:") -- the replacement terms
repeat with AnItem from 1 to count Originals
set TheText to (ReplaceText of TheText from (item AnItem of Originals) to (item AnItem of Replacements))
end repeat
try -- write a new output file
tell application "Finder" to make new file at TheFolder with properties {name:TheName}
set OpenFile to open for access (result as alias) with write permission
write TheText to OpenFile starting at eof
close access OpenFile
on error errmess
try
log errmess
close access OpenFile
end try
end try
end ReplaceMultipleItems
to GetUniqueName for SomeFile from SomeFolder
check if SomeFile exists in SomeFolder, creating a new unique name if needed
parameters - SomeFile [mixed]: a source file path
SomeFolder [mixed]: a folder to check
returns [text]: a unique file name and extension
set {Counter, Divider} to {"00", "_"}
-- get the name and extension
set {name:TheName, name extension:TheExtension} to info for file (SomeFile as text)
if TheExtension is in {missing value, ""} then
set TheExtension to ""
else
set TheExtension to "." & TheExtension
end if
set {NewName, TheExtension} to {TheName, (ChangeCase of TheExtension to "upper")}
set TheName to text 1 thru -((count TheExtension) + 1) of TheName
tell application "System Events" to tell (get name of files of folder (SomeFolder as text))
repeat while it contains NewName
set Counter to text 2 thru -1 of ((100 + Counter + 1) as text) -- leading zero
set NewName to TheName & Divider & Counter & TheExtension
end repeat
end tell
return NewName
end GetUniqueName
to EditItems of SomeItems given Title:TheTitle, Prompt:ThePrompt
displays a dialog for multiple item edit (note that a return is used between each edit item)
for each of the items in SomeItems, a line containing it's text is placed in the edit box
the number of items returned are padded or truncated to match the number of items in SomeItems
parameters - SomeItems [list]: a list of text items to edit
TheTitle [boolean/text]: use a default or the given dialog title
ThePrompt [boolean/text]: use a default or the given prompt text
returns [list]: a list of the edited items, or {} if error
set {TheItems, TheInput, TheCount} to {{}, {}, (count SomeItems)}
if TheCount is less than 1 then return {} -- error
if ThePrompt is in {true, false} then -- "with" or "without" Prompt
if ThePrompt then
set ThePrompt to "Edit the following items:" & return -- default
else
set ThePrompt to ""
end if
else -- fix up the given prompt a little
set ThePrompt to ThePrompt & return
end if
if TheTitle is in {true, false} then if TheTitle then -- "with" or "without" Title
set TheTitle to "Multiple Edit Dialog" -- default
else
set TheTitle to ""
end if
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
set {SomeItems, AppleScript's text item delimiters} to {SomeItems as text, TempTID}
set TheInput to paragraphs of text returned of (display dialog ThePrompt with title TheTitle default answer SomeItems)
repeat with AnItem from 1 to TheCount -- pad/truncate entered items
try
set the end of TheItems to (item AnItem of TheInput)
on error
set the end of TheItems to ""
end try
end repeat
return TheItems
end EditItems
to ReplaceText of SomeText from OldItem to NewItem
replace all occurances of OldItem with NewItem
parameters - SomeText [text]: the text containing the item(s) to change
OldItem [text]: the item to be replaced
NewItem [text]: the item to replace with
returns [text]: the text with the item(s) replaced
set SomeText to SomeText as text
if SomeText contains OldItem then
set {TempTID, AppleScript's text item delimiters} to {AppleScript's text item delimiters, OldItem}
try
set {ItemList, AppleScript's text item delimiters} to {text items of SomeText, NewItem}
set {SomeText, AppleScript's text item delimiters} to {ItemList as text, TempTID}
on error ErrorMessage number ErrorNumber -- oops
set AppleScript's text item delimiters to TempTID
error ErrorMessage number ErrorNumber
end try
end if
return SomeText
end ReplaceText
to ChangeCase of SomeText to CaseType
changes the case or capitalization of SomeText to the specified CaseType using Python
parameters - SomeText [text]: the text to change
CaseType [text]: the type of case desired:
"upper" = all uppercase text
"lower" = all lowercase text
"title" = uppercase character at start of each word, otherwise lowercase
"capitalize" = capitalize the first character of the text, otherwise lowercase
returns [text]: the changed text
set SomeText to SomeText as text
if CaseType is not in {"upper", "lower", "title", "capitalize"} then return SomeText
return (do shell script "/usr/bin/python -c \"import sys; print unicode(sys.argv[1], 'utf8')." & CaseType & "().encode('utf8')\" " & quoted form of SomeText)
end ChangeCase
</pre>
Edit: how does the choose from list dialog handle those big strings? I'm guessing not very well - is that why you avoided using them?
Message was edited by: red_menace -
Several count() statements from same table?
Hello all,
I have to count number of bills (several million entries) connected to contracts (aprox. 75000 entries). When I try
select contract.number,count(bill.id),count(a.id)
from contract,bill, bill a
where bill.contractid = contract.id
and bill.type = 0
and a.contractid = contract.id
and a.type = 1
the result of count(a.id) is always the same as count(bill.id). Well knowing that this is wrong, I've tried to change the count() into own select-statments but that doesn't help and the performance is more than poor.
Does anybody have an idea to get the correct count-results with a suitable performance?
Thanks CarstenHi, Carsten,
Instead of joing separate copies of the bill table for each type (for which you might need outer joins), just join one copy, on the broadest possible conditions.
You can use CASE expressions to count which rows joined on different criteria, like this:
SELECT contract.contract_number
, COUNT (CASE WHEN bill.type = 0 THEN bill.id END) AS type_0_cnt
, COUNT (CASE WHEN bill.type = 1 THEN bill.id END) AS type_1_cnt
FROM contract
, bill
WHERE contract.id = bill.contractid
AND bill.type IN (0, 1)
GROUP BY contract.contract_number
;Output:
CONTRACT_NUMBER TYPE_0_CNT TYPE_1_CNT
contract 1 4 2Do you really want 1 in the last column? If so, explain how you get that value.
NUMBER is a reserver word in Oracle, so it's not a good column name.
Edited by: Frank Kulash on Nov 30, 2009 9:38 AM
Edited by: Frank Kulash on Nov 30, 2009 9:52 AM
Changed "THEN 1" to 'THEN bill.id", after Bhushan -
Exit variable with multiple values or with ranges
Dear Experts,
I have a date exit variable used in a planning level. If the variable has a single value, I am able to execute the planning function. But if the exit is populated with a range or multiple single values, I am unable to execute the planning function. I get this message 'Variable "ZXPRDATE" is not restricted to a single value'.
I should be able to read all records from the cube in date range of one week for repost. Please advice if this is possible.
Thanks,
GnanaHi Mayank,
Yes, I am using the same variable for repost function also.
Let me explain in detial.
Req: I have a planning level with product, effective date and count(keyfigure). I want all products that has a count keyfigure value for the last one week.
If my effective date is a single value, I get all the list of products on that particular day. But, if my effective date has multiple dates or a date range, nothing is read from the data base.
Please advice.
Thanks,
Gnana -
Help With Multiple Class Objects With Methods
I am dealing with multiple classes. I am wondering why I am getting an error on this line it's by the bottom
obj1.array() = newArray[i];
It gives the array out of bounds. On another note I believe I can change obj1 to just like incomingArray if I wanted correct since it's just a reference because I should be able to do this method sort on any array.
method : selSort
input - none
output - void
This is where we sort the arary
Pseudocode Code:
1 Initialize variable oldlocation to hold spot of smallest number in original array
2 Initialize variable smallnumber to store smallest number in original array
3 Initialize new integer array
4 Set new array length to length of original array
5 Initialize variable length to store lengh of new array
6 For i = 0 and continue till i < new array length
6.1 Find smallest number in original array
6.2 Put the smallest number in new array
6.3 Remove smallest number from original array
7 Copy contents of new array that is sorted to original array
Basic concept is to repetitively find the smallest
(or largest) item in the original array. Once smallest
is found, move it to the next spot in a new array and
remove it from the old array.
public void selSort ()
int oldlocation = 0;
int smallnumber = 0;
int [] newArray = obj1.array();
newArray = new int [obj1.length()];
int length = newArray.length;
for (int i = 0; i < newArray.length; i++)
// System.out.println("Test 1");
newArray[i] = obj1.sortSmall();
// System.out.println("Test 2");
smallnumber = obj1.sortSmall();
// System.out.println("This is the smallest number " + smallnumber);
oldlocation = obj1.location(smallnumber);
// System.out.println("This is the old location " + oldlocation);
// System.out.println("Test 3");
obj1.removeLocation(oldlocation);
// System.out.println("Test 4");
System.out.println();
System.out.println("The sorted array looks like");
for (int k = 0; k < newArray.length; k++)
System.out.print(newArray[k] + " ");
System.out.println();
System.out.println();
obj1.resize(newArray.length);
for (int i = 0; i < newArray.length; i++)
obj1.array()[i] = newArray[i];
return;method : selSort
input - none
output - void
This is where we sort the arary
Pseudocode Code:
1 Initialize variable oldlocation to hold spot of smallest number in original array
2 Initialize variable smallnumber to store smallest number in original array
3 Initialize new integer array
4 Set new array length to length of original array
5 Initialize variable length to store lengh of new array
6 For i = 0 and continue till i < new array length
6.1 Find smallest number in original array
6.2 Put the smallest number in new array
6.3 Remove smallest number from original array
7 Copy contents of new array that is sorted to original array
Basic concept is to repetitively find the smallest
(or largest) item in the original array. Once smallest
is found, move it to the next spot in a new array and
remove it from the old array.
public void selSort ()
int oldlocation = 0;
int smallnumber = 0;
int [] newArray = obj1.array();
newArray = new int [obj1.length()];
int length = newArray.length;
for (int i = 0; i < newArray.length; i++)
// System.out.println("Test 1");
newArray[i] = obj1.sortSmall();
// System.out.println("Test 2");
smallnumber = obj1.sortSmall();
// System.out.println("This is the smallest number " + smallnumber);
oldlocation = obj1.location(smallnumber);
// System.out.println("This is the old location " + oldlocation);
// System.out.println("Test 3");
obj1.removeLocation(oldlocation);
// System.out.println("Test 4");
System.out.println();
System.out.println("The sorted array looks like");
for (int k = 0; k < newArray.length; k++)
System.out.print(newArray[k] + " ");
System.out.println();
System.out.println();
obj1.resize(newArray.length);
for (int i = 0; i < newArray.length; i++)
obj1.array() = newArray[i];
return; -
Counting Columns in a Structure or Table?
HI,
can any one tell me the best way to count the number of Columns a structure or internal table has.
Thanks
CHi,
Try using the describe field type s_struc components n..
data: begin of s_struc,
field1,
field2,
end of s_struc.
data: v_int type int4.
describe field s_struc type s_struc components v_int.
write: / v_int.
Thanks,
Naren
Message was edited by: Narendran Muthukumaran -
How to check which column data differs from master table and archive table
Hi All,
i have two tables, table a (a1 number,a2 varchar2,a3 varchar2) and table b (b1 number,b2 varchar2,b3 varchar2).
how to check the data in both the table are same( including all columns).
data in a.a1 is same as b.b1 and a.a2 is same as b.b2 like that.
if they not same , i need to know which field differs.
Kindly Share ur ideas.887268 wrote:
thanks Sven W. ,
above reply clearly shows what my question is.
one column must be primary key, based on that key i need to find out which are the fields having different data..
im strugling with this, i tried the following already, but not able to get.
select the columns from a MINUS select the columns from b.
-- from this i can find whether the difference occurred or not.
but i cant able to get which are the fields value changed.Good. Then you would match the rows using the PK column and need to compare the columns
Instead of a MINUS + UNION ALL + MINUS we can now use a FULL OUTER JOIN
It is a little task to write out all column names, but 40 columns can be handled.
This statement would show you both tables with matching rows on the same line.
select a.*, b.*
from a
FULL OUTER JOIN b on a.id = b.idNow filter/check for mismatches
select case when a.col1 != b.col1 then 'COL1 value changed'
when a.col2 != b.col2 then 'COL2 value changed'
when a.col3 != b.col3 then 'COL3 value changed'
end as compare_result
,a.*, b.*
from a
FULL OUTER JOIN b on a.id = b.id
/* return only non matching columns */
where (a.col1,a.col2,a.col3) != (b.col1,b.col2,b.col3) You might need to add nvls to take care of null values. Test this!
Another way could be to group upon the primary key
select *
from (
select id
,count(distinct col1)-1 cnt_col1
,count(distinct col2)-1 cnt_col2
,count(distinct col3)-1 cnt_col3
from
select 'A' source, a.*
from a
UNION ALL
select 'B' source, b.*
from b)
group by ID
/* only records with differences */
where 1 in (cnt_col1, cnt_col2, cnt_col3)
;The count columns will hold either 1 or 0. If it is 1 then this column has a difference. -
Inserting multiple records into a database from a table
I have a dynamic table with rows upto 10. i am trying to insert all the records in these rows into a database ( msaccess)
table name: Table1 ( in my form )
Database table : movies_comments ( as posted in stefan's forums ).
table columns: username, movieid, comments
i am using the following code.
Database.ExecSQL() function is as posted in stefcamerons forums.
var tlength = xfa.resolveNode("form1.#subform[0].Table1.Row1[*]").length;
xfa.host.messageBox("tlength is :" +tlength);
for ( var i = 1; i <= tlength; i++)
var username = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].user_name").rawValue;
var movieID = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].movie_id").rawValue;
var commentS = xfa.resolveNode("form1.#subform[0].Table1.Row1["+i+"].comment_").rawValue;
Database.ExecSQL("INSERT INTO movie_comments (username, movieId, comment) VALUES ('username','movieID', 'commentS');");
i am trying to insert multiple records using the code above. But i am getting error
GeneralError: Operation failed.
XFAObject.resolveNode:1:XFA:form1[0]:#subform[0]:Button1[0]:click
SOM expression returned list when single result was expected
suggest me an alternate way to insert multiple records from a table into a database.
thank Qfigured it out. I changed the ...OR (alternative names = colname) in the recordset to ...OR (alternative names LIKE %colname%). Works like a charm now- the result of a good night's sleep.
-
With SSAS Tabular using Excel:
If I place a single measure MyMeasure:=SUM([ColumnNameOnFactTable])
it happens very quickly.
I have 3 other dimensions from 3 other dimension tables on Excel with this "MyMeasure" as the value.
YearMonth in the columns and say Department ID, Account ID, and Call Center (just all made up for this example).
Now, when I place a second measure from that same table as "MyMeasure" call it SecondMeasure:SUM([AnotherColumnNameOnFactTable]) the OLAP query in Excel spins, and sometimes even throws the out of memory error.
The server has 24 GB of RAM, and the model is only a few hundred megs.
I assume something must be off here?
Either I've done something foolish with the model or I'm missing something?
EDIT:
It SEEMS to work better if I place all y measures on the Excel grid first, then go and add my "dimensions", adding the measures after the dimensions appears to incur a rather steep penalty?
Number of rows:
Largest table (account ID lookup has 180,000)
Fact table has 7,000
The others are 1,000 or less...Hi,
Thank you for your question.
I am trying to involve someone more familiar with this topic for a further look at this issue. Sometime delay might be expected from the job transferring. Your patience is greatly appreciated.
Thank you for your understanding and support.
Regards,
Charlie Liao
TechNet Community Support
Maybe you are looking for
-
Hi, Our hosted site just upgraded to 4.2.1 and I am getting: The requested URL /pls/apex/wwv_flow.accept was not found on this server. After trying to make a change on a master/detail form. I thought Apex 4.2 increased the # of fields on a master det
-
What is better Mac Mini or Mac Pro and 4K 40" screen or iMac 5K for work with Exel
I am working on Macbook pro retina for around 16 hours a day, it is ok but the screen is to small. I am opening about 25 - 30 EXCEL windows, 20 - 25 safari windows at the same time. Excel windows are small, they only show 40 rows and S column Now
-
Hi, How could I start an executable from within my Java application? Something like: public void start_converter(String toFormat){ String newFormat = toFormat; if newFormat.equalsIgnoreCase("MIF"){ //call the MapInfo program System.startup("MapBasic/
-
We are using Xerces implementation of jaxp - (xercesImpl.jar, xmlParserAPIs.jar). Below is my code: DocumentBuilder builder = getBuilder(); java.io.FileInputStream fi = new java.io.FileInputStream(�file://c$/config/tmp.xml�); org.w3c.dom.Documen
-
Excel VBA add-in to create a PDF: What is acrodistdll.dll?
My Excel VBA add-in prints an Excel sheet with a list of drawing numbers, then prints all the drawings (it communicates with a CAD and a CAM application via COM). Then it repeats the cycle many times, with different list of drawings. At the end I hav