IP Address Value within a range
I have this table:
GROUP_UID
GROUP_NAME
IP_VALUE_LOW
IP_VALUE_HIGH
It is used to control the grouping of ranges of IP Address. I need help on two things with this table. I am sure the solution to one will lead me to the other.
1. When given an IP_VALUE I need to return the GROUP_UID/NAME that IP_VALUE falls into. I can not use the normal between IP_VALUE_LOW and IP_VALUE_HIGH becuse the IP Value is not truly consecutive.
13150400 = 192.168.200.0
13150402 = 194.168.200.0 not 192.168.200.2
13150403 = 195.168.200.0 not 192.168.200.3
13150404 = 196.168.200.0 not 192.168.200.4
13150405 = 197.168.200.0 not 192.168.200.5
so 13150403 in not between 13150402 and 13150404
but 192.168.200.3 is between 192.168.200.2 and 192.168.200.4
2. A group is added or updated. I need to ensure that two groups do not overlap ranges.
Any Help would be great!!!
This is the funtion I use now to convert an IP Address to an IP Value:
FUNCTION IPAddressToIPValue2 (in_IPADDRESS VARCHAR2)
return NUMBER
IS
v_OCTET4 NUMBER;
v_OCTET3 NUMBER;
v_OCTET2 NUMBER;
v_OCTET1 NUMBER;
v_IP1 VARCHAR2(20);
v_IP2 VARCHAR2(20);
v_IP3 VARCHAR2(20);
v_IP4 VARCHAR2(20);
BEGIN
if length(in_IPADDRESS) > 15 then
return -3000000000;
end if;
select
max(decode(portion,1,piece)),
max(decode(portion,2,piece)),
max(decode(portion,3,piece)),
max(decode(portion,4,piece))
into
v_IP1,
v_IP2,
v_IP3,
v_IP4
from (
select
seq portion,
substr('.'|| in_IPADDRESS ||'.',instr('.'|| in_IPADDRESS ||'.','.',1,seq)+1,
instr('.'|| in_IPADDRESS ||'.','.',1,seq+1) - instr('.'|| in_IPADDRESS ||'.','.',1,seq) - 1) piece
from (select 1 seq from dual union all select 2 from dual union all select 3 from dual union all select 4 from dual));
v_OCTET4 := to_number(v_IP4);
v_OCTET3 := to_number(v_IP3);
v_OCTET2 := to_number(v_IP2);
v_OCTET1 := to_number(v_IP1);
if v_OCTET1 not between 0 and 255 or v_OCTET2 not between 0 and 255 or v_OCTET3 not between 0 and 255 or v_OCTET4 not between 0 and 255 then
return -3000000000;
else
return
case
when v_OCTET4 < 127 then
v_OCTET4 * power(2,24) + v_OCTET3 * power(2,16) + v_OCTET2 * power(2,8) + v_OCTET1
else
v_OCTET4 * power(2,24) + v_OCTET3 * power(2,16) + v_OCTET2 * power(2,8) + v_OCTET1 - power(2,32)
end;
end if;
END IPAddressToIPValue2;would I just:
return
case
when v_OCTET4 < 127 then
v_OCTET1 + v_OCTET2 * power(2,8) + v_OCTET3 * power(2,16) + v_OCTET4 * power(2,24)
else
v_OCTET1 - power(2,32) + v_OCTET2 * power(2,8) + v_OCTET3 * power(2,16) + v_OCTET4 * power(2,24)
end; Message was edited by:
Chris Wendell
Similar Messages
-
Urgent please- need help to retreive all values within a range
Hi,
I need to retreive all the values(ID) within a range no matter if it is available in the database or not. I just need this in a sql query not a stored proc.
for ex:
select id, name, age
from employee
where id between (1 and 10)
It returns
id name age
1 x 22
3 y 26
4 z 23
10 c 32
I need a query which should return values as follows.
id name age
1 x 22
2
3 y 26
4 z 23
5
6
7
8
9
10 c 32
quick replies will be appreciated.This is one way of doing
select decode(id,null,lev,id),name,age from employee,(select level lev from dual
connect by level < 11)
where employee.id(+)=lev
The above will display between 1 and 10. If you want to specify some other range then the below query will do,
select decode(id,null,lev,id),name,age from employee,(select level lev from dual
connect by level <=10
minus
select level lev from dual
connect by level <5)
where employee.id(+)=lev
The above query will display between 5 and 10 -
Creating a list of unique values within a range.
I have a huge data set I am working with and need to do two things.
First I need to get rid of any repeat entires, which there are many.
Second, and more importantly, I need to generate a list of unique values within a column for which I have no idea what the number or sort of values might be. For instance, say the column contained flavors of ice cream, I am looking for a formula that can return an array of the flavors listed.
Can either of these two things be done in numbers?CJ Eder wrote:
I have a huge data set I am working with and need to do two things.
First I need to get rid of any repeat entires, which there are many.
If entries are in column B starting from B2
In C2 enter the formula:
=IF(COUNTIF($B$1:$B1,B)=0,B,"")
and apply fill down.
You will get a single copy of existing entries.
Select the column C
Copy to Clipboard
Paste in column C
Sort on column C
delete the rows whose cell of column C is blank.
If I understand well, the same protocol apply to your second request.
Yvan KOENIG (from FRANCE mercredi 15 juillet 2009 21:32:30) -
Hi ,
I want to delete records only for a given range. Below is the script it deletes the records based on the given MP range.
And in this Switch table screen shot i have a switchID and ControlPointID column as main reference . For the given range only those records will be deleted. Now i want to delete a different table called SSDB_WIUDATA only for the controlpointIDs deleted on
this switch table. The scenario is ControlpointID will be same even out of the given range also.but switchID will be different So it was easy to delete the records in switch. But while deleting in WIU data i have WIUDataID and ControlPointID as main
column reference . How do i delete the values from WIUData only for the values deleted in switch table? Here ControlPoint ID will be same even out of the range also. So i should delete only within the range that is deleted in Switch table. I dont have Milepost
refernce also in WIU table.i have only ControlPointID as reference. Pls help me
IF (CURSOR_STATUS('global','Switch_cur')) >= -1
BEGIN
DEALLOCATE Switch_cur
END
DECLARE Switch_cur CURSOR FOR
Select SwitchID,ControlPointID FROM SSDB_Switch
WHERE Milepost BETWEEN @BeginMP AND @EndMP
AND SubdivisionID = @subdivisionID
OPEN Switch_cur
FETCH NEXT FROM Switch_cur INTO @SwitchID,@ControlPointID
WHILE (@@FETCH_STATUS=0)
BEGIN
set @Swi = (select Talon_LocEqup_ID from Mapping
where SSDB_ControlpointId_Asset_Id = @SwitchID and AssetType='PTC-Switch')
Delete from tbl_equipmentObjectPropertyValues
where equipmentObjectPropertyValue_object_guid_fk = ''+@Swi+''
Delete from tbl_objects
where object_guid_pk = ''+@Swi+''
DELETE from Mapping
where SSDB_ControlpointId_Asset_Id = @SwitchID
DELETE FROM SSDB_Clearancepoint
WHERE SwitchID = @SwitchID
DELETE FROM SSDB_TurnoutSpeed
WHERE SwitchID = @SwitchID
DELETE FROM SSDB_SwitchRelationship
WHERE SwitchID = @SwitchID
DELETE FROM SSDB_Switch
WHERE SwitchID = @SwitchID
FETCH FROM Switch_cur INTO @SwitchID,@ControlPointID
END ----Cur End
CLOSE Switch_cur
DEALLOCATE Switch_cur
DeepaBelow is the table structure of Switch and WIUData
CREATE TABLE SSDB_Switch (
SwitchID int IDENTITY PRIMARY KEY,
ControlPointID int,
WIUDataID int,
MilepostPrefix varchar(5),
MilepostSuffix varchar(5),
Milepost decimal(10,3) NOT NULL,
TrackName varchar(20) NOT NULL,
Latitude decimal(15,8) NOT NULL,
FOREIGN KEY(WIUDataID) REFERENCES SSDB_WIUData(WIUDataID),
FOREIGN KEY(ControlPointID) REFERENCES SSDB_ControlPoint(ControlPointID)
CREATE TABLE SSDB_WIUData (
WIUDataID int IDENTITY PRIMARY KEY,
ControlPointID int,
DeviceStatusTableID int NOT NULL,
BeaconFlag varchar(1) NOT NULL,
ConfigCRC varchar(8) NOT NULL,
EncryptedHmacKey varchar(64) NOT NULL,
WIUAddress varchar(64) NOT NULL,
WIUID decimal(12,0),
WIUName varchar(40),
WSRSType varchar(17),
InsertDate Datetime NOT NULL DEFAULT getdate(),
UpdateDate Datetime,
InsertUser varchar(50),
UpdateUser varchar(50),
FOREIGN KEY(ControlPointID) REFERENCES SSDB_ControlPoint(ControlPointID),
FOREIGN KEY(DeviceStatusTableID) REFERENCES SSDB_DeviceStatusConfiguration(DeviceStatusTableID),
FOREIGN KEY(BeaconFlag) REFERENCES SSDB_BeaconFlag(BeaconFlag),
FOREIGN KEY(WSRSType) REFERENCES SSDB_WSRSType(WSRSType)
Below is the screen shot for Switch for a range of 170 to 172 Milepost.For this range i have control point ID as 48. And even ControlPoint ID is same for 173 Milepost also. In switch i have deleted only for the range.
Below is the screenshot for WIU table . Here i have only ControlPointID as reference. Even in this table i should delete only the records deleted in switch table.
Deepa -
operate C# to modify PPT's hyperlink, while configuring the hyperlink's text to display attribute, the address value will be assigned as null. Anyone know this issue? Any solution?
How to reproduce the issue:
1.Create a new PPT slide in Office2010.
2. Insert a certain text/characters, such as Mircosoft blablabla,
3. Insert an URL right after the text part , TextToDisplay is the “Test”,Address is the "Url".
4. The content in the ppt is ”Microsoft Test“,here "Test" is the hyperlink which we would like to convert. Please execute the code we list below.
5. The problem will be reproduced by the above steps.
PPT.Application ap = new PPT.Application();
PPT.Presentation pre = null;
pre = ap.Presentations.Open(mFileName, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
foreach (PPT.Slide mSlide in pre.Slides)
PPT.Hyperlinks links = mSlide.Hyperlinks;
for (int i = 1; i <= links.Count; i++)
PPT.Hyperlink mLink = links[i];
mLink.TextToDisplay = mLink.TextToDisplay.Replace(mLink.TextToDisplay,"url");
mLink.Address = mLink.Address.Replace(mLink.Address, "url");
Modify texttodisplay, the address vaule will be assigned as null. Anyone knows how to solve it?
Does it caused by a PPT API's Limitation?I've tried the below code and it works, you can refer this article:
https://msdn.microsoft.com/en-us/library/office/ff745021.aspx
to find that the hyperlink needs to be associated with a text range, and thats what I did in the code below with the help of the link sent by Tony.
Microsoft.Office.Interop.PowerPoint.Application ap = new Application();
Microsoft.Office.Interop.PowerPoint.Presentation pre = null;
pre = ap.Presentations.Open(@"C:\Users\Fouad\Desktop\abcc.pptx", Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoFalse);
foreach (Microsoft.Office.Interop.PowerPoint.Slide mSlide in pre.Slides)
Microsoft.Office.Interop.PowerPoint.Hyperlinks links = mSlide.Hyperlinks;
Microsoft.Office.Interop.PowerPoint.Shape textShape = mSlide.Shapes[1];
for (int i = 1; i <= links.Count; i++)
Microsoft.Office.Interop.PowerPoint.Hyperlink mLink = links[i];
Microsoft.Office.Interop.PowerPoint.TextRange range1 = textShape.TextFrame.TextRange;
TextRange oTxtRng = range1.Find(((Microsoft.Office.Interop.PowerPoint.Hyperlink)mLink).TextToDisplay,After:range1.Start,WholeWords:Microsoft.Office.Core.MsoTriState.msoTrue);
oTxtRng.Replace(((Microsoft.Office.Interop.PowerPoint.Hyperlink)mLink).TextToDisplay, "url");
oTxtRng.ActionSettings[Microsoft.Office.Interop.PowerPoint.PpMouseActivation.ppMouseClick].Hyperlink.Address = "http://www.microsoft.com";
Fouad Roumieh -
Sql to find narrow ranges within broad ranges in the same table?
hi,
i'm building a query to find narrow ranges of zip codes within broader
ranges in a table (for tax purposes). for example:
LOW_ZIP HI_ZIP
23400 23499
need to find
23401 23402
23403 23440
23441 23... you get the picture. :)
so, each row has a low value and a hi value, then i need to run a
subquery to take those values and find narrower ranges. any ideas?
so far here's what i have - neeless to say it doesn't work. :P
select sales_tax_id,
from_postal_code,
to_postal_code
from ar_sales_tax a,
(select from_postal_code as fpc,
to_postal_code as tpc
from ar_sales_tax
where rowid = rowid) b
where from_postal_code between b.fpc and b.tpc
and to_postal_code between b.fpc and b.tpc
and end_date is nullhere's the table layout...
SQL> desc ar_sales_tax
Name Null? Type
LAST_UPDATE_DATE NOT NULL DATE
LAST_UPDATED_BY NOT NULL NUMBER(15)
CREATED_BY NOT NULL NUMBER(15)
CREATION_DATE NOT NULL DATE
LOCATION_ID NOT NULL NUMBER(15)
RATE_CONTEXT NOT NULL VARCHAR2(30)
ENABLED_FLAG NOT NULL VARCHAR2(1)
START_DATE NOT NULL DATE
END_DATE NOT NULL DATE
FROM_POSTAL_CODE NOT NULL VARCHAR2(30)
TO_POSTAL_CODE NOT NULL VARCHAR2(30)
TAX_RATE NOT NULL NUMBER
TAX_ACCOUNT NUMBER(15)
LOCATION1_RATE NUMBER
LOCATION2_RATE NUMBER
LOCATION3_RATE NUMBER
LOCATION4_RATE NUMBER
LOCATION5_RATE NUMBER
LOCATION6_RATE NUMBER
LOCATION7_RATE NUMBER
LOCATION8_RATE NUMBER
LOCATION9_RATE NUMBER
LOCATION10_RATE NUMBER
ATTRIBUTE_CATEGORY VARCHAR2(30)
ATTRIBUTE1 VARCHAR2(150)
ATTRIBUTE2 VARCHAR2(150)
ATTRIBUTE3 VARCHAR2(150)
ATTRIBUTE4 VARCHAR2(150)
ATTRIBUTE5 VARCHAR2(150)
ATTRIBUTE6 VARCHAR2(150)
ATTRIBUTE7 VARCHAR2(150)
ATTRIBUTE8 VARCHAR2(150)
ATTRIBUTE9 VARCHAR2(150)
ATTRIBUTE10 VARCHAR2(150)
ATTRIBUTE11 VARCHAR2(150)
ATTRIBUTE12 VARCHAR2(150)
ATTRIBUTE13 VARCHAR2(150)
ATTRIBUTE14 VARCHAR2(150)
ATTRIBUTE15 VARCHAR2(150)
PROGRAM_APPLICATION_ID NUMBER(15)
PROGRAM_ID NUMBER(15)
PROGRAM_UPDATE_DATE DATE
REQUEST_ID NUMBER(15)
DATE_FIRST_USED DATE
LAST_UPDATE_LOGIN NUMBER(15)
SALES_TAX_ID NOT NULL NUMBER(15)
SQL> spool off -
Function Module to Compare Date within date Range
Hi All,
Does anyone know Function Module to Compare Date within date Range...For example i need to find whether 08/02/2006 falls in between 07/15/2006 and 09/15/2006......data: datum type sy-datum value '20070802',
datum_low type sy-datum value '20070730',
datum_high type sy-datum value '20070930'.
If datum between datum_low and datum_high.
Endif.
Regards,
Rich Heilman -
Change the range of dchp addresses to a unlisted range - 10.31.1.x
i wish to use a new ABSE to run dhcp on my network and act as my wan router. i have a 30 node windows network with one lonely mac (mine) and another 30 statically set devices. the i.p. address range in use currently is 10.31.1.1 - 10.31.1.254. the 30 devices on the lan that are statically set within this range and can't be changed without paying some hefty support charges to the venders of the equipment so changing them is not a real option.
my question is this. can i have the ABSE distribute the range 10.31.1.x instead of the three it lists and can i setup range with the 30 reserved addresses.i am sorry for asking a question that has been posted about before. i found that it is possible to make reservation for some statically assigned devices. it apears that this is a function of the new "n" extreme and not the original abse. i am still searching for the answer to "can i change the range of distributed dhcp address" to 10.31.1.x.
again sorry for not searching fully before posting. -
Random number within TWO ranges
Is there anyway to select a random number within TWO ranges ? For example, a random number between the range (10 to 50) OR (100 to 200).
Thank you !This is a simple class that produces a number between a range:
class RandomRange
static java.util.Random random= new java.util.Random();
* Return an int between n1 and n2
static int getIntBetween(int n1, int n2) // n2 must be greater than n1 or n2-n1 must be positive
// get random number between 0 and the range(n2 - n1)
int result= random.nextInt(n2- n1);
// plus the offset
result += n1;
return result;
// return random.nextInt(n2 - n1) + n1;
// the result is n2 exclusive, to make it inclusive return (result + 1)
* Return a double between d1 and d2
static double getDoubleBetween(double d1, double d2)
return random.nextDouble()*(d2 - d1) + d1;
// d1 and d2 can be any value
* Return a float between f1 and f2
static float getFloatBetween(float f1, float f2)
// similar
}---------------------------------- -
How to get top 11 values per date range
I want to get the top 11 values by date range.
Sample Data
CREATE TABLE SAMPLE_DATA
DOMAIN_NAME VARCHAR2(100),
QTD NUMBER,
LOAD_DATE DATE
-- Insert
BEGIN
FOR lc IN 1..20
LOOP
FOR ld IN 1..30
LOOP
INSERT
INTO SAMPLE_DATA VALUES
'DM_'
||lc,
round(dbms_random.value(0,1000)),
SYSDATE-ld
END LOOP;
END LOOP;
COMMIT;
END;
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE ROWNUM <=10
UNION ALL
SELECT 'Others' DOMAIN_NAME,
SUM(QTD) QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT rownum rn,
DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM SAMPLE_DATA
WHERE LOAD_DATE = TRUNC(SYSDATE-3)
ORDER BY QTD DESC
WHERE rn > 10
GROUP BY LOAD_DATE
ORDER BY QTD DESC
-- Result
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Please, Help me get in one query this result using a range of date.
e.g
using LOAD_DATE BETWEEN '24/03/13' AND '25/03/13'
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/13
DM_1 1000 24/03/13
DM_20 933 24/03/13
DM_11 913 24/03/13
DM_3 743 24/03/13
DM_13 572 24/03/13
DM_12 568 24/03/13
DM_9 564 24/03/13
DM_6 505 24/03/13
DM_5 504 24/03/13
DM_2 480 24/03/13
Others 1948 25/03/13
DM_1 807 25/03/13
DM_8 764 25/03/13
DM_7 761 25/03/13
DM_11 656 25/03/13
DM_18 611 25/03/13
DM_17 523 25/03/13
DM_14 467 25/03/13
DM_19 447 25/03/13
DM_15 437 25/03/13
DM_6 380 25/03/13 Thank you in advance.I got the solution. Just sharing.
I used analytic functions that make my job easy.
Sample Data
DOMAIN_NAME QTD LOAD_DATE
DM_1 807 25/03/2013
DM_1 1000 24/03/2013
DM_2 226 25/03/2013
DM_2 480 24/03/2013
DM_3 244 25/03/2013
DM_3 743 24/03/2013
DM_4 48 25/03/2013
DM_4 413 24/03/2013
DM_5 164 25/03/2013
DM_5 504 24/03/2013
DM_6 380 25/03/2013
DM_6 505 24/03/2013
DM_7 761 25/03/2013
DM_7 212 24/03/2013
DM_8 764 25/03/2013
DM_8 308 24/03/2013
DM_9 354 25/03/2013
DM_9 564 24/03/2013
DM_10 214 25/03/2013
DM_10 367 24/03/2013
DM_11 656 25/03/2013
DM_11 913 24/03/2013
DM_12 37 25/03/2013
DM_12 568 24/03/2013
DM_13 332 25/03/2013
DM_13 572 24/03/2013
DM_14 467 25/03/2013
DM_14 87 24/03/2013
DM_15 437 25/03/2013
DM_15 450 24/03/2013
DM_16 238 25/03/2013
DM_16 299 24/03/2013
DM_17 523 25/03/2013
DM_17 143 24/03/2013
DM_18 611 25/03/2013
DM_18 145 24/03/2013
DM_19 447 25/03/2013
DM_19 464 24/03/2013
DM_20 91 25/03/2013
DM_20 933 24/03/2013 Top 11 QTD of DOMAIN_NAME per Data Range.
SELECT *
FROM
(SELECT DOMAIN_NAME,
QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD <= 10
UNION ALL
SELECT 'Others',
SUM(QTD) AS QTD,
LOAD_DATE
FROM
(SELECT LOAD_DATE,
DOMAIN_NAME ,
QTD,
(DENSE_RANK() OVER (PARTITION BY LOAD_DATE ORDER BY QTD DESC )) AS RANK_QTD
FROM SAMPLE_DATA
WHERE trunc(load_date) BETWEEN '24/03/2013' AND '25/03/2013'
WHERE RANK_QTD > 10
GROUP BY LOAD_DATE
ORDER BY LOAD_DATE ASC,
QTD DESC
DOMAIN_NAME QTD LOAD_DATE
Others 2888 24/03/2013
DM_1 1000 24/03/2013
DM_20 933 24/03/2013
DM_11 913 24/03/2013
DM_3 743 24/03/2013
DM_13 572 24/03/2013
DM_12 568 24/03/2013
DM_9 564 24/03/2013
DM_6 505 24/03/2013
DM_5 504 24/03/2013
DM_2 480 24/03/2013
Others 1948 25/03/2013
DM_1 807 25/03/2013
DM_8 764 25/03/2013
DM_7 761 25/03/2013
DM_11 656 25/03/2013
DM_18 611 25/03/2013
DM_17 523 25/03/2013
DM_14 467 25/03/2013
DM_19 447 25/03/2013
DM_15 437 25/03/2013
DM_6 380 25/03/2013 -
how to obtain all values in field range of domain?
Hello,
YOu can find those values in table DD07L
Regards
Naimesh -
Trying to get multiple cell values within a geometry
I am provided with 3 tables:
1 - The GeoRaster
2 - The geoRasterData table
3 - A VAT table who's PK is the cell value from the above tables
Currently the user can select a point in our application and by using the getCellValue we get the cell value which is the PK on the 3rd table and this gives us the details to return to the user.
We now want to give the worst scenario within a given geometry or distance. So if I get back all the cell values within a given geometry/distance I can then call my other functions against the 3rd table to get the worst scores.
I had a conversation open for this before where JeffreyXie had some brilliant input, but it got archived while I was waiting on Oracle to resolve a bug (about 7 months)
See:
Trying to get multiple cell values within a geometry
If I am looking to get a list of cell values that interact with my geometry/distance and then loop through them, is there a better way?
BTW, if anybody wants to play with this functionality, it only seems to work in 11.2.0.4.
Below is the code I was using last, I think it is trying to get the cell values but the numbers coming back are not correct, I think I am converting the binary to integer wrong.
Any ideas?
CREATE OR REPLACE FUNCTION GEOSUK.getCellValuesInGeom_FNC RETURN VARCHAR2 AS
gr sdo_georaster;
lb blob;
win1 sdo_geometry;
win2 sdo_number_array;
status VARCHAR2(1000) := NULL;
CDP varchar2(80);
FLT number := 0;
cdl number;
vals varchar2(32000) := null;
VAL number;
amt0 integer;
amt integer;
off integer;
len integer;
buf raw(32767);
MAXV number := null;
r1 raw(1);
r2 raw(2);
r4 raw(200);
r8 raw(8);
MATCH varchar2(10) := '';
ROW_COUNT integer := 0;
COL_COUNT integer := 0;
ROW_CUR integer := 0;
COL_CUR integer := 0;
CUR_XOFFSET integer := 0;
CUR_YOFFSET integer := 0;
ORIGINY integer := 0;
ORIGINX integer := 0;
XOFF number(38,0) := 0;
YOFF number(38,0) := 0;
BEGIN
status := '1';
SELECT a.georaster INTO gr FROM JBA_MEGARASTER_1012 a WHERE id=1;
-- first figure out the celldepth from the metadata
cdp := gr.metadata.extract('/georasterMetadata/rasterInfo/cellDepth/text()',
'xmlns=http://xmlns.oracle.com/spatial/georaster').getStringVal();
if cdp = '32BIT_REAL' then
flt := 1;
end if;
cdl := sdo_geor.getCellDepth(gr);
if cdl < 8 then
-- if celldepth<8bit, get the cell values as 8bit integers
cdl := 8;
end if;
dbms_lob.createTemporary(lb, TRUE);
status := '2';
-- querying/clipping polygon
win1 := SDO_GEOM.SDO_BUFFER(SDO_GEOMETRY(2001,27700,MDSYS.SDO_POINT_TYPE(473517,173650.3, NULL),NULL,NULL), 10, .005);
status := '1.2';
sdo_geor.getRasterSubset(gr, 0, win1, '1',
lb, win2, NULL, NULL, 'TRUE');
-- Then work on the resulting subset stored in lb.
status := '2.3';
DBMS_OUTPUT.PUT_LINE ( 'cdl: '||cdl );
len := dbms_lob.getlength(lb);
cdl := cdl / 8;
-- make sure to read all the bytes of a cell value at one run
amt := floor(32767 / cdl) * cdl;
amt0 := amt;
status := '3';
ROW_COUNT := (WIN2(3) - WIN2(1))+1;
COL_COUNT := (WIN2(4) - WIN2(2))+1;
--NEED TO FETCH FROM RASTER
ORIGINY := 979405;
ORIGINX := 91685;
--CALCUALATE BLOB AREA
YOFF := ORIGINY - (WIN2(1) * 5); --177005;
XOFF := ORIGINX + (WIN2(2) * 5); --530505;
status := '4';
--LOOP CELLS
off := 1;
WHILE off <= LEN LOOP
dbms_lob.read(lb, amt, off, buf);
for I in 1..AMT/CDL LOOP
if cdl = 1 then
r1 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
VAL := UTL_RAW.CAST_TO_BINARY_INTEGER(R1);
elsif cdl = 2 then
r2 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
val := utl_raw.cast_to_binary_integer(r2);
ELSIF CDL = 4 then
IF (((i-1)*cdl+1) + cdl) > len THEN
r4 := utl_raw.substr(buf, (i-1)*cdl+1, (len - ((i-1)*cdl+1)));
ELSE
r4 := utl_raw.substr(buf, (i-1)*cdl+1, cdl+1);
END IF;
if flt = 0 then
val := utl_raw.cast_to_binary_integer(r4);
else
val := utl_raw.cast_to_binary_float(r4);
end if;
elsif cdl = 8 then
r8 := utl_raw.substr(buf, (i-1)*cdl+1, cdl);
val := utl_raw.cast_to_binary_double(r8);
end if;
if MAXV is null or MAXV < VAL then
MAXV := VAL;
end if;
IF i = 1 THEN
VALS := VALS || VAL;
ELSE
VALS := VALS ||'|'|| VAL;
END IF;
end loop;
off := off+amt;
amt := amt0;
end loop;
dbms_lob.freeTemporary(lb);
status := '5';
RETURN VALS;
EXCEPTION
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR(-20001, 'GENERAL ERROR IN MY PROC, Status: '||status||', SQL ERROR: '||SQLERRM);
END;Hey guys,
Zzhang,
That's a good spot and as it happens I spotted that and that is why I am sure I am querying that lob wrong. I always get the a logic going past the total length of the lob.
I think I am ok using 11.2.0.4, if I can get this working it is really important to us, so saying to roll up to 11.2.0.4 for this would be no problem.
The error in 11.2.0.3 was an internal error: [kghstack_underflow_internal_3].
Something that I think I need to find out more about, but am struggling to get more information on is, I am assuming that the lob that is returned is all cell values or at lest an array of 4 byte (32 bit) chunks, although, I don't know this.
Is that a correct assumption or is there more to it?
Have either of you seen any documentation on how to query this lob?
Thanks -
Assigning value to a range dynamically
Hello All,
I want to assign the values to a range dynamically.
For example in the following piece of code, I cannot directly assign wa-kunnr to
r_kunnr-low.
LOOP AT ITAB INTO WA.
r_kunnr-sign = 'I'.
r_kunnr-option = 'EQ'.
r_kunnr-low = wa-kunnr.
APPEND r_kunnr.
ENDLOOP.
Can this be done dynamically? If I use following code I am getting a short dump.
lv_fnam = 'wa-kunnr'.
LOOP AT ITAB INTO WA.
r_kunnr-sign = 'I'.
r_kunnr-option = 'EQ'.
r_kunnr-low = ( lv_fnam ).
APPEND r_kunnr.
ENDLOOP.
Could anyone please suggest how to do this?
Regards
IndrajitHi,
Try giving it capital letters
lv_fnam = <b>'WA-KUNNR'</b>.
LOOP AT ITAB INTO WA.
r_kunnr-sign = 'I'.
r_kunnr-option = 'EQ'.
r_kunnr-low = ( lv_fnam ).
APPEND r_kunnr.
ENDLOOP.
Thanks
Naren -
Make field read only untill value within pciklist is choosen
Hello,
I am trying to establish if it is possible to make a field read-only until a value within a pick list is chosen. Basically we have a pick list called structure and if the field value called "Aligned" is selected then I want the text field called Aligned Name to be available for import all other times this field should not be available.
Has anyone done anything similar? I'm guessing that this could only be achieved through WF but I haven't been able to find any code to make fields read only.For those of you unable to download the document from MetaLink3 here it is:
As an example to illustrate this requirement, let’s say that once there is a checkbox field called "My_Check_Box". When this field is checked, the "Account Type" field need to become a required for entry by the user. To do this follow these steps:
1. In the Admin> Application Customization, select the appropriate Object and go into the Object Field Setup.
2. Edit the field called "My_Check_Box" and enter a Field Validation expression so it uses the following expression:
=[<bMy_Check_Box_ITAG>] AND NOT([<AccountType>] IS NULL AND [<bMy_Check_Box_ITAG >]='Y')
3. Enter an explicit error message.
This expression means that when the checkbox field is checked, the Account Type becomes required. Your custom error message will be raised when checking the checkbox, leaving the account type unpopulated and trying to save the account record.
4. Edit the Account Type field and enter the following expression as Field Validation:
=[<AccountType>] AND NOT([<AccountType>] IS NULL AND [<bMy_Check_Box_ITAG >]='Y')
5. Enter an explicit error message.
That validation handles the user case where a user changes the Account Type value from a NOT NULL value to a NULL value. Your custom error message will be raised when emptying out the account type from a populated value to nothing while the checkbox is checked and trying to save the account record.
Note that the expression in both fields validations begins with the field variable on which the statement is being written.** -
How To pass the value within the page using jsp?
How to passing the textbox value within the jsp page without using javascript or reload the page.
I have a scenario like this:
I have a textbox named as "accno" which allow user to key in the accno. After key in the accno, this accno value will used to do a query from database using jstl.
here is part of my code
<input name="accno" type="text" onChange="checkLC()"/>
<sql:query var="results" dataSource="${db}">
select accno,name from account where accno = '<%=value get from accno textbox%>'
</sql:query>
<c:out value="${result.rows[0].name}"/>
note that onChange() is the javascript when user key in accno then automatically go to check database then only show out the name. So how can i get the '<%=value get from accno textbox%>' from accno textbox.How to passing the textbox value within the jsp page
without using javascript or reload the page.No, jsp executes on the remoter server, the text box is on a client machine, you need to send information to the server over the network, http does this with a request, which will reload the page.....................
Maybe you are looking for
-
Shared iTunes Library not available
My iTunes library is located in the "Shared" users account and pointed to by a folder alias in my own "Music" folder. However, when setting up a slide show in iPhoto, my iTune tracks are not available. In fact iTunes does not even show up in the Musi
-
Sadly, after 7 years loyal service my powerbook fell on the floor and the right hand hinge snapped. Now all I get on start up is a quick flicker and black screen but an external screen fires up fine - except it doesn't show the login screen but an em
-
The composers of The Sims 2 music, which is compiled of many pop songs of today and turned into simmish language by Shawn K. Clement and Mark Mothersbaugh, is a creation I've wanted to establish with my own pop music. Does anyone know how they did it
-
I just downloaded Photos for Mac and did a test drive on the new SlideShow features. I noticed that it is impossible to stop a slide show once it has been started. There appear to be no keyboard keys (not escape either) or mouse movements that r
-
Design a simple calculator for multiple number systems
Details: 1. Before designing the graphical user interface, create an abstract class called Number and four derived classes called Binary, Octal, Decimal, and Hexadecimal. Use the following structure for your Number class. The derived classes shou