Counting horizontal value and generating date
using oracle 9i,
I have a table called test which has
Eno pct1 pct2 pct3 pct4 pct5 sal_date
101 0 100 0 100 100 03/01/2010
102 0 0 100 100 100 14/02/2010
103 0 100 100 100 100 24/01/2010for first row,we have two zeros for pct1,pct3,so the two records to be generated for 03/01/2010 and next week as well
Eno pct1 pct2 pct3 pct4 pct5 sal_date
101 0 100 0 100 100 03/01/2010 (2 Zeros,two weeks to b generated
101 0 100 0 100 100 10/01/2010
102 0 0 100 100 100 14/02/2010(2 Zeros,two weeks to b generated
102 0 0 100 100 100 21/02/2010
103 0 100 100 100 100 24/01/2010(one Zero,one week to b generated
create table test
( eno number,
pct1 number,
pct2 number,
pct3 number,
pct4 number,
pct5 number,
sal_date date);
insert into test values
(101,0,100,0,100,100,to_date('03/01/2010','DD/MM/YYYY');
insert into test values
(102,0,0,100,100,100,to_date('04/02/2010','DD/MM/YYYY');
insert into test values
(103,0,100,100,100,100,to_date('24/01/2010','DD/MM/YYYY');Can u pls help me out
Thanks in advance
Edited by: user12093849 on 28-Sep-2010 00:13
Mahesh Kaila wrote:
select ENO, PCT1, PCT2, PCT3, PCT4, PCT5,SAL_DATE + (cnt - 1) * 7 SAL_DATE from
select ENO, PCT1, PCT2, PCT3, PCT4, PCT5, SAL_DATE,
sum(
case when PCT1 = 0 then 1 else 0 end +
case when PCT2 = 0 then 1 else 0 end +
case when PCT3 = 0 then 1 else 0 end +
case when PCT4 = 0 then 1 else 0 end +
case when PCT5 = 0 then 1 else 0 end
) over (partition by (eno)) cnt
from test
) Regards,
Mahesh KailaHmm, only produces 3 rows, rather than the required 5...
SQL> select ENO, PCT1, PCT2, PCT3, PCT4, PCT5,SAL_DATE + (cnt - 1) * 7 SAL_DATE from
2 (
3 select ENO, PCT1, PCT2, PCT3, PCT4, PCT5, SAL_DATE,
4 sum(
5 case when PCT1 = 0 then 1 else 0 end +
6 case when PCT2 = 0 then 1 else 0 end +
7 case when PCT3 = 0 then 1 else 0 end +
8 case when PCT4 = 0 then 1 else 0 end +
9 case when PCT5 = 0 then 1 else 0 end
10 ) over (partition by (eno)) cnt
11 from test
12 )
13 /
ENO PCT1 PCT2 PCT3 PCT4 PCT5 SAL_DATE
101 0 100 0 100 100 10/01/2010 00:00:00
102 0 0 100 100 100 11/02/2010 00:00:00
103 0 100 100 100 100 24/01/2010 00:00:00
SQL>
Similar Messages
-
Execute BAPI for different input values and dispaly data in a table
Hi all,
I have a specific problem about executing BAPI multiple times for different input values and didplay result in a table.
I am using the code similar to the following logic.
Bapi_Mydata_Input in = new Bapi_Mydata_Input();
wdContext.nodeBapi_Mydata_Input().bind(in);
String in = wdContext.currentperdataElement.getnumber();
in.setDestination_From(10)
wdThis.wdGetMydataComponentController().executeBapi_Mydata_Input();
in.setDestination_From(20)
wdThis.wdGetMydataComponentController().executeBapi_Mydata_Input();
in.setDestination_From(30)
wdThis.wdGetMydataComponentController().executeBapi_Mydata_Input();
And I want to display the data in a single table. I want the result in a table for Bapi execution based on input parameters passed 10,20 30.
But I am getting the table data only for the input parameter 30.I mean its actually display the data in table only for the last input parameter.
So May I ask you all if you know the solution for this problem.PLease advise me with some tips .or sample code is very much appreciated.I promise to award points to the right answer/nice advises.
Regards
Maruti
Thank you in advance.Maruti,
It seems that WDCopyService replaces content of node, rather then adds to content.
Try this:
Bapi_Persdata_Getdetailedlist_Input frelan_in = new Bapi_Persdata_Getdetailedlist_Input();
wdContext.nodeBapi_Persdata_Getdetailedlist_Input().bind(frelan_in);
final Collection personalData = new ArrayList();
String fr1 = wdContext.currentE_Lfa1Element().getZzpernr1();
frelan_in.setEmployeenumber(fr1);
wdThis.wdGetFreLanReEngCompController().executeBapi_Persdata_Getdetailedlist_Input();
WDCopyService.copyElements(wdContext.nodePersonaldata(), wdContext.nodeNewPersonaldata());
for (int i = 0, c = wdContext.nodePersonaldata().size(); i < c; i++)
personalData.add( wdContext.nodePersonaldata().getElementAt(i).model() );
String fr2=wdContext.currentE_Lfa1Element().getZzpernr2();
frelan_in.setEmployeenumber(fr2);
wdThis.wdGetFreLanReEngCompController().executeBapi_Persdata_Getdetailedlist_Input();
WDCopyService.copyElements(wdContext.nodePersonaldata(), wdContext.nodeNewPersonaldata());
for (int i = 0, c = wdContext.nodePersonaldata().size(); i < c; i++)
personalData.add( wdContext.nodePersonaldata().getElementAt(i).model() );
wdContext.nodeNewPersonalData().bind( personalData );
Valery Silaev
EPAM Systems
http://www.NetWeaverTeam.com -
Need help regarding complex calculation using Max value and limiting data after Max date in MDX
I am working on a bit complex calculated measure in SSAS cube script mode.
Scenario /Data Set
Date
A
B
C
A+B
5/29/2014
Null
34
Null
34
6/30/2014
Null
23
45
68
7/15/2014
25
-25
Null
0
8/20/2014
-34
Null
Null
-34
9/30/2014
25
Null
60
25
10/15/2014
45
-45
Null
0
11/20/2014
7
8
Null
15
a) Need to capture latest non-null value of Column C based on date
with above example it should be 60 as of 9/30/2014
b) Need to capture column A+B for all dates.
c) Add values from column (A+B) only after latest date which is after 9/30/2014.
with above example it's last 2 rows and sum is 15
d) Finally add value from step a and step c. which means the calc measure value should be = 75
I need to perform all this logic in MDX. I was able to successfully get step a and b in separate calc measure, however i am not sure how to limit the scope based on certain date criteria. In this case it's, date> Max date(9/30/2014) . Also how should
i add calculated members and regular members?
I was able to get max value of C based on date and max date to limit the scope.
CREATE MEMBER CURRENTCUBE.[Measures].[LatestC] AS
TAIL(
NONEMPTY(
[Date].[Date].CHILDREN*[Measures].[C]),1).ITEM(0) ,visible=1;
CREATE MEMBER CURRENTCUBE.[Measures].[MaxDateofC] AS
TAIL(
NONEMPTY(
[Date].[Date].CHILDREN,[Measures].[C]),1).ITEM(0).MemberValue ,visible=1;
Please help with Scope statement to limit the aggregation of A+B for dates > MaxDateofC? Also further how to add this aggregation value to LatestC calc measure?
Thank YouHi Peddi,
I gave TRUNC to both of the dates. But still the same issue. I think the problem is in returning the BolbDomain.
return blobDomain;
} catch (XDOException xdoe) {
System.out.println("Exception in XDO :");
throw new OAException("Exception in XDO : "+xdoe.getMessage());
catch (SQLException sqle) {
System.out.println("Exception in SQL :");
throw new OAException("SQL Exception : "+sqle.getMessage());
catch (OAException e) {
System.out.println("Exception in OA :");
throw new OAException("Unexpected Error :: " +e.getMessage());
Thanks and Regards,
Myvizhi -
Read Instrument Value and Saving Data
Hi Everyone,
I have DSOX3014A Oscilloscope and 33521AQ Function / Arbitrary Waveform Generator . I want to make program that read oscilloscope and waveform generator data and send to tax file.
What should ı do ?
Thank for your time and attention.
Solved!
Go to Solution.I am really beginner.I never tried something so far.I have oscilloscope and arb generator. Also ı have piezoelectric bender(been attach) actuator resonance impedance.I connected oscilloscope and arb waveform generator to my computer. I want to record oscilloscope and arb waveform generator's data to tex file.
Actually ı don't have impedance analyzer therefore ı calculate piezo bender's resonance impedance this way.
Seem http://www.ni.com/try-labview/instrument-control/ first video but ı have to convert data to tex file.
What should ı do?
Thank You for your attention.
Attachments:
20150203_231732_Richtone(HDR).jpg 840 KB
Capture.PNG 970 KB -
SSRS Expression to compare two values and get data from another dataset
Hi,
I have a requirement where in i need to compare a value of a dataset (not the one which table is poiting to)
with the value of a text box, and return the count if it matches else 0, the expression is as below. Here
industryName and recCount are from the dataset ds_MedimOrLowImpactEntities. whats wrong in this expression
=Sum(IIF(Fields!industryName.Value = reportItems!hpapra_name.Value, Fields!RecCount.Value, 0), "ds_MediumOrLowImpactEntities")
This is the error that i am getting:
Any help on this is appreciated
Kruthi HegdeHi Kruthi,
After testing the issue in my local environment, I can reproduce it. Just the error message said, “Aggregate function can be used only on report items contained in page headers and footers”. So the sum function that contains report items should be stayed
at page headers or footers. Besides, you said the hpapra_name textbox contain a field from another dataset, not the ds_MedimOrLowImpactEntities dataset. While in Reporting Services, Report item expressions can only refer to other report items within the same
grouping scope or a containing grouping scope. So consider the two issues, we should use some other expression to instead the “reportItems!hpapra_name.Value” expression.
Take a look at the "Looking up values from another dataset" topic here:
http://msdn.microsoft.com/en-us/library/ms159673.aspx#LookupFunctions
Hope this helps.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
I have a problem with my iCal, when I use my caldav account, I can only see my own calendar on my MBA, on my co-workers MBP it works fine with both my account and his. My co-worker can't see other calendars than his own when he uses iCal on my laptop.
We can reproduce this problem on his computer by setting Location to Automatic rather than Amsterdam, then after deleting iCal's cache files, the caldav account and setting the Location back to Amsterdam solves the problem for him.
It does not solve the problem for me (or several other co-workers). We've been looking at this for a few weeks, and we can not find any clear pattern why certain machines have this problem and others don't.
All machines (both affected and unaffected) are running Mac OS 10.7.2 with iCal 5.0.1
I've spoken to Apple support over the phone (in the Netherlands), unfortunately, they couldn't help with this.
So far we've tried numerous location and language settings, but on affected machines nothing appears to solve the delegation problem (which we assume to be connected to the error messages iCal generates)
Starting iCal yeilds the following error messages in /var/log/system.log:
Jan 5 11:31:05 dhcp-91 [0x0-0x58f58f].com.apple.iCal[23884]: line 1,1: expecting FREQUENCE, found 'BYDAY' as token type 5
Jan 5 11:31:05 dhcp-91 iCal[23884]: iCalendar recurrence failure BYDAY=-1SU;FREQ=YEARLY;BYMONTH=3
line 1,6: unexpected char: '='
Jan 5 11:31:05 dhcp-91 [0x0-0x58f58f].com.apple.iCal[23884]: line 1,1: expecting FREQUENCE, found 'BYDAY' as token type 5
Jan 5 11:31:05 dhcp-91 iCal[23884]: iCalendar recurrence failure BYDAY=-1SU;FREQ=YEARLY;BYMONTH=10
line 1,6: unexpected char: '='
Jan 5 11:31:05 dhcp-91 iCal[23884]: Unexpected EOF, returning last token as fallback
Jan 5 11:31:05 dhcp-91 iCal[23884]: VTIMEZONE does not match System Time Zone (Europe/Amsterdam) for 20100105T000000 to 20120105T000000: (
"interval: 2001-01-01 01:00:00 +0100, offset: 3600"
) != (
"interval: 2010-03-28 03:00:00 +0200, offset: 7200",
"interval: 2010-10-31 02:00:00 +0100, offset: 3600",
"interval: 2011-03-27 03:00:00 +0200, offset: 7200",
"interval: 2011-10-30 02:00:00 +0100, offset: 3600"
BEGIN:VTIMEZONE
X-LIC-LOCATION:Europe/Amsterdam
TZID:Europe/Amsterdam
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZNAME:CEST
TZOFFSETTO:+0200
DTSTART:19700329T020000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZNAME:CET
TZOFFSETTO:+0100
DTSTART:19701025T030000
END:STANDARD
END:VTIMEZONE
Jan 5 11:31:05 dhcp-91 [0x0-0x58f58f].com.apple.iCal[23884]: line 1,1: expecting FREQUENCE, found 'BYDAY' as token type 5
Jan 5 11:31:05 dhcp-91 iCal[23884]: iCalendar recurrence failure BYDAY=-1SU;FREQ=YEARLY;BYMONTH=3
line 1,6: unexpected char: '='
Jan 5 11:31:05 dhcp-91 [0x0-0x58f58f].com.apple.iCal[23884]: line 1,1: expecting FREQUENCE, found 'BYDAY' as token type 5
Jan 5 11:31:05 dhcp-91 iCal[23884]: iCalendar recurrence failure BYDAY=-1SU;FREQ=YEARLY;BYMONTH=10
line 1,6: unexpected char: '='
Jan 5 11:31:05 dhcp-91 iCal[23884]: Unexpected EOF, returning last token as fallback
Jan 5 11:31:05 dhcp-91 iCal[23884]: VTIMEZONE does not match System Time Zone (Europe/Amsterdam) for 20100105T000000 to 20120105T000000: (
"interval: 2001-01-01 01:00:00 +0100, offset: 3600"
) != (
"interval: 2010-03-28 03:00:00 +0200, offset: 7200",
"interval: 2010-10-31 02:00:00 +0100, offset: 3600",
"interval: 2011-03-27 03:00:00 +0200, offset: 7200",
"interval: 2011-10-30 02:00:00 +0100, offset: 3600"
BEGIN:VTIMEZONE
X-LIC-LOCATION:Europe/Amsterdam
TZID:Europe/Amsterdam
BEGIN:DAYLIGHT
TZOFFSETFROM:+0100
TZNAME:CEST
TZOFFSETTO:+0200
DTSTART:19700329T020000
END:DAYLIGHT
BEGIN:STANDARD
TZOFFSETFROM:+0200
TZNAME:CET
TZOFFSETTO:+0100
DTSTART:19701025T030000
END:STANDARD
END:VTIMEZONE
And when I close iCal I get:
Jan 5 11:33:25 dhcp-91 [0x0-0x592592].com.apple.iCal[23894]: token mismatch: 4 != 5I'm seeing the same thing, and I can't even find where OS X stores calendars on disk anymore...
-
Header and Item data in a module pool
Hi Friends,
I designed a screen in that i have header data and item data.
Here in my screen header i have vendor number,Vendor name,
bank Name, Branch, LC value and Due date fields.
and for item details i have to take table control.In the item details i have the fields Sl No, PO Number and Po Value.
and Two push buttons i need to put.SAVE and CANCEL.
When i click on SAVE all my screen details should be saved in a ZTABLE and should generate a LCDOCUMENT-Number from the system.
So my question is shell i take the two tables for header and item data or one is enough and if i take two tables(one is header and one is item data) how i write the logic to store into the ztables.
How can i proceed.Plz provide me with ur inputs
Thanks and Regards.Hi!
you have to take one table.....in which u have to move the header and item data into that b'coz according to the header data the items are to be displayed.......
select the data for which ever tables they came and then take a final table in which include all the fields of header and item .loop on all the tables from which data u have taken and inside it move the data of those fields into the fields of the final table.
In the ALV u need to call the function module to display the ALV with that final table in which ur all data is there and prepare a field catalog of those fields you want to display in the item list.
for example a sample code is there...
types:
begin of type_s_vbak,
vkorg type vbak-vkorg, " Sales Organization
aufnr type vbak-aufnr, " Sales Order Number
auart type vbak-auart, " Sales Order Type
kunnr type vbak-kunnr, " Customer Number
vbeln type vbak-vbeln, " Sales Document
knumv type vbak-knumv, " Number of Document Condition
end of type_s_vbak. " BEGIN OF TYPE_S_VBAK
types:
begin of type_s_konv,
kwert type konv-kwert, " Condition Value
kbetr type konv-kbetr, " Rate (Condition Amount)
knumv type konv-knumv, " Number of Document Condition
kschl type konv-kschl, " Condition Type
end of type_s_konv. " BEGIN OF TYPE_S_KONV
types:
begin of type_s_material,
kunnr type vbak-kunnr, " Customer Number
matnr type vbap-matnr, " Material Number
arktx type vbap-arktx, " Material Description
steuc type marc-steuc, " Fiscal Classification
kwmeng type vbap-kwmeng, " Quantity
knumv type vbak-knumv, " Number of Document Condition
vbeln type vbak-vbeln, " Document Number
kwert type konv-kwert, " Condition Value
total type p length 14 decimals 2,
" Total
ipitype type p length 9 decimals 3,
" IPI Type
ipivalue type konv-kwert, " IPI Value
end of type_s_material. " BEGIN OF TYPE_S_MATERIAL
data:
fs_vbak type type_s_vbak.
data:
fs_mati type type_s_material.
data:
fs_konv type type_s_konv.
data:
t_vbak like
standard table
of fs_vbak.
data:
t_konv like
standard table
of fs_konv.
data:
t_mati like
standard table
of fs_mati.
loop at t_konv into fs_konv where kschl eq 'ZPNF'.
move fs_konv-kwert to fs_mati-kwert.
modify t_mati from fs_mati
transporting kwert
where knumv eq fs_konv-knumv.
endloop. " LOOP AT T_KONV INTO FS_KONV
* Modifying Total Field of Material Table.
loop at t_mati into fs_mati.
w_total = fs_mati-kwmeng * fs_mati-kwert.
move w_total to fs_mati-total.
modify t_mati from fs_mati
index sy-tabix
transporting total.
clear w_total.
endloop. " LOOP AT T_KONV INTO FS_KONV
* Modifying IPI-Type Field of Material Table.
loop at t_konv into fs_konv where kschl eq 'IPI3'.
w_total = fs_konv-kbetr div 10.
move w_total to fs_mati-ipitype.
modify t_mati from fs_mati
transporting ipitype
where knumv eq fs_konv-knumv.
clear w_total.
endloop. " LOOP AT T_KONV INTO FS_KONV
* Modifying IPI-Value Field of Material Table.
loop at t_konv into fs_konv where kschl eq 'IPI3'.
move fs_konv-kwert to fs_mati-ipivalue.
modify t_mati from fs_mati
transporting ipivalue
where knumv eq fs_konv-knumv.
endloop. " LOOP AT T_KONV INTO FS_KONV
and then fill the fieldcatalog and display the ALV
Edited by: Richa Tripathi on Apr 15, 2009 3:28 PM -
Increment the version and current date in .ver file
Hi All,
I have the version.ver file and it looks like
[version]
BuildDates=2014.10.01
Script=01
MainVersion=1.00.00.00:01
I want to increment the values and current date if i trigger the build using batch script. The output i need is like this
BuildDates=yy.mm.dd (current date)
Script=02
MainVersion=1.00.00.00:02
Thanks in advanceThanks for your reply. This is my script
@echo off>newfile&setlocal enabledelayedexpansion
:: set up your date here. It probably won't match my format so you'll need to adapt:
set dt=%date:~10,4%.%date:~7,2%.%date:~4,2%
for /f "skip=2 tokens=2,3 delims==:" %%a in ("filename") do (
set v= %%b
set v= !v: 0=!
set /a v+=1
set v=0!v!
set v=!v:~-2!
>>newfile echo SCRIPT=!v!
>>newfile echo BuildDates=%dt%
>>newfile echo MajorVersion=%%a:!v!
goto :aa
:aa
more +3 "filename" >> newfile
del "filename"
ren newfile "filename"
Before execute the script my file will be look like:
version]
BuildDates=date
Script=09
MainVersion=3.00.00.00:09
after executing i am getting the output value as
BuildDates=date
Script=01
MainVersion=19:01
MainVersion=3.00.00.00:09 -
SQL query generating data in SQL management studio but not in CUIC interface
Hello,
I'm working on a UCCE 9.0 system
I created SQL query for a report.
Whenever I run the query inside the SQL management studio, it works and generates data, but when I run it in the CUIC interface it works but generates nothing. As you can see in the below snapshot, it contains 209 records that are not being displayed.
Any help would be greatly apprciatedIs it a custom report ? Can you right click on your Custom Report and click on Edit Views. You need to check whether you have Grid Headers Listed.
Regards,
Senthil -
Foreign trade and customs data should be picked automatically in delivery
Dear All,
Foreign trade and customs data should be picked automatically in delivery note and in the invoice once we enter it in the master data for L/C Local Sales for example country Saudi arabia to Saudi Arabia in vi95 or any other transaction you have for this particular master data entry.please helpCheck the customizing settings under
IMG - SD - Foreign Trade/Customs - Basic Data for Foreign Trade - Define Business Transaction Types And Default Value
And the data should be picked up from Material Master record in Foreign trade export view.
They are checked as mandatory fields according to customizing under:
IMG - SD - Foreign Trade/Customs - Control Foreign Trade Data in MM and SD Documents - Incompleteness Schemas for Foreign Trade Data
Also, refer following link:
[Customizing Foreign Trade Master Data |http://wiki.sdn.sap.com/wiki/pages/viewpage.action?spaceKey=ERPLO&title=CustomizingForeignTradeMasterData&decorator=printable]
Thanks & Regards
JP -
I have to record league results and the points against each game and have a total of 84 to record for 15 teams.
I have set it up to record Points, For and Against goals across the page from column C to CH but I have been unable to record the number of times games have been won, lost or drawn.
Is it possible to count each value and have it updated each time Ienter the new results in a new column showing won, lost or drawn?
Any assistance that you can offer will be most appreciatedHere's the code:
I have used a Hashtable to store the value and its number of occurrences. Finally to print the result, I used the toString() method of Hashtable but you can print it in your own way, if u wish.
import java.util.Hashtable;
import java.io.*;
public class Repeating {
public static void main(String args[]) {
int[] num = new int[6];
try {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter six numbers: (press Enter after each number)");
for ( int i=0 ; i<num.length ; i++ ) {
System.out.print("Enter number #" + i + ": ");
num[i] = Integer.parseInt(br.readLine());
System.out.println("The array is: ");
for ( int i=0 ; i<num.length ; i++ ) {
System.out.print(num[i] + " ");
System.out.println("");
} catch (Exception e) {
System.out.println("Enter only one number in each line ...\n\n");
e.printStackTrace();
Hashtable h = new Hashtable();
for ( int i=0 ; i<num.length ; i++ ) {
Integer ii = new Integer(num);
if ( h.containsKey(ii) ) {
Integer val = (Integer) h.get(ii);
h.put(ii, new Integer(val.intValue() + 1));
} else {
h.put(ii, new Integer(1));
System.out.println("\nThe result: (value=number of occurrences)");
System.out.println(h); -
DLL interfacing with mixed value and reference types
I'm currently trying to work with a supplied DLL.
I have header files and all, and the DLL import wizard does a decent job of importing the DLL functions but there are some data types which simply can't be handled.
The DLL requires usage of a data type which is a struct with value and reference data types. I could theoretically replace the references with simple U32s but much of the required information in the data is in the data structures referenced by the pointers.
How do I go about implementing this seeing how I need to be able to pass the data back into the DLL in its original form (value and reference types).
I have something like the following:
struct Item {
Int Device,
*Item Next
*Item Previous
*Data Datastruct
I have downloaded the WDK from Microsoft, have CVI and Visual Studio 2008 available. I'm not very experienced at this end of things... I can deal with Structs with pure value types but how do I get at the data in the reference types?
I strongly suspect I need a wrapper DLL, but how is the best way to go about this?
Shane.
Say hello to my little friend.
RFC 2323 FHE-Compliant
Solved!
Go to Solution.Hi Shane,
To be honest, I don't understand why you have to pass the ENTIRE structue (if it's "Item" structure. The pointer to the next and the previous item should be held and manituplated in the DLL, doesn't it?
Operate within classes....
Are you talking about Labview Classes? I didn't use it yet. Sorry.
Convert Linked List to Array You can't store all elements by value in a cluster, because it's kind of recursive. The next pointer leads to the same Item structure (with it's own next pointer. If it's a circulary-linked-list it will never stop)
Or did you mean to store the pointers as a U32 value? That should work.
Output the struct as a binary blob Yes, why not ! But that lets me assume you don't know the concrete "Datastructure" ?!
I'm honest again I can't see the important information you mentioned if you pass the Data structure as a binary blob.
Read-only is a very good idea. If you don't need to tweak the pointers in the list you should avoid it.
Balze -
Generating Data for INSERT using a Stored Procedure, Function and Cursor
I've written a function that I finally got to compile, but was not successful in importing and inserting the data needed to populate a table with at least 1800 rows. Here's what I needed to do:
-- Generate a random test score ranging from 20 to 100 (already done)
-- Generate a random final grade for the course ranging from 4 to 0 (representing A to F) (already done, but question below.
-- Use conditional statements based on the counter to assign three courses (already done -- see SQL statements)
-- Process no more than 95% of the students (300) for test 1.
-- For test 2, process no more than 80% of the students who took test 1. Student cannot take test 2 unless the student takes test 1 (does this require a trigger? If so, how would I go about doing this?)
-- Use a function or another subprocedure to process the grade using IF-ELSIF statements
For example, I've tried the following statements:
For procedures
IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
school_grade := 6;
AND for functions:
IF birth_date BETWEEN to_date('01-Jan-89 AND to_date('31-Dec-89','dd-Mon-yy') THEN
RETURN (6);
RETURN;
- or -
IF birth_date BETWEEN to_date('01-Jan-89','dd-Mon-yy') AND to_date('31-Dec-89','dd-Mon-yy') THEN
school_grade := 9
RETURN school_grade;
-- Read the birth_date into the main procedure so that the value returned from the subprocedure or function can populate the birth_date column.
To give you an idea of what I've already done:
SQL>
SQL> CREATE OR REPLACE PROCEDURE add_tests (v_school_grade IN NUMBER) AS
2
3 v_counter NUMBER(3) := 0;
4 v_num_students CONSTANT NUMBER(3) := 300;
5 v_students_test1 NUMBER := 0;
6 v_students_test2 NUMBER := 0;
7 v_student_id VARCHAR2(5);
8 v_course1 VARCHAR2(2);
9 v_course2 VARCHAR2(2);
10 v_course3 VARCHAR2(2);
11 v_course4 VARCHAR2(2);
12 v_student_grade NUMBER(1) := 0;
13 v_test_score NUMBER(3) := 0;
14 v_course_final_grade NUMBER(1) := 0;
15 v_birth_date DATE;
16
17 FUNCTION pkg_get_grade RETURN NUMBER
18 IS
19
20 v_birth_date DATE;
21 v_school_grade NUMBER(1) :=0;
22
23 CURSOR grade_cur IS
24 SELECT birth_date FROM students;
25
26 BEGIN
27 OPEN grade_cur;
28 LOOP
29 FETCH grade_cur INTO v_birth_date;
30
31 EXIT WHEN grade_cur%NOTFOUND;
32
33 -- Assign student grade
34
35 -- 9th Grade
36
37 IF v_birth_date < TO_DATE('01-Jan-87','DD-Mon-YY') THEN
38 v_school_grade := 9;
39
40 -- 8th grade
41
42 ELSIF v_birth_date BETWEEN
43 TO_DATE('01-Jan-87','DD-Mon-YY') AND
44 TO_DATE('31-Dec-87','DD-Mon-YY') THEN
45
46 v_school_grade := 8;
47
48 -- 7th grade
49
50 ELSIF v_birth_date BETWEEN
51 TO_DATE('01-Jan-88','DD-Mon-YY') AND
52 TO_DATE('31-Dec-88','DD-Mon-YY') THEN
53
54 v_school_grade := 7;
55
56 -- 6th grade
57
58 ELSIF v_birth_date BETWEEN
59 TO_DATE('01-Jan-89','DD-Mon-YY') AND
60 TO_DATE('31-Dec-89','DD-Mon-YY') THEN
61
62 v_school_grade := 6;
63
64 -- 5th grade
65
66 ELSIF v_birth_date > TO_DATE('31-Dec-89','DD-Mon-YY') THEN
67
68 v_school_grade := 5;
69
70 END IF; -- end if loop for student's grade
71 END LOOP; -- end loop for grade_cur
72 CLOSE grade_cur; -- close cursor for assigning grade
73 RETURN v_school_grade;
74
75 END pkg_get_grade;
76
77 PROCEDURE delete_test_info AS
78
79 BEGIN
80
81 DELETE FROM student_facts;
82
83 END delete_test_info;
84
85 BEGIN
86
87 -- Process student for tests
88
89 WHILE (v_counter <= v_num_students) LOOP
90 v_counter := v_counter + 1; -- initialize counter
91
92 -- Set student id
93
94 v_student_id := 'S'| |v_counter;
95
96 -- portion of students taking beginning of year tests
97
98 v_students_test1 := v_num_students * .95;
99
100
101 -- Portion of students taking end of year tests
102
103 v_students_test2 := v_students_test1 * .80;
104
105
106 -- Est. test scores between 20 and 100
107
108 v_test_score := random.rand_max(80) + 20;
109
110
111 -- Est. final grade for course between 0 and 4
112
113 v_course_final_grade := random.rand_max(4);
114
115
116 -- Process tests for courses
117
118 IF v_counter < ROUND(v_num_students * .20) THEN
119 v_course1 := 'C1';
120 v_course2 := 'C2';
121 v_course3 := 'C3';
122
123 ELSIF v_counter BETWEEN ROUND(v_num_students * .20)
124 AND ROUND(v_num_students * .40) THEN
125
126 v_course1 := 'C2';
127 v_course2 := 'C1';
128 v_course3 := 'C3';
129
130 ELSE IF v_counter BETWEEN ROUND(v_num_students * .40)
131 AND ROUND(v_num_students * .60) THEN
132
133 v_course1 := 'C3';
134 v_course2 := 'C1';
135 v_course3 := 'C2';
136
137 ELSE IF v_counter BETWEEN (v_num_students * .60)
138 AND ROUND(v_num_students * .80) THEN
139
140 v_course1 := 'C3';
141 v_course2 := 'C1';
142 v_course3 := 'C2';
143
144 ELSE
145 v_course1 := 'C4';
146 v_course2 := 'C2';
147 v_course3 := 'C3';
148
149 END IF;
150 END IF;
151 END IF;
152
153 -- Input test information for students
154
155 -- Beginning of year test for Course 1
156
157 IF v_counter <= v_students_test1 THEN
158 INSERT INTO studentfacts
159 VALUES(v_student_id, v_course1, 'ACH1999',
160 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
161 v_student_grade, v_course_final_grade, v_test_score);
162 ELSE
163 INSERT INTO studentfacts
164 VALUES(v_student_id, v_course1, 'ACH1999',
165 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
166 v_student_grade, v_course_final_grade, NULL);
167 END IF;
168
169
170 -- End of year test for Course 1
171
172 IF v_counter <= v_students_test2 THEN
173 INSERT INTO studentfacts
174 VALUES(v_student_id, v_course1,'ACH2000',
175 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
176 v_student_grade, v_course_final_grade, v_test_score);
177 ELSE
178 INSERT INTO studentfacts
179 VALUES(v_student_id, v_course1, 'ACH2000',
180 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
181 v_student_grade, v_course_final_grade, NULL);
182 END IF;
183
184
185 -- Beginning of year test for Course 2
186
187 IF v_counter <= v_students_test1 THEN
188 INSERT INTO studentfacts
189 VALUES(v_student_id, v_course2, 'ACH1999',
190 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
191 v_student_grade, v_course_final_grade,
192 v_test_score);
193 ELSE
194 INSERT INTO studentfacts
195 VALUES(v_student_id, v_course2, 'ACH1999',
196 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
197 v_student_grade, v_course_final_grade, NULL);
198 END IF;
199
200
201 -- End of year test for Course 2
202
203 IF v_counter <= v_students_test2 THEN
204 INSERT INTO studentfacts
205 VALUES(v_student_id, v_course2,'ACH2000',
206 TO_DATE('01-JUN-2001''DD-MON-YYYY'),
207 v_student_grade, v_course_final_grade,
208 v_test_score);
209 ELSE
210 INSERT INTO studentfacts
211 VALUES(v_student_id, v_course2, 'ACH2000',
212 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
213 v_student_grade, v_course_final_grade, NULL);
214 END IF;
215
216
217 -- Beginning of year test for Course 3
218
219 IF v_counter <= v_students_test1 THEN
220 INSERT INTO studentfacts
221 VALUES(v_student_id, v_course3, 'ACH1999',
222 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
223 v_student_grade, v_course_final_grade,
224 v_test_score);
225 ELSE
226 INSERT INTO studentfacts
227 VALUES(v_student_id, v_course3, 'ACH1999',
228 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
229 v_student_grade, v_course_final_grade, NULL);
230 END IF;
231
232
233 -- End of year test for Course 3
234
235 IF v_counter <= v_students_test2 THEN
236 INSERT INTO studentfacts
237 VALUES(v_student_id, v_course3,'ACH2000',
238 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
239 v_student_grade, v_course_final_grade,
240 v_test_score);
241 ELSE
242 INSERT INTO studentfacts
243 VALUES(v_student_id, v_course3, 'ACH2000',
244 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
245 v_student_grade, v_course_final_grade, NULL);
246 END IF;
247
248
249 -- Beginning of year test for Course 4
250
251 IF v_counter <= v_students_test1 THEN
252 INSERT INTO studentfacts
253 VALUES(v_student_id, v_course4, 'ACH1999',
254 TO_DATE('01-SEP-1999','DD-MON-Y YYY'),
255 v_student_grade, v_course_final_grade,
256 v_test_score);
257 ELSE
258 INSERT INTO studentfacts
259 VALUES(v_student_id, v_course4, 'ACH1999',
260 TO_DATE('01-SEP-1999','DD-MON-YYYY'),
261 v_student_grade, v_course_final_grade, NULL);
262 END IF;
263
264
265 -- End of year test for Course 4
266
267 IF v_counter <= v_students_test2 THEN
268 INSERT INTO studentfacts
269 VALUES(v_student_id, v_course4,'ACH2000',
270 TO_DATE('01-JUN-2001', 'DD-MON-YYYY'),
271 v_student_grade, v_course_final_grade, v_test_score);
272 ELSE
273 INSERT INTO studentfacts
274 VALUES(v_student_id, v_course4, 'ACH2000',
275 TO_DATE('01-JUN-2001','DD-MON-YYYY'),
276 v_student_grade, v_course_final_grade, NULL);
277
278 END IF;
279 END LOOP;
280 END add_tests;
281 /
Procedure created.
SQL>
SQL> show errors
No errors.
SQL>
SQL> Input truncated to 9 characters
spool off
When I executed the main procedure, no data populated the student_table. I've tried several things, but I was not still able to populate the student_fact table (I've been at this for more than a week now, but haven't figured a way to populate the student_facts table with at least 1800 rows). Can you tell me what I need to change (if anything) whether if I need to structure things differently? I'm thinking that I missed something in calling the birth_date into the main procedure or returning the value from either a function or subprocedure. Related to the random final grade -- is there a way to sum the totals of the test scores (each student will have three), and generate a final grade from these values.
I also compiled successfully a package containing this same information, but don't know how to execute it to see whether this approach works.
Many thanks to anyone who can help.
nullldsw,
I am not sure if I totally understand everything that you are trying to do, but I tried to clean up your code and what is listed below is what I came up with. Please see if you can make use of any of it.
SQL> EDIT ldsw
CREATE OR REPLACE PACKAGE ldsw
AS
CURSOR grade_cur
IS
SELECT birth_date
FROM students;
PROCEDURE delete_test_info;
FUNCTION get_grade
(v_birth_date IN DATE)
RETURN NUMBER;
PRAGMA RESTRICT_REFERENCES (get_grade, WNDS, WNPS, RNDS, RNPS);
PROCEDURE add_tests;
END ldsw;
CREATE OR REPLACE PACKAGE BODY ldsw
AS
v_student_grade NUMBER (1) := 0;
PROCEDURE delete_test_info
IS
BEGIN
DELETE FROM studentfacts;
END delete_test_info;
FUNCTION get_grade
(v_birth_date IN DATE)
RETURN NUMBER
IS
v_school_grade NUMBER (1) := 0;
BEGIN
IF v_birth_date < TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY')
THEN
v_school_grade := 9;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1987', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1987', 'DD-Mon-YYYY')
THEN
v_school_grade := 8;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1988', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1988', 'DD-Mon-YYYY')
THEN
v_school_grade := 7;
ELSIF v_birth_date BETWEEN TO_DATE ('01-Jan-1989', 'DD-Mon-YYYY') AND TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
THEN
v_school_grade := 6;
ELSIF v_birth_date > TO_DATE ('31-Dec-1989', 'DD-Mon-YYYY')
THEN
v_school_grade := 5;
END IF;
RETURN v_school_grade;
END get_grade;
PROCEDURE add_tests
IS
v_num_students CONSTANT NUMBER (3) := 300;
v_students_test1 NUMBER := 0;
v_students_test2 NUMBER := 0;
v_counter NUMBER (3) := 0;
v_student_id VARCHAR2 (5);
v_test_score NUMBER (3) := 0;
v_course_final_grade NUMBER (1) := 0;
v_course1 VARCHAR2 (2) := NULL;
v_course2 VARCHAR2 (2) := NULL;
v_course3 VARCHAR2 (2) := NULL;
v_course4 VARCHAR2 (2) := NULL;
BEGIN
ldsw.delete_test_info;
v_students_test1 := v_num_students * .95;
v_students_test2 := v_students_test1 * .80;
FOR rec IN grade_cur
LOOP
v_counter := v_counter + 1;
IF v_counter <= v_num_students
THEN
v_student_id := 'S' | | TO_CHAR (v_counter);
v_test_score := random.rand_max (80) + 20;
v_course_final_grade := random.rand_max (4);
IF v_counter < ROUND (v_num_students * .20)
THEN
v_course1 := 'C1';
v_course2 := 'C2';
v_course3 := 'C3';
ELSIF v_counter BETWEEN ROUND (v_num_students * .20) AND ROUND (v_num_students * .40)
THEN
v_course1 := 'C2';
v_course2 := 'C1';
v_course3 := 'C3';
ELSIF v_counter BETWEEN ROUND (v_num_students * .40) AND ROUND (v_num_students * .60)
THEN
v_course1 := 'C3';
v_course2 := 'C1';
v_course3 := 'C2';
ELSIF v_counter BETWEEN ROUND (v_num_students * .60) AND ROUND (v_num_students * .80)
THEN
v_course1 := 'C3';
v_course2 := 'C1';
v_course3 := 'C2';
ELSE
v_course1 := 'C4';
v_course2 := 'C2';
v_course3 := 'C3';
END IF;
SELECT ldsw.get_grade (rec.birth_date)
INTO v_student_grade
FROM DUAL;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course1,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course2,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course3,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test1
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH1999',
TO_DATE ('01-SEP-1999', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
IF v_counter <= v_students_test2
THEN
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
v_test_score);
ELSE
INSERT INTO studentfacts
VALUES (v_student_id,
v_course4,
'ACH2000',
TO_DATE ('01-JUN-2001', 'DD-MON-YYYY'),
v_student_grade,
v_course_final_grade,
NULL);
END IF;
END IF;
END LOOP;
END add_tests;
END ldsw;
Save the file.
SQL> START ldsw
Package created.
Package body created.
SQL> EXECUTE ldsw.add_tests
PL/SQL procedure successfully completed.
SQL> SELECT * FROM student_facts;
null -
Post Author: tadj188#
CA Forum: Formula
Needed: Sum of LineCount Including Groups and Detail Data On Each Page Used To Generate New Page If TotalPageLineCount > 28
Background:
1) Report SQL is created with unions to have detail lines continue on a page, until it reaches page footer or report footer, rather than using subreports. A subreport report is now essentially a group1a, group1b, etc. (containing column headers and other data within the the report with their respective detail lines). I had multiple subreports and each subreport became one union.
Created and tested, already:
1) I have calculated @TotalLineForEachOfTheSameGroup, now I need to sum of the individual same group totals to get the total line count on a page.
Issue:
1) I need this to create break on a certain line before, it dribbles in to a pre-printed area.
Other Ideas Appreciated:
1) Groups/detail lines break inconveniently(dribble) into the pre-printed area, looking for alternatives for above situation.
Thank you.
Tadjexport all image of each page try like this
var myDoc = app.activeDocument;
var myFolder = myDoc.filePath;
var myImage = myDoc.allGraphics;
for (var i=0; myImage.length>i; i++){
app.select(myImage[i]);
var MyImageNmae = myImage[i].itemLink.name;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.high;
app.jpegExportPreferences.exportResolution = 300;
app.selection[0].exportFile(ExportFormat.JPG, File(myFolder+"/"+MyImageNmae+".JPEG"), false);
alert(myImage[i].itemLink.name) -
I would like to know how i can create a bell graph with out using sub VIs, the data that i created consists in 500 readings with values of 0 to 100, i calculated the mean value and standard diviation. I hope some one can help me
Here's a quick example I threw together that generates a sort-of-bell-curve shaped data distribution, then performs the binning and plotting.
-Kevin P.
Message Edited by Kevin Price on 12-01-2006 02:42 PM
Attachments:
Binning example.vi 51 KB
Binning example.png 12 KB
Maybe you are looking for
-
Header and Logo in Blocked ALV
Is It possible to put header and logo in Blocked ALV Report. Is yes shall I go with the same way we put the Header and Logo in ALV Grid report. Thanks in Advance.
-
Problem saving queries with calculated key figures
Hello Experts, I am analyzing this problem since many hours during the last weeks and I don't know, what else to do. The problem is saving a key user query containing a calculated key figure in the production system (BW 3.5 SP SAPKW35015). The Error
-
Hi All, There is a requiremnet to create a report that will contain the total amount due to and from of vendor ,the amount due in the current week. i am using BSEG table. Couid you please guid me to how to get the current week report when ever runs.
-
Premier Elements 12 - PC Windows 8.1 - plenty of disk space and RAM
I have been repeatedly getting the following error message when trying to burn a DVD. The error happens on a mix of different file sizes. Sometimes the system works correctly. internal software error:\Vobulator\BlockPlanner\BlockPlanner.cpp,line 21
-
My finder icon has a red hat, what does that mean?
A few days ago i started up my mac! Everything was the same, nothing changed except the icon of the finder!see picture Does anybody knows what this is? thanks