Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Insert data in rowid datatype column?

Posted on 2004-08-02
7
Medium Priority
?
1,301 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 15

Expert Comment

by:jdlambert1
ID: 11700095
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
ID: 11700812
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
ID: 11700829
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 8

Expert Comment

by:annamalai77
ID: 11700846
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
ID: 11701220
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
ID: 11703495
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 1000 total points
ID: 11706734
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In today's business world, data is more important than ever for informing marketing campaigns. Accessing and using data, however, may not come naturally to some creative marketing professionals. Here are four tips for adapting to wield data for insi…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

604 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