GetString() and column datatypes
Hi,
I have a program that reads the row values of a SELECT statement as strings.
std::string value = resultSet->getString(IntCol); // read an integer value as string instead of getInt()
The getString() function returns a std::string for almost all datatypes (like integer, float) correctly, except when it comes to Timestamp. Here getString() returns an empty string.
What surprised me that it worked as well for a column with the DATE datatype (getString() returns a string formatted with the session parameter NLS_DATE_FORMAT).
But this is not true for the Timestamp datatype. Here, I have to create explicitly a Timestamp object:
Timestamp time = resultSet->getTimestamp();
std::string value = time.toText(format, 6);
Is that a bug? Why isn't the session variable NLS_TIMESTAMP_FORMAT used (like DATE)?
Any suggestions appreciated! Thanks.
Christian
Use either a NLS_TIMESTAMP_FORMAT or explicitly convert timestamp to string by using TO_CHAR
Similar Messages
-
Difference between CHAR and VARCHAR2 datatype
Difference between CHAR and VARCHAR2 datatype
CHAR datatype
If you have an employee name column with size 10; ename CHAR(10) and If a column value 'JOHN' is inserted, 6 empty spaces will be inserted to the right of the value. If this was a VARCHAR column; ename VARCHAR2(10). How would it handle the column value 'JOHN' ?The CHAR datatype stores fixed-length character strings, and Oracle compares CHAR values using blank-padded comparison semantics.
Where as the VARCHAR2 datatype stores variable-length character strings, and Oracle compares VARCHAR2 values using nonpadded comparison semantics.
This is important when comparing or joining on the columns having these datatypes;
SQL*Plus: Release 10.2.0.1.0 - Production on Pzt Au 6 09:16:45 2007
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn hr/hr
Connected.
SQL> set serveroutput on
SQL> DECLARE
2 last_name1 VARCHAR2(10) := 'TONGUC';
3 last_name2 CHAR(10) := 'TONGUC';
4 BEGIN
5 IF last_name1 = last_name2 THEN
6 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is equal to -' || last_name2
|| '-');
7 ELSE
8 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is NOT equal to -' || last_n
ame2 || '-');
9 END IF;
10 END;
11 /
-TONGUC- is NOT equal to -TONGUC -
PL/SQL procedure successfully completed.
SQL> DECLARE
2 last_name1 CHAR(6) := 'TONGUC';
3 last_name2 CHAR(10) := 'TONGUC';
4 BEGIN
5 IF last_name1 = last_name2 THEN
6 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is equal to -' || last_name2
|| '-');
7 ELSE
8 DBMS_OUTPUT.PUT_LINE ( '-' || last_name1 || '- is NOT equal to -' || last_n
ame2 || '-');
9 END IF;
10 END;
11 /
-TONGUC- is equal to -TONGUC -
PL/SQL procedure successfully completed.
Also you may want to read related asktom thread - "Char Vs Varchar" http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1542606219593
and http://tahitiviews.blogspot.com/2007/05/less-is-more-more-or-less.html
Best regards. -
How to copy a table with LONG and CLOB datatype over a dblink?
Hi All,
I need to copy a table from an external database into a local one. Note that this table has both LONG and CLOB datatypes included.
I have taken 2 approaches to do this:
1. Use the CREATE TABLE AS....
SQL> create table XXXX_TEST as select * from XXXX_INDV_DOCS@ext_db;
create table XXXX_TEST as select * from XXXX_INDV_DOCS@ext_db
ERROR at line 1:
ORA-00997: illegal use of LONG datatype
2. After reading some threads I tried to use the COPY command:
SQL> COPY FROM xxxx/pass@ext_db TO xxxx/pass@target_db REPLACE XXXX_INDV_DOCS USING SELECT * FROM XXXX_INDV_DOCS;
Array fetch/bind size is 15. (arraysize is 15)
Will commit when done. (copycommit is 0)
Maximum long size is 80. (long is 80)
CPY-0012: Datatype cannot be copied
If my understanding is correct the 1st statement fails because there is a LONG datatype in XXXX_INDV_DOCS table and 2nd one fails because there is a CLOB datatype.
Is there a way to copy the entire table (all columns including both LONG and CLOB) over a dblink?
Would greatelly appriciate any workaround or ideas!
Regards,
Pawel.Hi Nicolas,
There is a reason I am not using export/import:
- I would like to have a one-script solution for this problem (meaning execute one script on one machine)
- I am not able to make an SSH connection from the target DB to the local one (although the otherway it works fine) which means I cannot copy the dump file from target server to local one.
- with export/import I need to have an SSH connection on the target DB in order to issue the exp command...
Therefore, I am looking for a solution (or a workaround) which will work over a DBLINK.
Regards,
Pawel. -
Table name input. and output i need all rows and columns using procedures
hi,
question: table name input. and output i need all rows and columns by using procedures.
thanks,
To AllAn example of using DBMS_SQL package to execute dynamic SQL (in this case to generate CSV data in a file)...
As sys user:
CREATE OR REPLACE DIRECTORY TEST_DIR AS '\tmp\myfiles'
GRANT READ, WRITE ON DIRECTORY TEST_DIR TO myuser
/As myuser:
CREATE OR REPLACE PROCEDURE run_query(p_sql IN VARCHAR2
,p_dir IN VARCHAR2
,p_header_file IN VARCHAR2
,p_data_file IN VARCHAR2 := NULL) IS
v_finaltxt VARCHAR2(4000);
v_v_val VARCHAR2(4000);
v_n_val NUMBER;
v_d_val DATE;
v_ret NUMBER;
c NUMBER;
d NUMBER;
col_cnt INTEGER;
f BOOLEAN;
rec_tab DBMS_SQL.DESC_TAB;
col_num NUMBER;
v_fh UTL_FILE.FILE_TYPE;
v_samefile BOOLEAN := (NVL(p_data_file,p_header_file) = p_header_file);
BEGIN
c := DBMS_SQL.OPEN_CURSOR;
DBMS_SQL.PARSE(c, p_sql, DBMS_SQL.NATIVE);
d := DBMS_SQL.EXECUTE(c);
DBMS_SQL.DESCRIBE_COLUMNS(c, col_cnt, rec_tab);
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
WHEN 2 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_n_val);
WHEN 12 THEN DBMS_SQL.DEFINE_COLUMN(c,j,v_d_val);
ELSE
DBMS_SQL.DEFINE_COLUMN(c,j,v_v_val,2000);
END CASE;
END LOOP;
-- This part outputs the HEADER
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_header_file,'w',32767);
FOR j in 1..col_cnt
LOOP
v_finaltxt := ltrim(v_finaltxt||','||lower(rec_tab(j).col_name),',');
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
IF NOT v_samefile THEN
UTL_FILE.FCLOSE(v_fh);
END IF;
-- This part outputs the DATA
IF NOT v_samefile THEN
v_fh := UTL_FILE.FOPEN(upper(p_dir),p_data_file,'w',32767);
END IF;
LOOP
v_ret := DBMS_SQL.FETCH_ROWS(c);
EXIT WHEN v_ret = 0;
v_finaltxt := NULL;
FOR j in 1..col_cnt
LOOP
CASE rec_tab(j).col_type
WHEN 1 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_v_val);
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
WHEN 2 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_n_val);
v_finaltxt := ltrim(v_finaltxt||','||v_n_val,',');
WHEN 12 THEN DBMS_SQL.COLUMN_VALUE(c,j,v_d_val);
v_finaltxt := ltrim(v_finaltxt||','||to_char(v_d_val,'DD/MM/YYYY HH24:MI:SS'),',');
ELSE
v_finaltxt := ltrim(v_finaltxt||',"'||v_v_val||'"',',');
END CASE;
END LOOP;
-- DBMS_OUTPUT.PUT_LINE(v_finaltxt);
UTL_FILE.PUT_LINE(v_fh, v_finaltxt);
END LOOP;
UTL_FILE.FCLOSE(v_fh);
DBMS_SQL.CLOSE_CURSOR(c);
END;This allows for the header row and the data to be written to seperate files if required.
e.g.
SQL> exec run_query('select * from emp','TEST_DIR','output.txt');
PL/SQL procedure successfully completed.Output.txt file contains:
empno,ename,job,mgr,hiredate,sal,comm,deptno
7369,"SMITH","CLERK",7902,17/12/1980 00:00:00,800,,20
7499,"ALLEN","SALESMAN",7698,20/02/1981 00:00:00,1600,300,30
7521,"WARD","SALESMAN",7698,22/02/1981 00:00:00,1250,500,30
7566,"JONES","MANAGER",7839,02/04/1981 00:00:00,2975,,20
7654,"MARTIN","SALESMAN",7698,28/09/1981 00:00:00,1250,1400,30
7698,"BLAKE","MANAGER",7839,01/05/1981 00:00:00,2850,,30
7782,"CLARK","MANAGER",7839,09/06/1981 00:00:00,2450,,10
7788,"SCOTT","ANALYST",7566,19/04/1987 00:00:00,3000,,20
7839,"KING","PRESIDENT",,17/11/1981 00:00:00,5000,,10
7844,"TURNER","SALESMAN",7698,08/09/1981 00:00:00,1500,0,30
7876,"ADAMS","CLERK",7788,23/05/1987 00:00:00,1100,,20
7900,"JAMES","CLERK",7698,03/12/1981 00:00:00,950,,30
7902,"FORD","ANALYST",7566,03/12/1981 00:00:00,3000,,20
7934,"MILLER","CLERK",7782,23/01/1982 00:00:00,1300,,10The procedure allows for the header and data to go to seperate files if required. Just specifying the "header" filename will put the header and data in the one file.
Adapt to output different datatypes and styles are required. -
I'm writing an exercise to learn more about different datatypes and am confused about the use of and difference between rowid and urowid. As I understand it using rowid should only be done when writing for backwards compatibility, and urowid should be used for new coding. I'm working in 9.2.0.1.0, so I assume I should use urowid.
The following code returns an error (shown below). Anyone know why this is happenning?
create or replace function lrnvrbls
return varchar2
is
v_rowid urowid;
v_data varchar2(100);
select rowid
into v_rowid
from mytable
where rownum = 10 -- 10 is just a number I chose
execute immediate
'select mycolumn ' ||
'from mytable ' ||
'where rowid = ' ||
v_rowid
into v_data;
return v_data;
end;
SQL>select lrnvrbls from dual;
select lrnvrbls from dual
ORA-00904: "AAAHCAAAMAAAADVAAI": invalid identifier
I've tried using both ROWID and UROWID datatypes with no luck. Also tried CHARTOROWID and ROWIDTOCHAR and failed the same way.
Anybody understand how to use this?A single datatype called the universal rowid, or UROWID, supports both logical
and physical rowids, as well as rowids of foreign tables such as non-Oracle
tables accessed through a gateway.
A column of the UROWID datatype can store all kinds of rowids. The value of the
COMPATIBLE initialization parameter must be set to 8.1 or higher to use UROWID
columns.
DROP TABLE mytable
CREATE TABLE mytable
AS SELECT owner mycolumn FROM all_tables
WHERE rownum < 100
CREATE OR REPLACE
FUNCTION lrnvrbls
RETURN varchar2
IS
v_rowid urowid;
v_data varchar2(100);
strSQL varchar2(255);
BEGIN
select rowid
into v_rowid
from mytable
where rownum = 1;
strSQL := 'select mycolumn from mytable where rowid = '''||v_rowid ||'''';
execute immediate strSQL into v_data;
return v_data;
END lrnvrbls;
SELECT lrnvrbls FROM DUAL
DROP FUNCTION lrnvrbls
DROP TABLE mytable
COMMIT
16:39:37 SQL> DROP TABLE mytable
16:39:39 2 /
Table dropped.
Elapsed: 00:00:00.00
16:39:39 SQL> --
16:39:39 SQL> CREATE TABLE mytable
16:39:39 2 AS SELECT owner mycolumn FROM all_tables
16:39:39 3 WHERE rownum < 100
16:39:39 4 /
Table created.
Elapsed: 00:00:00.00
16:39:39 SQL> --
16:39:39 SQL> CREATE OR REPLACE
16:39:39 2 FUNCTION lrnvrbls
16:39:39 3 RETURN varchar2
16:39:39 4 IS
16:39:39 5 --
16:39:39 6 v_rowid urowid;
16:39:39 7 v_data varchar2(100);
16:39:39 8 strSQL varchar2(255);
16:39:39 9 --
16:39:39 10 BEGIN
16:39:39 11 --
16:39:39 12 select rowid
16:39:39 13 into v_rowid
16:39:39 14 from mytable
16:39:39 15 where rownum = 1;
16:39:39 16 --
16:39:39 17 strSQL := 'select mycolumn from mytable where rowid = '''||v_rowid ||'''';
16:39:39 18 --
16:39:39 19 execute immediate strSQL into v_data;
16:39:39 20 --
16:39:39 21 return v_data;
16:39:39 22 --
16:39:39 23 END lrnvrbls;
16:39:39 24 /
Function created.
Elapsed: 00:00:00.00
16:39:39 SQL> --
16:39:39 SQL> SELECT lrnvrbls FROM DUAL
16:39:39 2 /
LRNVRBLS
SYS
Elapsed: 00:00:00.00
16:39:39 SQL> --
16:39:39 SQL> DROP FUNCTION lrnvrbls
16:39:39 2 /
Function dropped.
Elapsed: 00:00:00.01
16:39:40 SQL> DROP TABLE mytable
16:39:40 2 /
Table dropped.
Elapsed: 00:00:00.00
16:39:40 SQL> COMMIT
16:39:40 2 /
Commit complete.
Elapsed: 00:00:00.00
16:39:40 SQL>
*/ -
Hi,
I created a table with some 10 columns earlier, now one of the column datatype needs to be changed to varchar2(2), which actually in the database it is number.
The thing the table now contains 10 records. Its not allowing me to modify the column datatype, because it has rows in it. How to change the column datatype with data in the table. Pl reply ASAP.
ThanksSee the following example.
Let's modify deptno column from number to varchar2 :
SCOTT@demo102> desc emp2
Name Null? Type
EMPNO NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SCOTT@demo102> select count(*) from emp2;
COUNT(*)
14
SCOTT@demo102> alter table emp2 modify deptno varchar2(2);
alter table emp2 modify deptno varchar2(2)
ERROR at line 1:
ORA-01439: column to be modified must be empty to change datatype
SCOTT@demo102> alter table emp2[b] add deptno2 varchar2(2);
Table altered.
SCOTT@demo102> update emp2 set deptno2=deptno;
14 rows updated.
SCOTT@demo102> commit;
Commit complete.
SCOTT@demo102> alter table emp2 drop column deptno
SCOTT@demo102> /
Table altered.
SCOTT@demo102> alter table emp2 rename column deptno2 to deptno
SCOTT@demo102> /
Table altered.
SCOTT@demo102> desc emp2
Name Null? Type
EMPNO NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO VARCHAR2(2)
SCOTT@demo102>
Pl reply ASAP.Since this is saturday, and saturday is an unworked day in most of countries, and since this forum is based on volunteers, you cannot ask ASAP...
Nicolas. -
Dear all,
Could u plz tell me how to create rows and columns dynamically at runtime?
I got 3 columns and multiple rows.How do i go about it?
Is there ne FM to do this?Can you create an internal table dynamically? (at run time)
Yes , you can create a Dynamic Internal table .Just chek out this program .
type-pools : abap.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data,
xfc type lvc_s_fcat,
ifc type lvc_t_fcat.
selection-screen begin of block b1 with frame.
parameters: p_table(30) type c default 'T001'.
selection-screen end of block b1.
start-of-selection.
perform get_structure.
perform create_dynamic_itab. *********Creates a dyanamic internal table*********
perform get_data.
perform write_out.
form get_structure.
data : idetails type abap_compdescr_tab,
xdetails type abap_compdescr.
data : ref_table_des type ref to cl_abap_structdescr.
Get the structure of the table.
ref_table_des ?=
cl_abap_typedescr=>describe_by_name( p_table ).
idetails[] = ref_table_des->components[].
loop at idetails into xdetails.
clear xfc.
xfc-fieldname = xdetails-name .
xfc-datatype = xdetails-type_kind.
xfc-inttype = xdetails-type_kind.
xfc-intlen = xdetails-length.
xfc-decimals = xdetails-decimals.
append xfc to ifc.
endloop.
endform.
form create_dynamic_itab.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = ifc
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
endform.
form get_data.
Select Data from table.
select * into table <dyn_table>
from (p_table).
endform.
Write out data from table.
loop at <dyn_table> into <dyn_wa>.
do.
assign component sy-index
of structure <dyn_wa> to <dyn_field>.
if sy-subrc <> 0.
exit.
endif.
if sy-index = 1.
write:/ <dyn_field>.
else.
write: <dyn_field>.
endif.
enddo.
endloop.
http://www.sap-img.com/ab030.htm -
Help changing all PK and FK datatypes from uniqueidentifier to nvarchar(128)
Is there a simple script to iterate through all my tables and change my PK and FK datatypes to nvarchar(128)? I don't want to have to go through each table manually, remove relationships, and change each key one by one. Here is my db schema if it helps.
Hi Man_Cat,
According to your description, you are looking for the script to update all the PK and FK datatypes from uniqueidentifier to nvarchar(128), right?
Based on my research, we cannot change the data type of the Primary Key and Foreign Key directly as Tom said. However, we can drop the PK and FK and recreate them use the query below.
--This will drop the primary key temporarily
ALTER TABLE MyTable
drop CONSTRAINT PK_MyTable
--change data type
ALTER TABLE MyTable
ALTER COLUMN PrimaryKeyID BigInt
--add primary key
ALTER TABLE MyTable
ADD CONSTRAINT PK_MyTable PRIMARY KEY (PrimaryKeyID)
Reference
http://forums.asp.net/t/1528279.aspx?Alter+script+to+change+the+Primarykey+Column+datatype
Regards,
Charlie Liao
TechNet Community Support -
Question regarding Dashboard and column prompt
My question regarding Dashboard and column prompt:
1) Dashboard prompt usually work with only for columns which are in subject area. In my report I've created some of the columns which are based on other columns. Like I've daysNumber column that is based on two other columns, as it calculates the difference of two dates. When I create dashboard prompt I can't find this column there. I need to make a prompt on this column.
2)For one of the column I've only two values 1 and 0. When I create prompt for this column, is it possible that in drop down list It shows 'Yes' for 1 and 'No' for 0 and still filter the request??Hi Toony,...
I think there was another way of doing this...
In the dashboard prompt go to Show option > select SQL Results from dropdown.
There you need to write your Logical SQL like...
SELECT CASE WHEN 1=0 THEN PERIODS.YEAR ELSE difference of date functionality END FROM SubjectAreaName
Here.. Periods.Year is the column which is already exists in repository's presentation layer..
and difference of date functionality is the code or formula of column which you want to show in drop-down...
Also write the CASE WHEN 1=0 THEN PERIODS.YEAR ELSE difference of date functionality END code in fx of that prompt.
I think it helps you in doing this..
Just check and inform me if it works...
Thanks & Regards
Kishore Guggilla
Edited by: Kishore Guggilla on Oct 31, 2008 9:35 AM -
how can i open a PDF bank statement in "numbers" so that the rows and columns contain properly aligned data from statement?
Numbers can store pdfs pages or clippings but does not directly open pdf files. To get the bank statement into Numbers as a table I would open the bank statment in Preview (or Skim) or some pdf viewer.
Then hold the option key while selecting a column of data.
Then copy
Then switch to numbers and paste the column into a table
Then repeat for the other columns in the pdf document
It would be easier (in my opinion) to download the QFX or CSV version from your bank -
Good day,
I searched through the forum and cant find anything.
I have around 300 published reports on SSRS and we are busy migrating to a new system.
They have already setup their tables on the new system and I need to provide them with a list of table names and column names that are being used currently to generate the 300 reports on SSRS.
We use various tables and databases to generate these reports, and will take me forever to go through each query to get this info.
Is it at all possible to write a query in SQL 2008 that will give me all the table names and columns being used?
Your assistance is greatly appreciated.
I thank you.
Andre.There's no straightforward method for that I guess. There are couple of things you can use to get these details
1. query the ReportServer.dbo.Catalog table
for getting details
you may use script below for that
http://gallery.technet.microsoft.com/scriptcenter/42440a6b-c5b1-4acc-9632-d608d1c40a5c
2. Another method is to run the reports and run sql profiler trace on background to retrieve queries used.
But in some of these cases the report might be using a procedure and you will get only procedure. Then its upto you to get the other details from procedure like tables used, columns etc
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
iam not able to insert data into datagrid corresponding to the column names..as iam inserting both data and column names programatically..ie iam not able to co relate the data with the column names.plzzz help me asap
A DataGrid is row-based rather than cell-based with each row
corresponding to an item in an underlying collection (specified in the
dataProvider property). In order to add data to a DataGrid you
manipulate the underlying collection, rather than the grid directly.
Based on the limited description of your problem I would imagine you
would need to create dynamic objects with property names that correspond
to the dataFields of your dynamically created datagrid columns.
So if you had created columns with dataFields "alpha", "beta" and
"gamma" on your datagrid, you could create an item in your grid by
adding the following object to your dataProvider:
var gridItem : Object = new Object();
gridItem.alpha = "alphaValue";
gridItem.beta = "betaValue";
gridItem.gamma = "gammaValue"; -
How to get number of rows and columns in a two dimensional array ?
Hello,
What would be the simplest way to get number of rows and columns in a two dimensional array represented as integers ?
I'm looking for another solution as For...Each loop in case of large arrays.
Regards,
PetriHi Petri,
See a attached txt file for obtaining two arrays with upper and lower index values
Regards
Ray
Regards
Ray Farmer
Attachments:
Get2DArrayIndex.txt 2 KB -
How do I delete multiple rows and columns in an image?
I am looking into how digital SLRs extract video data from a CMOS sensor. To give an example, the GH1 from Panasonic can record video at 1920 x 1080 from a 12 MPixel sensor that, say, is 4000 horizontal x 3000 vertical. How they do that seems to be not in the public domain, but there have been a few guesses (see http://www.dvxuser.com/V6/showthread.php?t=206797 and http://luminous-landscape.com/forum/index.php?showtopic=38713).
One approach would be to simply read every second row of sensor pixels (1500 rows read from the original 3000) and once you have those in memory, delete every second column (2000 columns left). You would end up with a 2000 x 1500 image which could then be resampled to 1920 x 1080.
I'd like to simulate what the camera appears to be doing, by generating a 4000 x 3000 test image and then asking Photoshop CS4 to delete the appropriate rows and columns. It may not necessarily be every second row; the Canon 5DMk11 appears to read every third row, so I may need to delete two out of every three rows.
Can Photoshop do that sort of thing? If so, how?Thanks for the suggestions. Yes, I did take a detailed look at your images, but they weren't 100% convincing because it wasn't clear just what was happening. And Adobe's explanation, after reading it again, explains nothing at all to someone who doesn't know how Nearest Neighbor works.
But you are correct -- Nearest Neighbor does effectively delete pixels. I proved it with the attached 6 x 6 image of coloured pixels (the tiny midget image right after this full stop -- you'll have to go to maximum zoom in PS to see it).
These are the steps to delete every second row and then every second column.
1. Select Image > Image Size.
2. Set Pixel Dimensions > Height to half the original (in this case set to 3 pixels).
3. Set Resample Image to Nearest Neighbor.
4. Click OK and the image shoould now consist of three vertical white strips and three vertical Green-Red-Blue stripes.
5. Repeat steps 1-4, but this time set Pixel Dimensions > Width to half the original (in this case set to 3 pixels). The image should now consist of three horizontal stripes Green-Red-Blue.
Just to make sure the method worked for every third pixel, I repeated the above steps but with 2 pixels instead of 3 and obtained the correct White-Green, White-Green pattern.
I resampled the Height and Width separately for the test so that I could see what was happening. In a real example, the height and width can be changed at the same time in the one step, achieving the same results as above.
Finally, how to explain how Nearest Neighbor works in the simple cases described above?
Division by 2
In the case of an exact division by two (pixels numbered from top leftmost pixel), only the even numbered rows and columns remain. To put it a different way, every odd numbered row and column are deleted.
Division by 3
Only rows and columns 2, 5, 8, 11... remain.
Division by N
Only rows and columns 2, 2+N, 2+2N, 2+3N... remain.
To put it simply, a resample using Nearest Neighbor (using an exact integer multiple) keeps every Nth row and column, starting from number two. The rest are deleted. -
Lock rows and columns header in a table view report. It is possible?
hi,
I have a Dashboard that displays a report in "Table View" with many rows and columns.
Is it possible to set a lock on the rows and columns like Excel?
This would have blocked such headers that contain attributes and measures and to browse the report (eg with a scroll bar) had always viewed the headers.
Can you help me?
Thankshi,
please go through this discussion
Re: SCROLL BAR to FREZZ HEADERS
thanks,
saichand.v
Maybe you are looking for
-
Help with loading in the mx:html tag please
Hi everyone, I have just started working on this air application, it is for a online comic site and will be used to upload the comics. We alredy have html files for each of the sections and want to link to them, so far i have tried to do this using
-
System will not reinstall correctly
I have a Toshiba Satellite P70-A. Since day one it has always had updating crashes and problems. I have tried to reinstall from scratch several times and it still crashes during installation and giving errors. This is even after wiping the drive a
-
Using B2B as file / ftp gateway
We have a need to reach out various ftp servers and retrieve files. We can do it in BPEL directly, but i was wondering if it is possible for b2b server to go out to these ftp servers and retrieve the files on a scheduled basis ?
-
Performing redirects with a CSS
Hello, I have a CSS performing load balancing between some servers on port 443 (SSL). Since some clients try to connect to the VIP using port 80 (hhtp), Im trying to find a solution on the CSS to send a redirect to the client in order that this one
-
Apple, Thank You Very Much
Apple & Apple Support, Thank you very much for figuring out the User Login and Password issue with iCloud so quickly. Honestly, I was a bit worried, but the problem appears to be no more and I am a very happy customer. This is just another reason w