Silly request, needed yesterday: "queries stored in table, to Excel"
I have a fast-and-dirty requirement (CF8) which needs a fast-and-dirty solution ... "hacks welcome." I'd like to stumble-upon existing code that does as much of this work for me as possible.
I've got a table of queries. (That is to say, one of the columns is a text column containing a known-good SQL statement.) Those queries might contain a few parameters, and I've arranged for those to be identified in #some_name# syntax, within the text, just for simplicity All of these parameters are, and always will be, "dates."
The application is internal-only and the user is trustworthy. "Hijacking," injection and so forth is not a concern.
The user needs to be able to choose a query, enter the parameters needed, and poof, out pops a page in Microsoft Excel containing the query results.
I can see from a quick Google search that "this requirement has been done to death." So, can anyone quickly point me to the closest thing they've stumbled-upon that matches these requirements? Yes, I want to be lazy.
I found the following very satisfactory answer, and in fairly short order: (Assumes Excel 2003 or better.)
You can run "cfquery" no-problem getting the query from a string variable, if you use the function PreserveSingleQuotes() on the string.
Next, by whatever means, construct an XML document as your output. Excel defines a full-featured XML representation for workbooks, sheets, cell data, and formulas. This is discussed in the Excel documentation. The schemas are, e.g. "urn:schemas-microsoft-com:office:spreadsheet"
Include this: <cfheader name="content-disposition" value="inline; filename=report_output.xls" />
Now, use the <cfcontent> tag to output the XML data as type="application/msexcel"
Even though the file is an XML file, Excel understands it perfectly.
Now... how'd I find all this stuff out, so fast? Yep! "Google it!" There are plenty of code-samples that illustrate the technique. (Disregard any that don't use XML. Ones that require special APIs are also unnecessary.)
Similar Messages
-
Need to upload morethan 20 tables from excel sheet
Hi Everyone,
I need to upload 20 different tables from the excel sheets. One way to implement is to write 20 different report programs.
But can we meet the above requirement from a single report program?
Regards,
YugeshHi
You can do from One report. You have to take 20 diff. naming convention of your file and then read these fille and upload them into appropriate table.
Regards,
Shiv. -
How to export data from a Dynpro table to Excel file?
Hi
Here I go again. I read the post <b>Looking for example to export data from a DynPro table to Excel file</b> and put the code lines into a Web Dynpro Project where we need to export a dynpro table to Excel file but exactly at line 23 it doesn't recognize <b>workBook = new HSSFWorkbook();</b>
1 //Declare this in the end between the Begin others block.
2
3 private FileOutputStream out = null;
4 private HSSFWorkbook workBook = null;
5 private HSSFSheet hsSheet = null;
6 private HSSFRow row = null;
7 private HSSFCell cell = null;
8 private HSSFCellStyle cs = null;
9 private HSSFCellStyle cs1 = null;
10 private HSSFCellStyle cs2 = null;
11 private HSSFDataFormat dataFormat = null;
12 private HSSFFont f = null;
13 private HSSFFont f1 = null;
14
15 //Code to create the Excel.
16
17 public void onActionExportToExcel(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
18 {
19 //@@begin onActionExportToExcel(ServerEvent)
20 try
21 {
22 out = new FileOutputStream("C:/mydirectory/myfiles/testexcel.xls");
23 workBook = new HSSFWorkbook();
24 hsSheet = workBook.createSheet("My Sheet");
25 cs = workBook.createCellStyle();
26 cs1 = workBook.createCellStyle();
27 cs2 = workBook.createCellStyle();
28 dataFormat = workBook.createDataFormat();
29 f = workBook.createFont();
30 f1 = workBook.createFont();
31 f.setFontHeightInPoints((short) 12);
32 // make it blue
33 f.setColor( (short)HSSFFont.COLOR_NORMAL );
34 // make it bold
35 // arial is the default font
36 f.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
37
38 // set font 2 to 10 point type
39 f1.setFontHeightInPoints((short) 10);
40 // make it red
41 f1.setColor( (short)HSSFFont.COLOR_RED );
42 // make it bold
43 f1.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
44 f1.setStrikeout(true);
45 cs.setFont(f);
46 cs.setDataFormat(dataFormat.getFormat("#,##0.0"));
47
48 // set a thick border
49 cs2.setBorderBottom(cs2.BORDER_THICK);
50
51 // fill w fg fill color
52 cs2.setFillPattern((short) HSSFCellStyle.SOLID_FOREGROUND);
53 cs2.setFillBackgroundColor((short)HSSFCellStyle.SOLID_FOREGROUND);
54 // set the cell format to text see HSSFDataFormat for a full list
55 cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text"));
56 cs2.setFont(f1);
57 cs2.setLocked(true);
58 cs2.setWrapText(true);
59 row = hsSheet.createRow(0);
60 hsSheet.createFreezePane(0,1,1,1);
61 for(int i=1; i<10;i++)
62 {
63 cell = row.createCell((short)i);
64 cell.setCellValue("Excel Column "+i);
65 cell.setCellStyle(cs2);
66 }
67 workBook.write(out);
68 out.close();
69
70 //Read the file that was created.
71
72 FileInputStream fin = new FileInputStream("C:/mydirectory/myfiles/testexcel.xls");
73 byte b[] = new byte[fin.available()];
74 fin.read(b,0,b.length);
75 fin.close();
76
77 wdContext.currentContextElement().setDataContent(b);
78 }
79 catch(Exception e)
80 {
81 wdComponentAPI.getComponent().getMessageManager().reportException("Exception while reading file "+e,true);
82 }
83 //@@end
84 }
I don't know why this happen? Any information I will appreciate it.
Thanks in advance!!!
Tokio Franco ChangAfter test the code lines appears this error stacktrace:
[code]
java.lang.NoClassDefFoundError: org/apache/poi/hssf/usermodel/HSSFWorkbook
at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.ExportToExcel.onActionAct1(ExportToExcel.java:232)
at com.sap.tc.webdynpro.progmodel.api.iwdcustomevent.wdp.InternalExportToExcel.wdInvokeEventHandler(InternalExportToExcel.java:147)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleAction(WebDynproMainTask.java:101)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.handleActionEvent(WebDynproMainTask.java:304)
at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:252)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:392)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:345)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:323)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:865)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:240)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:95)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:159)
Thanks in advance!!!
Tokio Franco Chang
[/code] -
I need to know in which table the long text is stored
Using the transaction code 'AC03' , I go to the ' Create Service Master Page '. Navigating through the page , I could see a ' long text ' button . Once it is being clicked , the white space for text entry comes .
My query is this -> <b>I need to know in which table the long text is stored and the name of the field ??</b>
If one goes to the table 'ASMDT' , one can find a field 'KZLTX' , which is a long text indicator, but not a long text storage field ...... plz helpHi
Use the function module READ_TEXT for fetching the long text..
I came across similar situation in my project where i need to fetch the long text for Notification no.I have used the following code for fetching the Notificatin long text,you can just compare this logic and change accordingly.
CALL FUNCTION 'READ_TEXT'
EXPORTING
CLIENT = SY-MANDT
ID = 'LTXT'
LANGUAGE = WA_STRUCT12-KZMLA
NAME = QMNUM
OBJECT = 'QMEL'
TABLES
LINES = INT_TAB13.
Specify LANGUAGE if you wanna fetch the long text regardless of the log on lang.The resulting long text will be stored in the itab INT_TAB13 which can be defined with reference to the structure TLINE.
Hope this helps.
Regards,
Hakim -
Run queries against system tables for oracle BPEL processes
I want to run queries against system tables for oracle BPEL processes. It is becoming very difficult for me to us EM as it is very slow,
and not all the time, it is sufficient for our needs.
We are doing load testing and we want find out info like how many requests came in and how many faulted and what time is taken by each request...
So do any of you have the query that I can use and tables that I need to go against?Use the BPEL hydration database table "cube_instance".
There should be plenty of example in the forum regarding this table. -
Concurrent delete queries on one table
Hi folks,
I just recently started working with SQL server. I did my research and I guess that the post http://social.msdn.microsoft.com/Forums/en-US/7fe7499e-10a5-4371-84a4-aa1df8187a04/can-i-prevent-deadlock-during-concurrent-delete?forum=transactsql hits and somehow
sovles my problem 100%.
I am glad to have my issue resolved but I am also interested in understanding what went wrong deep inside as much as learn what I might do better. My scenario:
4 processes updating disjunct entries at different intervals within the same table and issuing delete queries on that table. Sometimes (maybe once a day) that gives me a deadlock. colums: value, mainclass, subclass, timestamp with a clustered index at timestamp
(My statement is of the form "delete from table where maintype=sth and subtype=sth and timestamp=st")
I'll append a sample deadlock graph. My main questions, which I couldn't answer so far:
1. Is this expected behaviour or should SQL Server be able to handle such requests, or to put it right do I have to care for structures that avoid the above scenario, do I have to reconfigure or is there sth else to look at?
2. Is this a configuration problem?
3. I also do not understand why the report states that the processes fought for page ids when the lock escalation type was set to table.
4. As far as I got to know until now having a clustered index on the timestamp colum is likely to boost my problem rather than solving it?
I am really looking forward to any insights you can give.
Bye,
Lamu
<deadlock>
<victim-list>
<victimProcess id="process56d746188" />
</victim-list>
<process-list>
<process id="process56d746188" taskpriority="0" logused="0" waitresource="PAGE: 5:1:210559 " waittime="3120" ownerId="2642852343" transactionname="user_transaction" lasttranstarted="2014-09-05T11:16:12.683" XDES="0x5a36bd740" lockMode="U" schedulerid="4" kpid="3204" status="suspended" spid="72" sbid="1" ecid="4" priority="0" trancount="0" lastbatchstarted="2014-09-05T11:16:12.990" lastbatchcompleted="2014-09-05T11:16:12.683" lastattention="1900-01-01T00:00:00.683" clientapp="WIRELESS LOCALIZATION SYSTEM 1.15.0" hostname="S-ITCS-ORTUNG" hostpid="6504" isolationlevel="read committed (2)" xactid="2642852343" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="94" sqlhandle="0x020000008e714d2c0ee98fc35b8a7712a719321f42c9366a0000000000000000000000000000000000000000">
DELETE [statisticlog] WHERE [statisticid]=@1 AND [storageid]=@2 AND [timest]<@3 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x02000000e1914b015d3b4d5ca54af4b548f2990acfe909ec0000000000000000000000000000000000000000">
DELETE from statisticlog where ((statisticid='node.temperatur') and (storageid='17:85:00:00:1a:18.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </frame>
</executionStack>
<inputbuf>
DELETE from statisticlog where ((statisticid='node.temperatur') and (storageid='17:85:00:00:1a:18.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </inputbuf>
</process>
<process id="process7edeee188" taskpriority="0" logused="0" waitresource="PAGE: 5:1:196655 " waittime="3124" ownerId="2642852343" transactionname="user_transaction" lasttranstarted="2014-09-05T11:16:12.683" XDES="0x8747f1740" lockMode="U" schedulerid="2" kpid="7108" status="suspended" spid="72" sbid="1" ecid="2" priority="0" trancount="0" lastbatchstarted="2014-09-05T11:16:12.990" lastbatchcompleted="2014-09-05T11:16:12.683" lastattention="1900-01-01T00:00:00.683" clientapp="WIRELESS LOCALIZATION SYSTEM 1.15.0" hostname="S-ITCS-ORTUNG" hostpid="6504" isolationlevel="read committed (2)" xactid="2642852343" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="94" sqlhandle="0x020000008e714d2c0ee98fc35b8a7712a719321f42c9366a0000000000000000000000000000000000000000">
DELETE [statisticlog] WHERE [statisticid]=@1 AND [storageid]=@2 AND [timest]<@3 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x02000000e1914b015d3b4d5ca54af4b548f2990acfe909ec0000000000000000000000000000000000000000">
DELETE from statisticlog where ((statisticid='node.temperatur') and (storageid='17:85:00:00:1a:18.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </frame>
</executionStack>
<inputbuf>
DELETE from statisticlog where ((statisticid='node.temperatur') and (storageid='17:85:00:00:1a:18.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </inputbuf>
</process>
<process id="process7edeefc38" taskpriority="0" logused="0" waitresource="PAGE: 5:1:196655 " waittime="3119" ownerId="2642852529" transactionname="user_transaction" lasttranstarted="2014-09-05T11:16:12.973" XDES="0x87f3ddbb0" lockMode="U" schedulerid="2" kpid="5216" status="suspended" spid="62" sbid="1" ecid="2" priority="0" trancount="0" lastbatchstarted="2014-09-05T11:16:12.980" lastbatchcompleted="2014-09-05T11:16:12.973" lastattention="1900-01-01T00:00:00.973" clientapp="WIRELESS LOCALIZATION SYSTEM 1.15.0" hostname="S-ITCS-ORTUNG" hostpid="1308" isolationlevel="read committed (2)" xactid="2642852529" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="94" sqlhandle="0x020000008e714d2c0ee98fc35b8a7712a719321f42c9366a0000000000000000000000000000000000000000">
DELETE [statisticlog] WHERE [statisticid]=@1 AND [storageid]=@2 AND [timest]<@3 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x02000000dd48f433f7e565ecccaaf5283c2e99548dd371d20000000000000000000000000000000000000000">
DELETE from statisticlog where ((statisticid='GWConnect') and (storageid='17:85:00:00:19:c8.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </frame>
</executionStack>
<inputbuf>
DELETE from statisticlog where ((statisticid='GWConnect') and (storageid='17:85:00:00:19:c8.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </inputbuf>
</process>
<process id="process681871868" taskpriority="0" logused="0" waitresource="PAGE: 5:1:210559 " waittime="3118" ownerId="2642852529" transactionname="user_transaction" lasttranstarted="2014-09-05T11:16:12.973" XDES="0x87bb39740" lockMode="U" schedulerid="1" kpid="8088" status="suspended" spid="62" sbid="1" ecid="3" priority="0" trancount="0" lastbatchstarted="2014-09-05T11:16:12.980" lastbatchcompleted="2014-09-05T11:16:12.973" lastattention="1900-01-01T00:00:00.973" clientapp="WIRELESS LOCALIZATION SYSTEM 1.15.0" hostname="S-ITCS-ORTUNG" hostpid="1308" isolationlevel="read committed (2)" xactid="2642852529" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="94" sqlhandle="0x020000008e714d2c0ee98fc35b8a7712a719321f42c9366a0000000000000000000000000000000000000000">
DELETE [statisticlog] WHERE [statisticid]=@1 AND [storageid]=@2 AND [timest]<@3 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x02000000dd48f433f7e565ecccaaf5283c2e99548dd371d20000000000000000000000000000000000000000">
DELETE from statisticlog where ((statisticid='GWConnect') and (storageid='17:85:00:00:19:c8.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </frame>
</executionStack>
<inputbuf>
DELETE from statisticlog where ((statisticid='GWConnect') and (storageid='17:85:00:00:19:c8.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </inputbuf>
</process>
<process id="process6e959f0c8" taskpriority="0" logused="10000" waittime="3087" schedulerid="4" kpid="6624" status="suspended" spid="62" sbid="1" ecid="0" priority="0" trancount="2" lastbatchstarted="2014-09-05T11:16:12.980" lastbatchcompleted="2014-09-05T11:16:12.973" lastattention="1900-01-01T00:00:00.973" clientapp="WIRELESS LOCALIZATION SYSTEM 1.15.0" hostname="S-ITCS-ORTUNG" hostpid="1308" loginname="LocSystem" isolationlevel="read committed (2)" xactid="2642852529" currentdb="5" lockTimeout="4294967295" clientoption1="671088672" clientoption2="128056">
<executionStack>
<frame procname="adhoc" line="1" stmtstart="94" sqlhandle="0x020000008e714d2c0ee98fc35b8a7712a719321f42c9366a0000000000000000000000000000000000000000">
DELETE [statisticlog] WHERE [statisticid]=@1 AND [storageid]=@2 AND [timest]<@3 </frame>
<frame procname="adhoc" line="1" sqlhandle="0x02000000dd48f433f7e565ecccaaf5283c2e99548dd371d20000000000000000000000000000000000000000">
DELETE from statisticlog where ((statisticid='GWConnect') and (storageid='17:85:00:00:19:c8.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </frame>
</executionStack>
<inputbuf>
DELETE from statisticlog where ((statisticid='GWConnect') and (storageid='17:85:00:00:19:c8.0')) AND timest < {ts '1970-01-01 01:00:00.000' } </inputbuf>
</process>
</process-list>
<resource-list>
<pagelock fileid="1" pageid="210559" dbid="5" subresource="FULL" objectname="LocSystem.LocSystem.statisticlog" id="lock707200480" mode="U" associatedObjectId="72057594045464576">
<owner-list>
<owner id="process6e959f0c8" mode="U" />
</owner-list>
<waiter-list>
<waiter id="process56d746188" mode="U" requestType="wait" />
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="196655" dbid="5" subresource="FULL" objectname="LocSystem.LocSystem.statisticlog" id="lock6ddb9e400" mode="U" associatedObjectId="72057594045464576">
<owner-list>
<owner id="process681871868" mode="U" />
</owner-list>
<waiter-list>
<waiter id="process7edeee188" mode="U" requestType="wait" />
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="196655" dbid="5" subresource="FULL" objectname="LocSystem.LocSystem.statisticlog" id="lock6ddb9e400" mode="U" associatedObjectId="72057594045464576">
<owner-list>
<owner id="process7edeee188" mode="U" requestType="wait" />
</owner-list>
<waiter-list>
<waiter id="process7edeefc38" mode="U" requestType="wait" />
</waiter-list>
</pagelock>
<pagelock fileid="1" pageid="210559" dbid="5" subresource="FULL" objectname="LocSystem.LocSystem.statisticlog" id="lock707200480" mode="U" associatedObjectId="72057594045464576">
<owner-list>
<owner id="process56d746188" mode="U" requestType="wait" />
</owner-list>
<waiter-list>
<waiter id="process681871868" mode="U" requestType="wait" />
</waiter-list>
</pagelock>
<exchangeEvent id="Pipe59935a700" WaitType="e_waitPipeGetRow" nodeId="1">
<owner-list>
<owner id="process7edeefc38" />
<owner id="process681871868" />
</owner-list>
<waiter-list>
<waiter id="process6e959f0c8" />
</waiter-list>
</exchangeEvent>
</resource-list>
</deadlock>>1. Is this expected behaviour or should SQL Server be able to handle such requests, or to put it right do I have to >care for structures that avoid the above scenario, do I have to reconfigure or is there sth else to look at?
Basically yes. Because your queries are non-trivial the DELETE query plans for different queries may conflict.
>2. Is this a configuration problem?
It's influenced by your table indexing, and especially how well your DELETE statements are supported by the physical data structures in your table. The bigger and more complicated the physical design, the more likely that concurrent DELETES will conflict.
>3. I also do not understand why the report states that the processes fought for page ids when the lock escalation >type was set to table.
Page locks are never the result of lock escalation. Row locks escalate to Table locks. Period. When a query uses Page locks it's an optimization to avoid taking lots of row locks to begin with. But this comes at the possible cost
of some concurrency. The
ROWLOCK query hint, possibly along with the READPAST hint can force more granular locking.
>4. As far as I got to know until now having a clustered index on the timestamp colum is likely to boost my problem >rather than solving it?
You minimize the locking conflicts by ensuring that it's very simple to find the rows affected by your DELETE. There's not enough information here to speculate on which physical design (partition scheme, clustered index, non-clustered indexes...) is optimal
for this.
A threshold question is whether you really _need_ these deletes to run concurrently on the table. If not, then you can simply serialize them (eg with TABLOCK).
David
David http://blogs.msdn.com/b/dbrowne/ -
Use Formule on FORM with REPORT - result stored at table
Hi all,
What is the best solution for?
I have region with FORM WITH REPORT on the same PAGE.
Values stored at table INFO with column ID, MYDATE, TIME_START_HOUR, TIME_START_MIN, TIME_END_HOUR, TIME_END_MIN, SUM1, SUM2
ITEMS on the form:
P1_ID (hidden)
P1_MYDATE (date picker)
P1_TIME_START_HOUR (select list)
P1_TIME_START_MIN (select list)
P1_TIME_END_HOUR (select list)
P1_TIME_END_MIN (select list)
P1_SUM1 (hidden)
P1_SUM2 (hidden)
After user fill in MYDATE, TIME_START_HOUR, TIME_START_MIN, TIME_END_HOUR, TIME_END_MIN then I need proces for calculation SUM1 en SUM2. Result stored (one record) at table INFO.
Report shows all columns. User had possibility to update the record
Formule:
Select
(CASE
when to_char(mydate,'DY','nls_date_language=dutch') in ('ZA','ZO')
THEN substr(to_timestamp (mydate||':'||TIME_END_HOUR||':'||TIME_END_MIN ||':00','DD-MM-YY:HH24:MI:SS') -
to_timestamp (mydate||':'||TIME_START_HOUR||':'||TIME_START_MIN ||':00','DD-MM-YY:HH24:MI:SS') -
(interval '00 00:00:00' day to second)
,12,5)
ELSE '08:00'
END) SUM1,
(CASE
when to_char(mydate,'DY','nls_date_language=dutch') in ('ZA','ZO')
THEN substr(to_timestamp (mydate||':'||TIME_END_HOUR||':'||TIME_END_MIN ||':00','DD-MM-YY:HH24:MI:SS') -
to_timestamp (mydate||':'||TIME_START_HOUR||':'||TIME_START_MIN ||':00','DD-MM-YY:HH24:MI:SS') -
(interval '00 04:00:00' day to second)
,12,5)
ELSE '04:00'
END) SUM2
FROM INFO
where id=:ID
What is the best way for the calculation: computation or processes or etc? The calculation after or before user push button(New:create button of Update:Apply Changes)?
How to fill the answer (SUM1 and SUM2) at table INFO?
Thanks WalterI have something similar I use:
DECLARE
str_day VARCHAR2(10);
dt_indx DATE;
db_dt_indx VARCHAR2(20);
str_st_tm VARCHAR2(20);
dt_st_tm DATE;
db_st_tm VARCHAR2(20);
str_ed_tm VARCHAR2(20);
dt_ed_tm DATE;
db_ed_tm VARCHAR2(20);
shft_flag NUMBER;
BEGIN
str_day := :P1050_DATE_MM || '/' || :P1050_DATE_DD || '/' || :P1050_DATE_YYYY;
dt_indx := to_date(str_day, 'MM/DD/YYYY');
db_dt_indx := to_char(dt_indx, 'MM/DD/YYYY');
str_st_tm := str_day || ' ' || :P1050_TIME_IN_HH || ':' || :P1050_TIME_IN_MI || ' ' || :P1050_TIME_IN_AM;
dt_st_tm := TO_DATE(str_st_tm, 'MM/DD/YYYY HH:MI AM');
str_ed_tm := str_day || ' ' || :P1050_TIME_OUT_HH || ':' || :P1050_TIME_OUT_MI || ' ' || :P1050_TIME_OUT_AM;
dt_ed_tm := TO_DATE(str_ed_tm, 'MM/DD/YYYY HH:MI AM');
--Alter date if night shift
SELECT NVL(:P1050_NIGHT_FLAG,0) into shft_flag from dual;
IF dt_ed_tm < dt_st_tm THEN
dt_ed_tm := dt_ed_tm + 1;
END IF;
db_st_tm := to_char(dt_st_tm + shft_flag,'MM/DD/YYYY HH:MI AM');
db_ed_tm := to_char(dt_ed_tm + shft_flag,'MM/DD/YYYY HH:MI AM');
end;You'll need to modify it for your page variables. -
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. -
QM action not allowed for DTP requests in master data and Text tables
Hi,
I have a master data object load request which has failed, returned error in st22 and job finished.
BUT the request has not turned red in the monitor - it's still yellow. That means that I can not delete request nor start new load to infoprovider because it believes a request is still running. But it's not, I've checked both sm37, sm50 etc.
When trying to manually change QM status to 'red' it says 'QM action not allowed for DTP requests in master data and Text tables'
How can I force QM status to red so that I can move on?
Running NW2004s BI (7.0) Patch 15.
I searched for this question but there is no answer
Thank youFolks
I know how frustrating this problem is even in netweaver 7.0 environment. I found a solution for this problem atlast and it works but a not direct way of resolving this issue.
When this request is in yellow status and not able to change / delete the request, its actually in a pseudo status and it is a bug in the program. This request sits in table RSBKREQUEST with processing type as 5 in data elements USTATE, TSTATE and this 5 is actually "Active" status which is obviously wrong.
All we need is, ask your basis person to change the status to 3 in both these data elements and then it allows to reload the delta. Once the delta is successfully loaded, you can delete the previous bad request even though it is still in yellow. Once the request is deleted, the request status gets updated as "4" in table RSBKREQUEST.
Hope this helps.
Thanks -
Strange 'gc cr multi block request' during dictionary queries
Hi,
here goes the case :
I've got 4 node 10.2.0.3 RAC , DDL intensive (CTAS, DROP/TRUNCATE) database
It's like 20TB of data, milions of partitions and objects .
When I'm doing queries agains dictionary tables like select * from
dba_segments where owner = 'A' and segment_name = 'B'
I'm observing 'gc cr multi block request' , as far as I know its kind of
scattered reads but using interconnect to gather data .
Whats bothering me is profile of that 'gc cr multi block requests' , here
goes some lines from 10046 trace:
WAIT #6: nam='gc cr multi block request' ela= 861 file#=1 block#$34788
class#=1 obj#8 tim18733123446958
WAIT #6: nam='gc cr multi block request' ela= 69 file#=1 block#$34788
class#=1 obj#8 tim18733123447083
WAIT #6: nam='gc cr multi block request' ela= 60 file#=1 block#$34788
class#=1 obj#8 tim18733123447220
WAIT #6: nam='gc cr multi block request' ela= 99 file#=1 block#$34788
class#=1 obj#8 tim18733123447347
WAIT #6: nam='gc cr multi block request' ela= 111 file#=1 block#$34788
class#=1 obj#8 tim18733123447482
WAIT #6: nam='gc cr multi block request' ela= 193 file#=1 block#$34788
class#=1 obj#8 tim18733123447704
WAIT #6: nam='gc cr multi block request' ela= 84 file#=1 block#$34788
class#=1 obj#8 tim18733123447820
WAIT #6: nam='gc cr multi block request' ela= 81 file#=1 block#$34788
class#=1 obj#8 tim18733123447931
WAIT #6: nam='gc cr multi block request' ela= 108 file#=1 block#$34788
class#=1 obj#8 tim18733123448065
WAIT #6: nam='gc cr multi block request' ela= 111 file#=1 block#$34788
class#=1 obj#8 tim18733123448199
WAIT #6: nam='gc cr multi block request' ela= 105 file#=1 block#$34788
class#=1 obj#8 tim18733123448328
WAIT #6: nam='gc cr multi block request' ela= 100 file#=1 block#$34788
class#=1 obj#8 tim18733123448458
WAIT #6: nam='gc cr multi block request' ela= 151 file#=1 block#$34788
class#=1 obj#8 tim18733123448639
WAIT #6: nam='gc cr multi block request' ela= 84 file#=1 block#$34788
class#=1 obj#8 tim18733123448750
WAIT #6: nam='gc cr multi block request' ela= 90 file#=1 block#$34788
class#=1 obj#8 tim18733123448867
WAIT #6: nam='gc cr multi block request' ela= 98 file#=1 block#$34788
class#=1 obj#8 tim18733123448994
and that pattern repeats with different block#
Question is why Oracle is requesting the same block , over and over (16
times) , I thinks 16 comes from MBRC which is 16 and I've got 16kb blocksize
Looks like a bug :) isnt it ?
Generally all queries agains dictionary tables are slow (minutes) , I'm not
observing any lost block issues so its probably bad plans issue .
Any comments ?
Regards
GregGIt looks like this:
select *
from
dba_segments where owner = 'INS' and segment_name = 'T'
call count cpu elapsed disk query current rows
Parse 1 0.10 0.10 0 6 0 0
Execute 1 0.00 0.00 0 0 0 0
Fetch 2 11.05 79.71 74418 96116 0 1
total 4 11.16 79.82 74418 96122 0 1
Misses in library cache during parse: 1
Optimizer mode: ALL_ROWS
Parsing user id: 842
Rows Row Source Operation
1 VIEW SYS_DBA_SEGS (cr=96116 pr=74418 pw=0 time=3397685 us)
1 UNION-ALL (cr=96116 pr=74418 pw=0 time=3397673 us)
1 FILTER (cr=91749 pr=74315 pw=0 time=3397634 us)
11 HASH JOIN RIGHT OUTER (cr=91749 pr=74315 pw=0 time=3397620 us)
1317 TABLE ACCESS FULL USER$ (cr=34 pr=0 pw=0 time=6738 us)
11 HASH JOIN (cr=91715 pr=74315 pw=0 time=3392292 us)
262 TABLE ACCESS FULL FILE$ (cr=3 pr=0 pw=0 time=1087 us)
11 HASH JOIN (cr=91712 pr=74315 pw=0 time=3389434 us)
75 TABLE ACCESS FULL TS$ (cr=82 pr=0 pw=0 time=2693 us)
11 NESTED LOOPS (cr=91630 pr=74315 pw=0 time=3386237 us)
12 HASH JOIN (cr=91592 pr=74313 pw=0 time=23765169 us)
20 TABLE ACCESS BY INDEX ROWID OBJ$ (cr=424 pr=21 pw=0 time=261735 us)
20 INDEX SKIP SCAN I_OBJ2 (cr=406 pr=21 pw=0 time=261140 us)(object id 37)
966949 VIEW SYS_OBJECTS (cr=91168 pr=74292 pw=0 time=52219753 us)
966949 UNION-ALL (cr=91168 pr=74292 pw=0 time=50285852 us)
113050 TABLE ACCESS FULL TAB$ (cr=20294 pr=16672 pw=0 time=18883720 us)
627116 TABLE ACCESS FULL TABPART$ (cr=7188 pr=5576 pw=0 time=5652638 us)
25 TABLE ACCESS FULL CLU$ (cr=20293 pr=16520 pw=0 time=1019 us)
13835 TABLE ACCESS FULL IND$ (cr=20322 pr=16550 pw=0 time=11400216 us)
195932 TABLE ACCESS FULL INDPART$ (cr=2523 pr=2421 pw=0 time=1967714 us)
1213 TABLE ACCESS FULL LOB$ (cr=20350 pr=16553 pw=0 time=22044772 us)
8363 TABLE ACCESS FULL TABSUBPART$ (cr=122 pr=0 pw=0 time=9995 us)
7160 TABLE ACCESS FULL INDSUBPART$ (cr=72 pr=0 pw=0 time=9572 us)
255 TABLE ACCESS FULL LOBFRAG$ (cr=4 pr=0 pw=0 time=2060 us)
11 TABLE ACCESS CLUSTER SEG$ (cr=38 pr=2 pw=0 time=32200 us)
11 INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=26 pr=0 pw=0 time=11331 us)(object id 9)
0 NESTED LOOPS (cr=1 pr=1 pw=0 time=8349 us)
0 NESTED LOOPS (cr=1 pr=1 pw=0 time=8344 us)
0 FILTER (cr=1 pr=1 pw=0 time=8340 us)
0 NESTED LOOPS OUTER (cr=1 pr=1 pw=0 time=8334 us)
0 NESTED LOOPS (cr=1 pr=1 pw=0 time=8327 us)
0 TABLE ACCESS BY INDEX ROWID UNDO$ (cr=1 pr=1 pw=0 time=8322 us)
0 INDEX RANGE SCAN I_UNDO2 (cr=1 pr=1 pw=0 time=8314 us)(object id 35)
0 TABLE ACCESS CLUSTER SEG$ (cr=0 pr=0 pw=0 time=0 us)
0 INDEX UNIQUE SCAN I_FILE#_BLOCK# (cr=0 pr=0 pw=0 time=0 us)(object id 9)
0 TABLE ACCESS CLUSTER USER$ (cr=0 pr=0 pw=0 time=0 us)
0 INDEX UNIQUE SCAN I_USER# (cr=0 pr=0 pw=0 time=0 us)(object id 11)
0 TABLE ACCESS BY INDEX ROWID FILE$ (cr=0 pr=0 pw=0 time=0 us)
0 INDEX UNIQUE SCAN I_FILE2 (cr=0 pr=0 pw=0 time=0 us)(object id 42)
0 TABLE ACCESS CLUSTER TS$ (cr=0 pr=0 pw=0 time=0 us)
0 INDEX UNIQUE SCAN I_TS# (cr=0 pr=0 pw=0 time=0 us)(object id 7)
0 FILTER (cr=4366 pr=102 pw=0 time=4366839 us)
0 HASH JOIN RIGHT OUTER (cr=4366 pr=102 pw=0 time=4366833 us)
1317 TABLE ACCESS FULL USER$ (cr=60 pr=0 pw=0 time=1397 us)
0 HASH JOIN (cr=4306 pr=102 pw=0 time=4361061 us)
75 TABLE ACCESS FULL TS$ (cr=82 pr=0 pw=0 time=745 us)
0 NESTED LOOPS (cr=4224 pr=102 pw=0 time=4357971 us)
262 TABLE ACCESS FULL FILE$ (cr=3 pr=0 pw=0 time=1738 us)
0 TABLE ACCESS CLUSTER SEG$ (cr=4221 pr=102 pw=0 time=4355035 us)
0 INDEX RANGE SCAN I_FILE#_BLOCK# (cr=4221 pr=102 pw=0 time=4351804 us)(object id 9)
Elapsed times include waiting on following events:
Event waited on Times Max. Wait Total Waited
---------------------------------------- Waited ---------- ------------
library cache lock 18 0.00 0.00
SQL*Net message to client 2 0.00 0.00
gc current block 2-way 2299 0.00 1.16
gc current block 3-way 1597 0.00 1.28
gc cr block busy 4 0.01 0.03
gc cr grant 2-way 313 0.00 0.11
db file sequential read 627 0.06 2.94
gc cr block 2-way 37 0.00 0.02
gc cr block 3-way 27 0.00 0.02
gc current grant 2-way 1 0.00 0.00
gc cr multi block request 23073 0.01 7.07
db file scattered read 1756 0.10 13.70
db file parallel read 4708 0.19 44.89
latch: KCL gc element parent latch 33 0.00 0.00
SQL*Net message from client 2 1492.36 1492.36
latch free 4 0.00 0.00
latch: gcs resource hash 2 0.00 0.00
latch: cache buffers chains 5 0.00 0.00
gc buffer busy 1 0.00 0.00
latch: cache buffers lru chain 2 0.00 0.00
gc cr disk read 2 0.00 0.00
and in raw trace:
WAIT #4: nam='gc cr multi block request' ela= 18 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416456439
WAIT #4: nam='gc cr multi block request' ela= 320 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416456780
WAIT #4: nam='gc cr multi block request' ela= 146 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416456949
WAIT #4: nam='gc cr multi block request' ela= 14 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416456979
WAIT #4: nam='gc cr multi block request' ela= 6 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416457000
WAIT #4: nam='gc cr multi block request' ela= 107 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416457119
WAIT #4: nam='gc cr multi block request' ela= 171 file#=1 block#=3396 class#=1 obj#=4 tim=1318904416457594
WAIT #4: nam='gc cr multi block request' ela= 1119 file#=1 block#=3387 class#=1 obj#=4 tim=1318904416458819
WAIT #4: nam='db file parallel read' ela= 9411 files=1 blocks=10 requests=10 obj#=4 tim=1318904416468429
WAIT #4: nam='gc cr multi block request' ela= 592 file#=1 block#=4244 class#=1 obj#=4 tim=1318904416470099
WAIT #4: nam='gc cr multi block request' ela= 7 file#=1 block#=4244 class#=1 obj#=4 tim=1318904416470136
WAIT #4: nam='gc cr multi block request' ela= 203 file#=1 block#=4244 class#=1 obj#=4 tim=1318904416470353
WAIT #4: nam='gc cr multi block request' ela= 69 file#=1 block#=4244 class#=1 obj#=4 tim=1318904416470487
WAIT #4: nam='gc cr multi block request' ela= 962 file#=1 block#=4244 class#=1 obj#=4 tim=1318904416471499
WAIT #4: nam='gc cr multi block request' ela= 49 file#=1 block#=4244 class#=1 obj#=4 tim=1318904416471650Any ideas ?:)
Regards
GregG -
Please I need some help with a table
Hi All
I need some help with a table.
My table needs to hold prices that the user can update.
Also has a total of the column.
my question is if the user adds in a new price how can i pick up the value they have just entered and then add it to the total which will be the last row in the table?
I have a loop that gets all the values of the column, so I can get the total but it is when the user adds in a new value that I need some help with.
I have tried using but as I need to set the toal with something like total
totalTable.setValueAt(total, totalTable.getRowCount()-1,1); I end up with an infinite loop.
Can any one please advise on some way I can get this to work ?
Thanks for reading
CraigHi there camickr
thanks for the help the other day
this is my full code....
package printing;
import java.awt.*;
import java.awt.event.*;
import java.awt.print.*;
import javax.swing.*;
import javax.swing.table.*;
import java.text.DecimalFormat;
public class tablePanel
extends JDialog implements Printable {
BorderLayout borderLayout1 = new BorderLayout();
private boolean printing = false;
private Dialog1 dialog;
JPanel jPanel = new JPanel();
JTable table;
JScrollPane scrollPane1 = new JScrollPane();
DefaultTableModel model;
private String[] columnNames = {
private Object[][] data;
private String selectTotal;
private double total;
public tablePanel(Dialog1 dp) {
dp = dialog;
try {
jbInit();
catch (Exception exception) {
exception.printStackTrace();
public tablePanel() {
try {
jbInit();
catch (Exception exception) {
exception.printStackTrace();
private void jbInit() throws Exception {
jPanel.setLayout(borderLayout1);
scrollPane1.setBounds(new Rectangle(260, 168, 0, 0));
this.add(jPanel);
jPanel.add(scrollPane1, java.awt.BorderLayout.CENTER);
scrollPane1.getViewport().add(table);
jPanel.setOpaque(true);
newTable();
addToModel();
addRows();
setTotal();
public static void main(String[] args) {
tablePanel tablePanel = new tablePanel();
tablePanel.pack();
tablePanel.setVisible(true);
public void setTotal() {
total = 0;
int i = table.getRowCount();
for (i = 0; i < table.getRowCount(); i++) {
String name = (String) table.getValueAt(i, 1);
if (!"".equals(name)) {
if (i != table.getRowCount() - 1) {
double dt = Double.parseDouble(name);
total = total + dt;
String str = Double.toString(total);
table.setValueAt(str, table.getRowCount() - 1, 1);
super.repaint();
public void newTable() {
model = new DefaultTableModel(data, columnNames) {
table = new JTable() {
public Component prepareRenderer(TableCellRenderer renderer,
int row, int col) {
Component c = super.prepareRenderer(renderer, row, col);
if (printing) {
c.setBackground(getBackground());
else {
if (row % 2 == 1 && !isCellSelected(row, col)) {
c.setBackground(getBackground());
else {
c.setBackground(new Color(227, 239, 250));
if (isCellSelected(row, col)) {
c.setBackground(new Color(190, 220, 250));
return c;
table.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2) {
if (e.getClickCount() == 1) {
if (table.getSelectedColumn() == 1) {
table.setTableHeader(null);
table.setModel(model);
scrollPane1.getViewport().add(table);
table.getColumnModel().getColumn(1).setCellRenderer(new TableRenderDollar());
public void addToModel() {
Object[] data = {
"Price", "5800"};
model.addRow(data);
public void addRows() {
int rows = 20;
for (int i = 0; i < rows; i++) {
Object[] data = {
model.addRow(data);
public void printOut() {
PrinterJob pj = PrinterJob.getPrinterJob();
pj.setPrintable(tablePanel.this);
pj.printDialog();
try {
pj.print();
catch (Exception PrintException) {}
public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.black);
int fontHeight = g2.getFontMetrics().getHeight();
int fontDesent = g2.getFontMetrics().getDescent();
//leave room for page number
double pageHeight = pageFormat.getImageableHeight() - fontHeight;
double pageWidth = pageFormat.getImageableWidth();
double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
double scale = 1;
if (tableWidth >= pageWidth) {
scale = pageWidth / tableWidth;
double headerHeightOnPage = 16.0;
//double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
//System.out.println("this is the hedder heigth " + headerHeightOnPage);
double tableWidthOnPage = tableWidth * scale;
double oneRowHeight = (table.getRowHeight() + table.getRowMargin()) * scale;
int numRowsOnAPage = (int) ( (pageHeight - headerHeightOnPage) / oneRowHeight);
double pageHeightForTable = oneRowHeight *numRowsOnAPage;
int totalNumPages = (int) Math.ceil( ( (double) table.getRowCount()) / numRowsOnAPage);
if (pageIndex >= totalNumPages) {
return NO_SUCH_PAGE;
g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
//bottom center
g2.drawString("Page: " + (pageIndex + 1 + " of " + totalNumPages), (int) pageWidth / 2 - 35, (int) (pageHeight + fontHeight - fontDesent));
g2.translate(0f, headerHeightOnPage);
g2.translate(0f, -pageIndex * pageHeightForTable);
//If this piece of the table is smaller
//than the size available,
//clip to the appropriate bounds.
if (pageIndex + 1 == totalNumPages) {
int lastRowPrinted =
numRowsOnAPage * pageIndex;
int numRowsLeft =
table.getRowCount()
- lastRowPrinted;
g2.setClip(0,
(int) (pageHeightForTable * pageIndex),
(int) Math.ceil(tableWidthOnPage),
(int) Math.ceil(oneRowHeight *
numRowsLeft));
//else clip to the entire area available.
else {
g2.setClip(0,
(int) (pageHeightForTable * pageIndex),
(int) Math.ceil(tableWidthOnPage),
(int) Math.ceil(pageHeightForTable));
g2.scale(scale, scale);
printing = true;
try {
table.paint(g2);
finally {
printing = false;
//tableView.paint(g2);
g2.scale(1 / scale, 1 / scale);
g2.translate(0f, pageIndex * pageHeightForTable);
g2.translate(0f, -headerHeightOnPage);
g2.setClip(0, 0,
(int) Math.ceil(tableWidthOnPage),
(int) Math.ceil(headerHeightOnPage));
g2.scale(scale, scale);
//table.getTableHeader().paint(g2);
//paint header at top
return Printable.PAGE_EXISTS;
class TableRenderDollar extends DefaultTableCellRenderer{
public Component getTableCellRendererComponent(
JTable table,
Object value,
boolean isSelected,
boolean isFocused,
int row, int column) {
setHorizontalAlignment(SwingConstants.RIGHT);
Component component = super.getTableCellRendererComponent(
table,
value,
isSelected,
isFocused,
row,
column);
if( value == null || value .equals("")){
( (JLabel) component).setText("");
}else{
double number = 0.0;
number = new Double(value.toString()).doubleValue();
DecimalFormat df = new DecimalFormat(",##0.00");
( (JLabel) component).setText(df.format(number));
return component;
} -
Need some help with the Table Function Operator
I'm on OWB 10gR2 for Sun/Solaris 10 going against some 10gR2 DB's...
I've been searching up and down trying to figure out how to make OWB use a Table Function (TF) which will JOIN with another table; allowing a column of the joined table to be a parameter in to the TF. I can't seem to get it to work. I'm able to get this to work in regular SQL, though. Here's the setup:
-- Source Table:
DROP TABLE "ZZZ_ROOM_MASTER_EX";
CREATE TABLE "ZZZ_ROOM_MASTER_EX"
( "ID" NUMBER(8,0),
"ROOM_NUMBER" VARCHAR2(200),
"FEATURES" VARCHAR2(4000)
-- Example Data:
Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (1,'Room 1',null);
Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (2,'Room 2',null);
Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (3,'Room 3','1,1;2,3;');
Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (4,'Room 4','5,2;5,4;');
Insert into ZZZ_ROOM_MASTER_EX (ID,ROOM_NUMBER,FEATURES) values (5,'Room 5',' ');
-- Destination Table:
DROP TABLE "ZZZ_ROOM_FEATURES_EX";
CREATE TABLE "ZZZ_ROOM_FEATURES_EX"
( "ROOM_NUMBER" VARCHAR2(200),
"FEATUREID" NUMBER(8,0),
"QUANTITY" NUMBER(8,0)
-- Types for output table:
CREATE OR REPLACE TYPE FK_Row_EX AS OBJECT
ID NUMBER(8,0),
QUANTITY NUMBER(8,0)
CREATE OR REPLACE TYPE FK_Table_EX AS TABLE OF FK_Row_EX;
-- Package Dec:
CREATE OR REPLACE
PACKAGE ZZZ_SANDBOX_EX IS
FUNCTION UNFK(inputString VARCHAR2) RETURN FK_Table_EX;
END ZZZ_SANDBOX_EX;
-- Package Body:
CREATE OR REPLACE
PACKAGE BODY ZZZ_SANDBOX_EX IS
FUNCTION UNFK(inputString VARCHAR2) RETURN FK_Table_EX
AS
RETURN_VALUE FK_Table_EX := FK_Table_EX();
i NUMBER(8,0) := 0;
BEGIN
-- TODO: Put some real code in here that will actually read the
-- input string, parse it out, and put data in to RETURN_VALUE
WHILE(i < 3) LOOP
RETURN_VALUE.EXTEND;
RETURN_VALUE(RETURN_VALUE.LAST) := FK_Row_EX(4, 5);
i := i + 1;
END LOOP;
RETURN RETURN_VALUE;
END UNFK;
END ZZZ_SANDBOX_EX;
I've got a source system built by lazy DBA's and app developers who decided to store foreign keys for many-to-many relationships as delimited structures in driving tables. I need to build a generic table function to parse this data and return it as an actual table. In my example code, I don't actually have the parsing part written yet (I need to see how many different formats the source system uses first) so I just threw in some stub code to generate a few rows of 4's and 5's to return.
I can get the data from my source table to my destination table using the following SQL statement:
-- from source table joined with table function
INSERT INTO ZZZ_ROOM_FEATURES_EX(
ROOM_NUMBER,
FEATUREID,
QUANTITY)
SELECT
ZZZ_ROOM_MASTER_EX.ROOM_NUMBER,
UNFK.ID,
UNFK.QUANTITY
FROM
ZZZ_ROOM_MASTER_EX,
TABLE(ZZZ_SANDBOX_EX.UNFK(ZZZ_ROOM_MASTER_EX.FEATURES)) UNFK
Now, the big question is--how do I do this from OWB? I've tried several different variations of my function and settings in OWB to see if I can build a single SELECT statement which joins a regular table with a table function--but none of them seem to work, I end up getting SQL generated that won't compile because it doesn't see the source table right:
INSERT
/*+ APPEND PARALLEL("ZZZ_ROOM_FEATURES_EX") */
INTO
"ZZZ_ROOM_FEATURES_EX"
("ROOM_NUMBER",
"FEATUREID",
"QUANTITY")
(SELECT
"ZZZ_ROOM_MASTER_EX"."ROOM_NUMBER" "ROOM_NUMBER",
"INGRP2"."ID" "ID_1",
"INGRP2"."QUANTITY" "QUANTITY"
FROM
(SELECT
"UNFK"."ID" "ID",
"UNFK"."QUANTITY" "QUANTITY"
FROM
TABLE ( "ZZZ_SANDBOX_EX"."UNFK2" ("ZZZ_ROOM_MASTER_EX"."FEATURES")) "UNFK") "INGRP2",
"ZZZ_ROOM_MASTER_EX" "ZZZ_ROOM_MASTER_EX"
As you can see, it's trying to create a sub-query in the FROM clause--causing it to just ask for "ZZZ_ROOM_MASTER_EX"."FEATURES" as an input--which isn't available because it's outside of the sub-query!
Is this some kind of bug with the code generator or am I doing something seriously wrong here? Any help will be greatly appreciated!Hello Everybody!
Thank you for all your response!
I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
I had created a Z table with the following fields :
ZADS :
MANDT
VKORG
ABGRU.
I had written a select query as below :
I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table
select vkorg abgru from ZADS into it_rej.
Earlier :
IT_REJ is a Work area:
DATA : BEGIN OF IT_REJ,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
Now :
DATA : BEGIN OF IT_REJ occurs 0,
VKORG TYPE VBAK-VKORG,
ABGRU TYPE VBAP-ABGRU,
END OF IT_REJ.
I guess this will fix the issue correct?
PLease suggest!
Regards,
Developer. -
I NEED TO KNOW ABOUT DRIVING TABLE...PLEASE
Well, My name is Adan. I am from Panama.. my english is not
good. But I'll try. I need to know about driving tables and how
have to choose a driving table and how optimizer proccess an sql
statment.
Example:
Employees have (1,000,000 rows),
dept have (100 rows)
Category have (100 rows)...
I need retrieved all employees with category and dept name for
those employee with salary > 100000
Well, What is the driving table and where i have to put this one
in the from clause ? What about order in the where predicate...
First ?
Select E.name, C.category, D.Departement
from Employees e, dept d, category c
where
and d.cat = c.cat
and e.deptno = d.deptno
and e.salary > 100000
Last ?
Select E.name,C.category, D.Departement
from dept d, category c ,Employees e
where
and d.cat = c.cat
and e.deptno = d.deptno
and e.salary > 100000
I apreciate your help....Thanks and sorry for my english....
Bye..Adam,
If you set your optimizer = choose and analyze the tables and
indexes to generate statistics, then your system can use the
Cost Based Optimizer (CBO) and, like David said, it will
automatically choose the best access path, and the order of
things will not matter.
If your optimizer is not set to choose or if there are no
statistics, then it will use the Rule Based Optimizer (RBO), in
which case, the only thing that matters is the order of the
tables in the from clause. When using RBO, the driving table
should be at the end of the from clause, in the right-most
position. The driving table is the one such that, after the
restrictions have been applied, returns the smallest number of
rows. You would have to compare the number of rows in the
employees table where salary > 100000 to the number of rows in
the dept table (100) and the number of rows in the category
table (100).
In RBO, if there are more than 100 rows in the employees table
where salary > 100000, then your from clause would be:
FROM employees e, dept d, category c
In RBO, if there are less than 100 rows in the employees table
where salary > 100000, then your from clause would be:
FROM category c, dept d, employees e
This is all that applies to the example you have given, however
there are other things that can apply in other situations. For
example, if there is an outer join to a table, the table that
has the (+) cannot be used as the driving table.
Barbara -
Do I need to make a new table?
I pasted in a small table from excel.
Three columns and 10 rows.
I now need to add rows but don't know if I can. Can I, or do I have to start a new table from scratch. thanks.I don't recommend pasting formatted content from MS Office into your HTML pages because the code often carries MS Proprietary styles which you don't want in your page. Much better to create tables in DW.
When copying & pasting content from other apps use DW Edit menu > Paste Special > Text Only.
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
www.alt-web.com/
www.twitter.com/altweb -
Need the file extensions database table name
Hi,
I need to know the Database table name for file extensions in WCC.
Please check the image for reference .Hi 2790552
Please look at file doc_config.htm in the location <middleware_home>/Oracle_ECM1/ucm/idc/resources/core/tables/doc_config.htm
This is the file which helps in building the applet view.
I do belive that revisions and documents table might be used for validation and other specific things, but thats more in the context of document processing and from component IBR at runtime. But administration sake, i thing it works from the these config files since database doesn't have any table to hold this info.
Maybe you are looking for
-
Hi, I dragged and Dropped and Mp3 File in a Track, and I want to edit/cut some sections of it. How do I acheive this?
-
Having issues with my mac will upgrade solve them?
Hi guys with reference to my other thread me and the wife were discussing wether to upgrade our 10.3.9 to 10.4 (so she can watch videos on facebook etc) is it really worth it? if this has been covered elsewhere please forgive me .Thanks
-
Boilerplate Fields and text substitution
Hey, I'm new to LiveCycle Designer and would appreciate any help on this. Having used Output Designer for over a year I am used to using boilerplate text fields that allow text substitution with a block of text by using @fieldname. and within the dat
-
IPhone upgrade causing outlook to crash
Does anyone have trouble with Outlook crashing when trying to reply to an e-mail? This started after i upgraded my original iphone with the new software. ugh.
-
Create object in runtime phase
Hi all, i would create a data grid and pass it an array... for example th array looks like this: <mx:Array id="planets"> <mx:Object planet="Mercury" kind="Terrestrial" year_duration="0.24" moons="0" cost="1250" /> <mx:Object planet="Venus" kind="Terr