Insert data in rowid datatype column?


How can I insert data in an index organized table that has 2 columns of number and rowid datatypes.

Here is the ddl:

CREATE TABLE "CSS"."TESTTABLE"
("DOCID" NUMBER(38),
 "TEXTKEY" ROWID NOT NULL,
    CONSTRAINT "SYS_IOT_TOP_32819" PRIMARY KEY("TEXTKEY"))  
    ORGANIZATION
    INDEX  
    TABLESPACE "SHRD" PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE ( INITIAL 128K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0)
    LOGGING

LVL 11
mohammadzahidAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jdlambert1Commented:
If you're using Oracle, you can't insert into a rowid, that done automatically by Oracle. If you're not using Oracle, please tell us what you are using.

From "Oracle PL/SQL Programming":

In the Oracle RDBMS, ROWID is a pseudocolumn that is a part of every table you create. The rowid is an internally generated and maintained binary value which identifies a row of data in your table. It is called a pseudocolumn because a SQL statement includes it in places where you would normally use a column. However, it is not a column that you create for the table. Instead, the RDBMS generates the rowid for each row as it is inserted into the database. The information in the rowid provides the exact physical location of the row in the database. You cannot change the value of a rowid.

You can use the ROWID datatype to store rowids from the database in your pl/sql program. You can SELECT or FETCH the rowid for a row into a ROWID variable.
0
annamalai77Commented:
hi there

what our friend has said earlier is correct. u cannot do anything like update or insert into a rowid column in oracle since it is being maintained internally by oracle,which is unique for everyrow in a table. but if the field is just a userdefined one then u can use the decault insert command to insert values into the table.

regards
annamalai
0
mohammadzahidAuthor Commented:
I know that rowid are maintained by Oracle internally and are exclusive to each row.

Can you please paste the exact command showing how to insert values into the table that has user defined rowid datatype.

Thanks.

0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

annamalai77Commented:
hi

what do u mean by user defined rowid datatype

insert into css values(1,'aabb36156');

commit;

do u have any logic to generate the rowid by urserlf.

regards
annamalai
0
mohammadzahidAuthor Commented:
I meant was if I create a table and use rowid as datatype. Please see DDL of the table at the start of this thread.

I don't have a logic to generate the rowid myself.
All, I need to do is figer out a method to populate a table to test my database application against an index organized table that gets called from a C program that reads storage parametes of IOT.

The insert statement you pasted in your last response is not valid.


0
hans_vdCommented:
insert into css
values(1,'AAAABB22FFFFCCCC');

But I really can't think of a reason to do this.  You probably need something like this:

insert into css
select 1, rowid from some_table
where rownum < 2;
0
jdlambert1Commented:
Create your table without specifying a rowid column. Oracle will take care of it automatically. You can't create it, and you can't insert into it, and you can't make it a primary key.

You can use it, by selecting that column, assigning it to a variable, using logic in a stored procedure, whatever.

CREATE TABLE "CSS"."TESTTABLE"
("DOCID" NUMBER(38),
    CONSTRAINT "SYS_IOT_TOP_32819" PRIMARY KEY("DOCID"))  
    ORGANIZATION
    INDEX  
    TABLESPACE "SHRD" PCTFREE 10 INITRANS 2 MAXTRANS 255
    STORAGE ( INITIAL 128K NEXT 0K MINEXTENTS 1 MAXEXTENTS
    2147483645 PCTINCREASE 0)
    LOGGING

When you insert into an Oracle table, ignore the fact that there is a hidden rowid column.
INSERT CSS.TestTable(DocID) VALUES(1)

SELECT rowid, docid FROM CSS.TestTable
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.