473,386 Members | 1,830 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

%ROWTYPE Insert

2
Hi...

I've 2 tables lang & lang_desc. lang_desc has an additional description field. Can I insert into lang_desc table a row selecting it from lang table using %ROWTYPE without implicitly assign the fields? The below code works but it is assigning the fields...
************************************************** *********************
CREATE TABLE LANG
(
ID VARCHAR2(9),
LANGUAGE_CODE VARCHAR2(5)
);


CREATE TABLE LANG_DESC
(
ID VARCHAR2(9),
LANGUAGE_CODE VARCHAR2(5),
DESCRIPTION VARCHAR2(30)
);
************************************************** *****************

DECLARE
r_lang lang%ROWTYPE;
r_lang_desc lang_desc%ROWTYPE;


BEGIN

SELECT * INTO r_lang FROM lang where iD = '15649';

r_lang_desc.id := r_lang.id;
r_lang_desc.language_code := r_lang.language_code;

INSERT INTO lang_desc
VALUES r_lang_desc;
COMMIT;

END;
Sep 28 '07 #1
2 6612
Saii
145 Expert 100+
You can use insert with select syntax. Will that fulfill your requirement?
Sep 28 '07 #2
qnrt
2
INSERT INTO lang_desc (id, language_code)
(SELECT * FROM lang where iD = '15649') ;
COMMIT;

Yeah this will work.. But my actual scenario is 2 tables with more than 40 fields.. Any other solutions??
Sep 28 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sri | last post by:
how to handle a situation where i wnt a variable of type ref cursor. TYPE refCur IS REF CURSOR; rc refCur; myRow rc%rowtype; -- How can I make this work??? The whole problem is that only on...
0
by: Uwe C. Schroeder | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 I guess I'm not the first asking this, however googling gave no results. Is it possible to insert a row based on a rowtype variable ? Thx UC
1
by: Rajesh Kumar Mallah | last post by:
Hi, profile_row profile_master%ROWTYPE; in a plpgsql function gives the error below tradein_clients=# SELECT general.create_accounts(); WARNING: plpgsql: ERROR during compile of...
4
by: ezra epstein | last post by:
Aother head banger for me. Below is a complete example of the code Using Postgres 7.4, the function "test" gets this: psql:temp3.sql:10: ERROR: syntax error at or near "%" at character 135...
0
by: Federico Pedemonte | last post by:
Hi all, Imagine I have a PL/pgSQL function called myfunction that returns a rowtype like this CREATE TYPE mytype AS (a integer, b integer, c integer); Imagine that I often need only 1...
3
by: Iker Arizmendi | last post by:
How are function parameters of rowtype specified when calling them from a client such as libpq? Is there a syntax similar to that for arrays? (eg, {x, y, z} ) Thanks, Iker ...
14
by: Karl O. Pinc | last post by:
Hi, Thought perhaps some other eyes than mine can tell if I'm doing something wrong here or if there's a bug somewhere. I've never passed a ROWTYPE varaible to a function but I don't see where...
0
by: Carlos Roberto Chamorro Mostacilla | last post by:
I have a function that receives a Record or a Rowtype, I need to construct a record of a SQL, to modify a field of the record and soon to pass it to the function but when calling the function is...
2
by: dilippanda | last post by:
Hi Experts, I want to display all the elements of a %ROWTYPE type.How can i achieve that. I have written one sample code. DECLARE TYPE dept_info IS record dept%ROWTYPE; ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.