Solved

Insert data in rowid datatype column?

Posted on 2004-08-02
7
1,200 Views
Last Modified: 2012-05-05

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

0
Comment
Question by:mohammadzahid
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 15

Expert Comment

by:jdlambert1
Comment Utility
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
 
LVL 8

Expert Comment

by:annamalai77
Comment Utility
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
 
LVL 11

Author Comment

by:mohammadzahid
Comment Utility
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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 8

Expert Comment

by:annamalai77
Comment Utility
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
 
LVL 11

Author Comment

by:mohammadzahid
Comment Utility
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
 
LVL 6

Expert Comment

by:hans_vd
Comment Utility
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
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 250 total points
Comment Utility
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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now