0

i want to insert values to oracle Object type by selecting values from other table

And the tables and insert statement looks like this.

CREATE TYPE Test_obj AS OBJECT (
  attr1           VARCHAR2(20),
  attr2 VARCHAR2(20),
  attr3 VARCHAR2(25)  );
/

CREATE TABLE resultrow_obj (
  resultrow         Test_obj ,
  RESULTTABLEID    NUMBER(20,0),
  ROWNUMBER NUMBER(20,0) );
  /

  INSERT INTO resultrow_obj VALUES (
  Test_obj (select col1,col2,col3 from Table2 where rownum<=1), 
 1,123 );
 /
1
  • 1
    So what's your actual question? Commented Feb 7, 2013 at 9:06

1 Answer 1

1

You've got it nearly right:

SQL> INSERT INTO resultrow_obj
  2  VALUES((SELECT Test_obj('A', 'B', 'C') 
  3            FROM dual WHERE rownum <= 1), 
  4         1, 123);

1 row inserted
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.