Incrementing a variable in memory
I have an older application that is querying a list, pulling out an AD from the list, then incrementing the database by +1 with every pull. The site has grown very popular and now the traffic is creating a ton of deadlocks. I tried using CFLOCK but that made things worse.
Instead of writing each increment to the DB, I want to write it to memory and then run a routine which collects that value at some interval and update the DB.
How would I do this? Would I use an Array or some other method? I am not all that familiar with CF. Thanks in advance.
Referring to my last post, it might be more efficient to join the 2 queries into one. In fact I should have commented out the second query as optional. It now looks a bit confusing -- even to me! You would only run it where you needed to use the current number of views from the database.
<cflock scope="application" timeout="10" throwontimeout="no" type="exclusive">
<CFQUERY NAME="application.GRABCOMPANYINFO" DATASOURCE="bg4">
SELECT COMPANY_ID, COMPANY, WEBADDRESS, graphic, flashad
FROM dbo.COMPANIES
WHERE COMPANY_ID = #application.COMPANY_ID#
</CFQUERY>
<!---
<CFQUERY NAME="application.getViews" DATASOURCE="BG4">
SELECT VIEWS, MONTHVIEWS
FROM dbo.BANNERKING
WHERE COMPANY_ID = #application.COMPANY_ID#
</CFQUERY>
--->
<!--- update the number of views for each particular company_id--->
<cfset application.views["#application.COMPANY_ID#"] = application.views["#application.COMPANY_ID#"] + 1>
<cfset application.monthViews["#application.COMPANY_ID#"] = application.monthViews["#application.COMPANY_ID#"] + 1>
</cflock>
<!--- much later in the code ... --->
<cflock scope="application" timeout="10" throwontimeout="no" type="exclusive">
<CFQUERY NAME="UPDATEVIEWS" DATASOURCE="BG4">
UPDATE dbo.BANNERKING
SET VIEWS=#application.views[application.COMPANY_ID]#,MONTHVIEWS=#application.monthViews[appl ication.COMPANY_ID]#
WHERE COMPANY_ID = #application.COMPANY_ID#
</CFQUERY>
</cflock>
Similar Messages
-
Problem while incrementing a variable in Jasper Reports
Hi
I am using Jasper Reports for designing reports. These reports will be used by my Java application.
But there is problem while I am trying to increment a variable depending on some condition.
Requirement: I have to display information about all the residents in a hospital in a single report. Resident information will be fetched from the XML file. When a resident ID is found in the XML, then the variable(resno) shoud be incremented. I have set the initial value to 1.
Problem: Only for the first resident, resno is showing as 1. For all the remaining residents, its showing as 0 (zero).The variable 'resno' is not incrementing for each resident.
Even the ResidentID is not null. All the ResidentID's exists in the XML file.
Please find the code below.
<variable name="resno" class="java.lang.Integer" incrementType="Group" incrementGroup="residentbrk" calculation="Count">
<initialValueExpression><![CDATA[new Integer(1)]]></initialValueExpression>
</variable>
<group name="residentbrk" isStartNewPage="true">
<groupExpression><![CDATA[$F{ResidentID}]]></groupExpression>
<groupHeader>
<band height="16">
<textField hyperlinkType="None">
<reportElement positionType="Float" x="0" y="-1" width="96" height="17"/>
<textElement>
<font isBold="true"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$R{residentno}]]></textFieldExpression>
</textField>
<textField hyperlinkType="None">
<reportElement positionType="Float" x="96" y="-2" width="64" height="18"/>
<textElement/>
<textFieldExpression class="java.lang.Integer"><![CDATA[$V{resno}]]></textFieldExpression>
</textField>
</band>
</groupHeader>
</group>
Could you please provide a solution for this.Not clear at all. May be like this
declare
v_temp varchar2(100);
v_final number;
begin
--loop
v_temp:='sun';
v_temp:=translate(lower(v_temp), '1abcdefghijklmnopqrstuvwxyz', '1');
dbms_output.put_line('Temp:'||v_temp);
v_temp := v_temp || 'Mon5.1';
v_temp:=translate(lower(v_temp), '1abcdefghijklmnopqrstuvwxyz', '1');
dbms_output.put_line('Temp:'||v_temp);
v_temp:= v_temp || 'Tue';
v_temp:=translate(lower(v_temp), '1abcdefghijklmnopqrstuvwxyz', '1');
dbms_output.put_line('Temp:'||v_temp);
v_final:=to_number(v_temp);
dbms_output.put_line('v_final'||v_final);
--coalesce
--end loop;
end;
/ -
Variable size memory is not matching....
Hello, Here is my oracle version..
Oracle Database 10g Enterprise Edition Release 10.1.0.2.0 - Prod
PL/SQL Release 10.1.0.2.0 - Production
CORE 10.1.0.2.0 Production
TNS for 32-bit Windows: Version 10.1.0.2.0 - Production
NLSRTL Version 10.1.0.2.0 - Production
My variable size memory should be exactly same as Java pool, large pool, shared pool.
scott@orcl> show sga
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
scott@orcl> select
2 sum(bytes)
3 from
4 v$sgastat
5 where
6 pool in ('shared pool', 'java pool', 'large pool');
SUM(BYTES)
143369796
The stream pool size should be part of SGA. But it is not showing in v$sgastat view....
In oracle9i, variable size was matching with the above query. Now it is not matching..
Am i missing any thing in my above query? Any help is highly appreicated...still it is not matching... variable size is 145488364 bytes... but the below is showing 142606336.
scott@orcl> show sga
Total System Global Area 171966464 bytes
Fixed Size 787988 bytes
Variable Size 145488364 bytes
Database Buffers 25165824 bytes
Redo Buffers 524288 bytes
scott@orcl> select sum(bytes) from v$sgainfo where name in('Streams Pool Size',
2 'Java Pool Size','Large Pool Size','Shared Pool Size');
SUM(BYTES)
142606336
scott@orcl>
scott@orcl> select * from v$sgainfo;
NAME BYTES RES
Fixed SGA Size 787988 No
Redo Buffers 524288 No
Buffer Cache Size 25165824 Yes
Shared Pool Size 83886080 Yes
Large Pool Size 8388608 Yes
Java Pool Size 50331648 Yes
Streams Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 171966464 No
Startup overhead in Shared Pool 29360128 No
Free SGA Memory Available 0
11 rows selected.
scott@orcl> -
How can I increment a variable in LabView ?
Hello ..
I'm trying to use LabVIEW to increment a variable, but I can't find the right way to do that !
I need to declare a variable and assign zero as its value, then increment it by one each time a certain condition is met, and I need it to reset to zero after it reaches a certain value. It's easy to perform these steps using standard C language but here it looks complicated !
Could someone explain the steps to do that ?
Thanks!I guess trying to explain how to write a state machine would be difficult..
It should take you 5 mins to implement the solution. I post so late that it's probably too late for you.
But here goes.
Take a While loop with shift registers as shown in the image of an earlier post. Place a Case Structure inside the loop. You will need to use an enumerator (usually create a type def control). Put 2 states into the enumerator: reset, increment. Wire the enumerator to the question mark of the Case Structure. In the increment case of the Case Structure, you place the +1. In the reset case you simply wire zero '0' as the proper type (dbl, U32, etc) to the right tunnel of the Case Structure.
In the code somewhere... you need to set the logic to tell the state machine when to reset. I don't recall reading what that was... But in any case, you need another shift register to pass the next state to the Case Statement. Or if that code is embedded into some other code, then it is probably not necessary. But you will need someting like a selector to choose between Increment and Reset. Also choose which of the 2 is the default state, probably any of the 2 for now. The outcome of the logic to reset or increment is obviously wired to the middle terminal of the Select.
Just curious, since you are in this predicament. Did you tell your boss that you knew LabVIEW in order to get the job and now you are obviously stuck delivering a solution? -
Is it possible to use a form variable (in memory) as input to render pdf?
Hi,
I understand that the render to PDF service takes URI as input, but what if I have a xdp form modified and stored in memory, and would like to use that to render PDF, how can this be done?
Thakns in advance.Hi Jasmine,
Thanks for the tip. So, is this what I need to do?
I have an xdp form in the repository, and xml data I generate from a custom component.
1. render the pdf form (merge xdp (no data) with xml data)
2. convert pdf back to xdp (this xdp now includes data) and stored as a document variable in memory
3. manipulate the xdp (via custom component)
4. render the pdf form by passing the xdp (from step 3) in a document variable type as part of the data parameter, leaving URL blank.
5. write pdf to disk
This would work right? Is there another way?
Thanks in advance. -
How to delete variable from memory
Hi,
I need to delete specfic session variables from memory. How
do I do this? What command?
Thanks.Individual keys can be deleted with the StructDelete function
<cfset StructDelete(session, "nameOfTheVariable")>
http://livedocs.adobe.com/coldfusion/7/htmldocs/00000637.htm -
Hi,
I'm a beginner in ABAP and I have a question..
Is possible increment a char variable?
for example I have varible:
R001 and i want increment this variable till RZZZ..
There is some solution or some function that i could use to do this?
Thanks so much.Hi,
please find starting & ending sequence numbers from R000 RZZZ
000 001 002 003 004 005 006 007 008 009 00A 00B 00C 00D 00E 00F 00G 00H 00I 00J 00K 00L 00M 00N
00O 00P 00Q 00R 00S 00T 00U 00V 00W 00X 00Y 00Z 010 011 012 013 014 015 016 017 018 019 020 021
022 023 024 025 026 027 028 029 030 031 032 033 034 035 036 037 038 039 040 041 042 043 044 045
046 047 048 049 050 051 052 053 054 055 056 057 058 059 060 061 062 063 064 065 066 067 068 069
070 071 072 073 074 075 076 077 078 079 080 081 082 083 084 085 086 087 088 089 090 091 092 093
094 095 096 097 098 099 01A 01B 01C 01D 01E 01F 01G 01H 01I 01J 01K 01L 01M 01N 01O 01P 01Q 01R
01S 01T 01U 01V 01W 01X 01Y 01Z 02A 02B 02C 02D 02E 02F 02G 02H 02I 02J 02K 02L 02M 02N 02O 02P
ZUM ZUN ZUO ZUP ZUQ ZUR ZUS ZUT ZUU ZUV ZUW ZUX ZUY ZUZ ZVA ZVB ZVC ZVD ZVE ZVF ZVG ZVH ZVI ZVJ
ZVK ZVL ZVM ZVN ZVO ZVP ZVQ ZVR ZVS ZVT ZVU ZVV ZVW ZVX ZVY ZVZ ZWA ZWB ZWC ZWD ZWE ZWF ZWG ZWH
ZWI ZWJ ZWK ZWL ZWM ZWN ZWO ZWP ZWQ ZWR ZWS ZWT ZWU ZWV ZWW ZWX ZWY ZWZ ZXA ZXB ZXC ZXD ZXE ZXF
ZXG ZXH ZXI ZXJ ZXK ZXL ZXM ZXN ZXO ZXP ZXQ ZXR ZXS ZXT ZXU ZXV ZXW ZXX ZXY ZXZ ZYA ZYB ZYC ZYD
ZYE ZYF ZYG ZYH ZYI ZYJ ZYK ZYL ZYM ZYN ZYO ZYP ZYQ ZYR ZYS ZYT ZYU ZYV ZYW ZYX ZYY ZYZ ZZA ZZB
ZZC ZZD ZZE ZZF ZZG ZZH ZZI ZZJ ZZK ZZL ZZM ZZN ZZO ZZP ZZQ ZZR ZZS ZZT ZZU ZZV ZZW ZZX ZZY ZZZ
My suggestion will be create a custom table and keep all possible combination numbers in it and use this table
a® -
Difference between Pre and Post Incrementing a variable
I have a problem understanding the nuances between i++ and ++i.
I have run several loops and changed the position of the "++". I noticed that sometimes the out put differs and sometimes the output remains the same.
Is there a rule of thumb as to whether a variable show be post or pre incremented?
ThanksThank you all.
After I asked the question, I did a little research and found this (from JGuru shortcourse):
Note that x++ and ++x are equivalent in standalone contexts where the only task is to increment a variable by one,that is, contexts where the ultimate evaluation is ignored:
int x = 4;
x++; // same effect as ++x
System.out.println("x = " + x);
This code produces the output:
x = 5;
The next part after this is:
In the following context, the placement of the increment operator is important:
int x = 4;
int y = x++;
int z = ++x;
System.out.println(
"x = " + x + " y = " + y + " z = " + z);
This code produces the output:
x = 6 y = 4 z = 6
======================================================================
I thought the out put would be x = 4, y = 6, z = 4.
I totally lost! How do I interpet this correctly? -
Variable declaration/memory use
Do you use more memory if you do
int q = stringBuffer.indexOf("cat");
stringBuffer.insert(q, "your ");
than
stringBuffer.insert(stringBuffer.indexOf("cat"), "your ");
I would think no...So you should
go with the second version!How do you come to that conclusion? This kind of
thinking just leads to to code cramming andultimately
hard to maintain code. AND all stack allocationsare
released when the method finishes.Title: "variable declaration/memory use"
That's why I came to this conclusion! Let's say that
in this method you have a for(;;) that never breaks
(like a daemon), this memory is never released, is
it?
Well, to be picky, the question was which uses more memory, not which is better.
In any case, the answer "A uses more memory than B" does not automatically imply "Therefore B is better." This kind of microoptimization is rarely useful. If you're so tight on stack that coding like that makes a difference between your program running or breaking, then you probably either need more memory, or, more likely, a better design. -
Shared variable engine memory problem
Hello,
I have a lot of problems with DSC 8. The server that worked very well in DSC 7, in DSC 8 is creating a lot of problems starting with memory leaks in tagsrv process. I have over 5000 shared variables and when I publish them the tagsrv is around 90Mb of memory. After approx. 30 min is around 130Mb and so on until the computer becomes useless. If I restart the computer the process is the same, even if I don't start the VI that updates the shared variables. I tried to uncheck different things in the variables definition like: no alarming, no buffering, no scaling, with no improvement.
Is there a way to undeploy the shared variables or processes manually, not from the labview project, or Variable Manager. To undeploy the mentioned library with the Variable Manager takes more that an hour (just to enumerate all the shared variables).
Any suggestion is welcomed,
cosmincosmin,
I have several thoughts for you. First, I recommend
splitting up
your 5000 variable library into a set of smaller libraries. In
contrast
with the LabVIEW DSC 7 engine, the LabVIEW 8 Shared Variable Engine is
optimized for multiple smaller libraries. I would recommend
having at
most about 1000 variables per library. You'll see some different
recommendations from different people at NI, but in my personal
experience I
think 1000 is about as many Shared Variables that can be easily managed
at
once. For your case this would mean having 1000 variables in 5
different
libraries. --Splitting up your library gives you the added
benefit of being able to
undeploy/disable individual libraries without affecting the other
libraries. Unfortunately, the SCF migration tool will not do this
for you manually so it may take a little time to get everything
organized.
Your comment about ever-increasing memory usage is
concerning. Do
you see this while deploying your library, or while writing
values? If
you write to values very fast (like in an untimed loop) for an extended
period
of time memory usage will increase as the variable buffers
increase.
Please elaborate more on this topic and let me know what happens if you
separate your variables into multiple libraries. I was not able
to reproduce this on a similarly spec'd computer using 10 libraries of
500 variables each.
You can programmatically undeploy libraries using the delete process VI
on the DSC Engine Control palette in LabVIEW. Use this VI in combination
with the get process list VI to quickly remove all currently deployed
libraries.
Also, regarding your question about why variables sometimes show up the
Published Variable Monitor window; the different utilities you described may
use different methods to get that variable list. These methods behave
differently depending on how stressed the Shared Variable Engine is. If
you're in the middle of loading a library with 5000 variables I'm not surprised
that the list won't get populated immediately in the Published Variable Monitor
window. After the library successfully loads though, you should be able
to refresh the view and see all the variables.
Regards,
Nick F
LabVIEW R&D
~~ -
Variable scope & memory allocation.
Traditional wisdom normally says keep variables in the smalled scope you can (or atlest I think it does, feel free to correct me if I'm wrong from the offset).
However memory allocation on J2ME is going to be slow. So...
int noRects = readCard32();
int pixel = readCard8();
drawOnMe.draw( (pixel >>0 &7) * 36, (pixel >>3 &7) * 36,
(pixel >>6 &3) * 85, mx, my, w, h );
for( int r = 0; r<noRects; r++ ) {
pixel = readCard8();
int lx = readCard8();
int ly = readCard8();
int lw = readCard8();
int lh = readCard8();
drawOnMe.draw( (pixel >>0 &7) * 36, (pixel >>3 &7) * 36,
(pixel >>6 &3) * 85, mx + lx, my + ly,
lw, lh );
// or
int noRects = readCard32();
int pixel = readCard8();
drawOnMe.draw( (pixel >>0 &7) * 36, (pixel >>3 &7) * 36,
(pixel >>6 &3) * 85, mx, my, w, h );
int lx;
int ly;
int lw;
int lh;
for( int r = 0; r<noRects; r++ ) { /* ... */ }MikeAnd as far as the difference - even though I'm not sure there is a performance increase, I'm sure that declaring them outside has no negative effects so I do it just in case.
Plus, I remember reading somewhere that Java had some optimized access support for the first 4 (I think it's 4, and I think it also include the parameters) locals declared in a function, some kind of "fast register" thingie - so in functions that have tight inner loops I always declare the most "accessed" variables right at the top of the function. I don't know how much this holds true for KVMs, but again, it can't hurt.
shmoove -
Hi,
I am wondering about the maximum variable size for display in the variable window...
I have dynamically allocated a structure of about 5000 elements (consisting of a few double arrays) and when clicking on the '+' item in the variable manager I receive the message 'item is too large to expand'.
This message is not welcome, obviously. Why can't one display the first say 20 elements and permit scrolling through the array? I never need to see all 5000 elements simultaneously, due to limited brain and screen capacity, but right now debugging is not possible at all...
Is there a trick to bypass this limitation?
Thanks!Hi,
I think your stucture is too large for the memory of the watch window. Maybe, when your array is not too large, there is a chance to create a pointer to your array und then you can display your array only.
I believe thats the only way how can it work.
regards
Tobias -
Incrementing a variable in a loop
I'm trying to increment my text_item names with a "counter" in my code. Is there a way to do this in PL/SQL? I have 8 text_items I'm trying to fill with a text delimited file. Please see comment within code below.
loop
idxval:= instr( bigstr, ',' );
if idxval = 0 then
smlstr:= bigstr;
else
smlstr:= substr( bigstr, 1, idxval - 1 );
bigstr:= substr( bigstr, idxval + 1 );
end if;
-- increment :text_item name here (8-0) with idxval
:text_item := dbms_output.put_line( smlstr );
exit when idxval = 0;
end loop;
Thanks, MaggieIf you trying to concatenate values to a text_item you should do :
:BlockName_Text_Item := :BlockName_Text_Item || smlstr
It is no necessary use dbms_ouput in forms you just do
:BlockName_Text_Item := smlstr -
How do I increment a variable at the end of a loop to run it through the loop again?
I'm new to LabVIEW programming and I'm trying to write a small program that just receives a lower and upper limit, and whether the user wants to increment or decrement the number. I can't figure out how to increment the number after the simple calculations have been done and to run through the loop again with the incremented number. Right now I'm using a while loop inside of a case structure where true decrements and false increments.
Here are a few possibilities.
Message Edited by altenbach on 12-05-2008 03:25 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
fractionaIncrement.png 8 KB -
Increment of variable after graph execution
Hi all,
I would like to find out if there is any way that I can increase a variable each time a graph is executed in Endeca Integrator/ Endeca Integrator Server. The URL used in my HTTP Connector component found in my graph will need to refer to this variable and I would like this variable to be changed each time the graph is executed. I thought the closest to achieve this will be to make use of a Parameter in the graph but I have not found a good way to update this Parameter the way i define it.
One use case for this is that my HTTP Connector will retrieve data from my internal API and the URL which specifies the offset of the data that I would like to retrieve will be changed each time the graph is executed. The variable shall represent the offset used in the URL.
Thank you!Page 218 of the Integrator Guide has information on using Dictionary Entries to accomplish this requirement: http://docs.oracle.com/cd/E39272_01/integrator.300/IntegratorDesignerGuide.pdf.
Ryan - EID PM
Maybe you are looking for
-
One-Time Customer or Vendor Address Printing in Smart Forms
Hi friends, I am using the Address Node in Smart Forms to print the Addresses in Tax Invoice Printing. How to get the address details for the One-Time Customers which is stored in the BSEC table using the same Address Function. (We can directly get t
-
My iPhone 4 location is hundreds of miles off. Why would this happen?
I live in Iowa. Today my iPhone 4 has shown my location - in Maps, Find my iPhone, and Find my Friends - as in Toronto, San Jose CA, Dallas, and Mesquite TX. It keeps changing, and is hundreds of miles off from my actual location. I'm stumped as to w
-
ERROR IN INSTALLING WLAN DRIVER
Hello, i have problem with instaling the broadcom wireless driver for HP 15-ac026tx running on Windows 8 x64.When i download and try to install the driver i get this error please solve this...i need this driver to connect to any wifi
-
What are the essential services that are required for ensuring server is healthy up ?
Hi All, Please advise me What are the essential services that are required for ensuring server is healthy up ? Warm regards, jk1510
-
Interval onMouseMove AS 3.0
Hi all, I need to make this function in AS3, as I do in AS2. clearInterval (_root.myMouseInterval); this.createEmptyMovieClip ("mcOnenter", 5000); _root.myMouseInterval = setInterval (hideAll, 5000); mcOnenter.onEnterFrame = function () { _root.onMou