Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1321
  • Last Modified:

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

0
mohammadzahid
Asked:
mohammadzahid
  • 2
  • 2
  • 2
  • +1
1 Solution
 
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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now