Insert the data in the table another table
Hi experts,I am currently using the version below:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE 11.2.0.1.0 Production
TNS for 32-bit Windows: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production
My requirement is to insert a table of data in the other table.Table 1:
create table a (a1 number);
insert into a values (1);
insert into a values (null);
insert into a values (3);
Table 2:CREATE TABLE c (b1 number not null);
Note : table c have b1 column with not null constraint
I wrote the code to insert the lines below. declare
v_a1 a.a1%TYPE;
CURSOR c1 IS SELECT a1 FROM a;
BEGIN
OPEN c1;
for i in 1..3 loop
FETCH c1 INTO v_a1;
EXIT WHEN c1%notfound;
INSERT INTO c values(v_a1);
commit;
end loop;
close c1;
end;
He insert 1 row, then after I get the error message like: 01400. 00000 - "impossible to insert a NULL value in (%s)."But I want the output as:
SELECT * FROM c;
OUTPUT :
1
3
Please give the solution to the prescription above.Thank you
I think you are looking for DML ERROR LOGGING
SQL> desc a_tab
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
COL1 NUMBER
COL2 NUMBER
COL3 NUMBER
COL4 NUMBER
SQL> desc b_tab
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
COL1 NOT NULL NUMBER
COL2 NOT NULL NUMBER
COL3 NUMBER
COL4 NUMBER
SQL> execute dbms_errlog.create_error_log('b_tab', 'b_tab_err')
PL/SQL procedure successfully completed.
SQL> desc b_tab_err
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
ORA_ERR_NUMBER$ NUMBER
ORA_ERR_MESG$ VARCHAR2(2000)
ORA_ERR_ROWID$ ROWID
ORA_ERR_OPTYP$ VARCHAR2(2)
ORA_ERR_TAG$ VARCHAR2(2000)
COL1 VARCHAR2(4000)
COL2 VARCHAR2(4000)
COL3 VARCHAR2(4000)
COL4 VARCHAR2(4000)
SQL> insert into b_tab(col1, col2, col3, col4)
2 select col1, col2, col3, col4
3 from a_tab
4 log errors into b_tab_err('my_test') reject limit unlimited;
2 rows created.
SQL> select * from b_tab;
COL1 COL2 COL3 COL4
---------- ---------- ---------- ----------
1 2 3 4
6 8 4 9
SQL> set serveroutput on
SQL>
SQL> exec dev_util.print_table('select * from b_tab_err')
-------------------------------------------------------
Field Name Field Value
-------------------------------------------------------
ORA_ERR_NUMBER$ : 1400
ORA_ERR_MESG$ : ORA-01400: cannot insert NULL into("ARBORU"."B_TAB"."COL2")
ORA_ERR_ROWID$ :
ORA_ERR_OPTYP$ : I
ORA_ERR_TAG$ : my_test
COL1 : 5
COL2 :
COL3 : 3
COL4 : 6
-------------------------------------------------------
Field Name Field Value
-------------------------------------------------------
ORA_ERR_NUMBER$ : 1
ORA_ERR_MESG$ : ORA-00001: unique constraint(ARBORU.SYS_C00658187) violated
ORA_ERR_ROWID$ :
ORA_ERR_OPTYP$ : I
ORA_ERR_TAG$ : my_test
COL1 : 1
COL2 : 9
COL3 : 9
COL4 : 0
PL/SQL procedure successfully completed.
SQL>
Tags: Database
Similar Questions
-
How to insert CLOB data in tha table in my database
I create a table called (annual NUMBER, name VARCHAR and CLOB doc) html page
IsqlPlus I have run the following procedure
P4_FIRE_HTML_TRIGGER_ARG EXEC ("OLBA + LEGAL + PSOA + OEJN", file); file: came the CLOB parameterthe result parameter is set to the queue:
< ! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 / / IN" "http://..." >
< HTML >
< HEAD >
< TITLE > ADDS - METARS results form < / TITLE >
"< LINK REL ="StyleSheet"type =" text/css"HREF="/layout/awc/mystyle.css ">
< / HEAD >
< BODY BGCOLOR = "#FFFFFF" >
< TABLE SUMMARY = "this table is used for formatting only" BORDER = 0 CELLPADDING = 3 CELLSPACING = 0 >
< TR VALIGN = "top" >
< TD ALIGN = "left" COLSPAN = "2" >
< H2 > Aviation digital data Service (ADDS) < / H2 >
Produced by form of METAR (1858 & #160;) 11 February 2014 UTC) < BR >
" located at < A HREF =" http://AV .............................
< Table >
< /TR >
< TR VALIGN = "top" >
< TD ALIGN = "left" COLSPAN = "2" >
< FONT FACE = "Monospace, Courier" > OLBA 111800Z 01006KT 7000 FEW026 16/11 Q1022 < / POLICE > < BR >
< FONT FACE = "Monospace, Courier" > LEGAL 111830Z 34005KT 8000 NSC 13/11 Q1021 NOSIG < / POLICE > < BR >
< FONT FACE = "Monospace, Courier" > PSOA 111830Z 21009KT 9999 - RA BKN016 06/03 Q1003 NOSIG < / POLICE > < BR >
< FONT FACE = "Monospace, Courier" > OEJN 111800Z 34004KT CAVOK 25/20 Q1012 NOSIG < / POLICE > < BR >
< Table >
< /TR >
< /table >
< / BODY >
< / HTML >I try inserting the above result in my HtmlPage of the table by a simple insert:
Values inserted INTO HTMLPAGE (annual, doc)
(5, 'meatr_taf', ' <!) DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 / / IN" "http://... "
... < / HTML > ') values are not inserted just I got a message:
SP2-0863: iSQL * more treatmentCan someone help me to insert CLOB data in my table HtmlPage above
Thank yousoftware:
Form [32 bit] Version 9.0.2.9.0 (Production), oracle JInitiator: Version
1.3.1.9, WebUtil Version 1.0.2 (Beta), window xp service pack 2 build 2600, Internet Explorer 8
LOOP
UTL_HTTP. READ_LINE (RESP, File_Metar, TRUE);
p2_putlines (File_Metar);
USING_CLOB. ADD_MORE (1, File_Metar);
USING_CLOB. LOB_INS (1, 'Metar_taf', File_Metar);
END LOOP;
UTL_HTTP. END_RESPONSE (resp);You should not use USING_CLOB. LOB_INS (1, 'Metar_taf', File_Metar) inside the Loop.You must use
LOOP
UTL_HTTP. READ_LINE (RESP, File_Metar, TRUE);
p2_putlines (File_Metar);
USING_CLOB. ADD_MORE (1, File_Metar);
END LOOP;
-
The most effective way to insert form data into multiple tables and w/autonum
Hi all, this is my first post here. I am new to APEX and PL/SQL. I have ColdFusion and SQL, and I'm used to perform CRUD operations in my CF Tags application files. From what I've read so far, so if this is accurate, it seems that it is more efficient to perform most of the CRUD operations on the database side, I hope that for advice on the best way to accomplish what I ask - even if I'm trying to do is better off in my new APEX application I am open to this information as well.
I have a form whose data must reside in two tables. Table A is a one-to-one relationship table and stores General information for each request. Table B is a table of one-to-many observations and should store unique records for each type of comment entered on the form, of which there are 3 comment fields on the form, I'd end up with 3 disks in table B for 1 in table A. I am generating an AutoNumber for table A with a sequence and relaxation. I want to do is take the AutoNumber I just created and use it for insertion in the Table B each insertion I have to do. This is where I am stuck.
I would like to comment on 1) where I should put all these operations and 2) how best to go about what I want to do coding. In ColdFusion, it is as simple as inserting the record in Table A, immediately asking to table A more recent recording and storing (auto) ID in a variable and then using this var for any other table insertions, I had to do. I know it must be at least a little easier in the Oracle world, I just need a nudge in the right direction. Thank you!OraclePledge,
You're pretty close to not having worked with oracle a lot.
This section is backwards:
insert into sch.tbl_main(cust_lname,cust_fname,acct_num) values(:P3_CUST_LNAME,:P3_CUST_FNAME,:P3_ACCT_NUM); select "SCH"."TBL_MAIN_SEQ".currval into v_ID from dual;
Even if it will work if you only have a single user, it's a potential bug with two or more users. First select the key (if it's first use nextval rather than currval) can use it in the insert statement.
See you soon,.
Janet TysonPublished by: Tyson Janet on June 23, 2011 10:48
-
Protect a document while allowing the insertion of data in a table and the points on a graph.
I created a Word document that contains a table and a chart. Can I protect document but allow data entry in the table and allow points appear in the table using Adobe?
Hi brianh89327665,
While you can apply a permissions password to a PDF file to prevent things such as printing and editing the document, you can not apply it selectively to parts of the PDF file.
Best,
Sara
-
How to insert the table of contents within a table
Using FrameMaker 12, I create a table of contents within a table. This means, 1st column contains the number of paragraphs, the 2nd column of the text of the paragraphs, the 3rd column the page numbers. Of course, each item must fill each cell of the table. I downloaded an example.
Thank you for your help
Nicolas
Create a table of contents in normal conditions and use tabs as separators between the page number and section number, <$paratext>.
Then use convert FM to the usefulness of the table to convert the table of contents for a table using the table design appropriate to your catalog.
It's a manual, and you will have to redo this each time that you update the table, but it should only take a few clicks to do. Automate the steps with a script would make it less painful.
$paratext> -
Hello
I have a procedure that takes xmltype as input parameter that contains data such as:
<? XML version = "1.0"? >
rowset <>
< ROW >
< > 7782 EMPNO < / EMPNO >
CLARK < ENAME > < / ENAME >
MANAGER < JOB > < / JOB >
< MGR > 7839 < / MGR >
< HIREDATE > 9 June 81 < / HIREDATE >
< SAL > 2450 < / SAL >
< DEPTNO > 10 < / DEPTNO >
< / ROW >
< ROW >
< > 7839 EMPNO < / EMPNO >
KING of < ENAME > < / ENAME >
PRESIDENT < JOB > < / JOB >
< HIREDATE > 17 November 81 < / HIREDATE >
< SAL > 5000 < / SAL >
< DEPTNO > 10 < / DEPTNO >
< / ROW >
< ROW >
< > 7934 EMPNO < / EMPNO >
MILLER < ENAME > < / ENAME >
CLERK of < JOB > < / JOB >
< MGR > 7782 < / MGR >
< HIREDATE > 23 January 82 < / HIREDATE >
< SAL > 1300 < / SAL >
< DEPTNO > 10 < / DEPTNO >
< / ROW >
< / LINES >
I analyze this data and insert into the employee table.
I remember that using the extract function we can do, but I do not get it exactly.
Can you please help me in this.
Thank you
VinodSee [url http://docs.oracle.com/cd/E14072_01/server.112/e10592/functions251.htm#CIHGGHFB] XMLTABLE
For example:
-- INSERT INTO
WITH x AS (SELECT XMLTYPE(' 7782 CLARK MANAGER 7839 09-JUN-81 2450 10 7839 KING PRESIDENT 17-NOV-81 5000 10 7934 MILLER CLERK 7782 23-JAN-82 1300 10 -
Need to insert test data in all the tables that were present in a schema
Hello
I use Oracle 9i.
10 tables were present in my current schema. All tables are not having all the records.
I need to insert test data in each table using a single procedure. (the table name is inparameter for the procedure)
For example, I test_emp, test_sal tables.
CREATE TABLE test_emp (ename varchar2 (40), number of sal);
CREATE TABLE test_sal (it NUMBER, rank NUMBER, will designate the NUMBER);
I need to insert some test data in these tables. I shouldn't use utl_file or sql * loader for this.
I tried below way.
I am not able to transmit these values to the collection dynamically to the INSERT statement. I tried many ways, but I am not satisfied with the code I've written.-- Incomplete code CREATE OR REPLACE PROCEDURE test_proc_insertdata(p_table_name IN VARCHAR2) IS BEGIN --Selected all the column_names, data_type, data_length into a collection variable from user_tab_columns. SELECT u.column_name, u.data_type, u.data_length --BULK COLLECT INTO l_col_tab FROM user_tab_columns u WHERE u.table_name = p_table_name; -- generated the values using below statement SELECT decode(u.DATA_TYPE,'VARCHAR2',dbms_random.string('A', u.data_length),'NUMBER',TRUNC(dbms_random.value(1, 5000)),'DATE',SYSDATE) val_list -- INTO collection varaible FROM user_tab_columns u WHERE TABLE_NAME = p_table_name; END;
Please help me if you know a better idea.
Thank you
SuriSuri wrote:
HelloI use Oracle 9i.
10 tables were present in my current schema. All tables are not having all the records.
I need to insert test data in each table using a single procedure. (the table name is inparameter for the procedure)
For example, I test_emp, test_sal tables.
CREATE TABLE test_emp (ename varchar2 (40), number of sal);
CREATE TABLE test_sal (it NUMBER, rank NUMBER, will designate the NUMBER);I need to insert some test data in these tables. I shouldn't use utl_file or sql * loader for this.
I tried below way.
-- Incomplete code CREATE OR REPLACE PROCEDURE test_proc_insertdata(p_table_name IN VARCHAR2) IS BEGIN --Selected all the column_names, data_type, data_length into a collection variable from user_tab_columns. SELECT u.column_name, u.data_type, u.data_length --BULK COLLECT INTO l_col_tab FROM user_tab_columns u WHERE u.table_name = p_table_name; -- generated the values using below statement SELECT decode(u.DATA_TYPE,'VARCHAR2',dbms_random.string('A', u.data_length),'NUMBER',TRUNC(dbms_random.value(1, 5000)),'DATE',SYSDATE) val_list -- INTO collection varaible FROM user_tab_columns u WHERE TABLE_NAME = p_table_name; END;
I am not able to transmit these values to the collection dynamically to the INSERT statement. I tried many ways, but I am not satisfied with the code I've written.
Please help me if you know a better idea.
Thank you
SuriWith some effort, you can write dynamic insert queries. Read the data dictionary views ALL_TABLES and ALL_TAB_COLUMNS to get the data you need. You may need to limit the list to the tables you specify to hardcode the names of the tables. You can read the views for the information of table and column that you need generate the insert column orders. It will be a lot of work and it might be easier to simply hardcode values. Dynamic SQL is difficult to debug and work with: (.) Something like this (untested and totally undebugged)
declare cursor v_tab_col(p_table_name) is select * from all_tab_columns where table_name = p_table_name; v_text varchar2(32767); v_table_name varchar2(30); begin v_table_name := 'DUAL'; --chr(10) is a newline for readability when debugging v_text := 'insert into '||v_table_name||chr(10)||'('; --loop to build column list for v_tab_rec in v_tab_col loop --add comma if not first item in list if v_tab_col%rowcount > 1 then v_text := v_text ||','; end if; v_text := v_text || v_tab_rec.column_name; end loop; v_text := v_text ||') values ('|| --loop to build column values for v_tab_rec in v_tab_cur loop if (v_tab_rec.datatype = 'VARCHAR2') then --add comma if not first item in list if v_tab_col%rowcount > 1 then v_text := v_text ||','; end if; if v_tab_rec.datatype = 'NUMBER' then v_text := v_text || '9'; elsif v_tab_rec.datatype = 'VARCHAR2' then v_text := v_text ||'X'; end if; end loop; v_text := v_text || ')'; execute immediate v_text; end;
This code is not effective, but shows how to do what you described. You'll have to code for all data types you need and find a way to take into account the primary/foreign keys, yourself. I leave it to you to find a way to avoid selecting the data twice ;)
Good luck!Published by: riedelme on July 24, 2012 13:58
-
How to load the large amount of data in 2 tables oracle ~ mill 6 lines-URGENT
Hi all
I have a file with lines of 6-8 million load us using a direct charge into a temporary table. Then we insert the missing data by research. The data in this temporary table are inserted/updated in table1.
for ex - we have:
Table1 (key1, key2, key3, key4, key5, col1, col2, col3)
Table2 (key1, key2, key3, col1, col2, col3) - the only diff between table1 and table2 is key4 and key5 (located in table 1).
First we insert/update data into temporary table table1.
Insertion: insert into table1
Select * from insert_table where (key1, key2, key3, key4, key5) IN
(select key1, key2, key3, key4, temporary_table key5
less
Select key1, key2, key3, key4, key5 from table1)
because me to (select all colulmns
of insert_table
less
Select all columns in table1)
loop
Update table1;
end loop;
Then we insert/update data into table2 from table1.
-the only difference in the insert/update is I use partiiton by making the sum of the columns non-cles and inserted the aggregated data in table2.
Insertion: insert into table2
Select key1...
sum (nonkey col) over (partition by key1, key2, key3)
FROM table1 where (key1, key2, key3) IN
(select key1, key2, key3 in table2
less
Select key1, key2, key3 in table1)
Update:
I'm in (select key1...
sum (nonkey col) over (partition by key1, key2, key3)
FROM table1 where (key1, key2, key3,) IN
(select key1, key2, key3 col1 in table2
less
Select col1, key1, key2, key3... from table1)
)
loop
Update table1;
end loop;
First we insert/update data into temporary table table1.
Insertion: insert into table1
Select * from insert_table where (key1, key2, key3, key4, key5) IN
(select key1, key2, key3, key4, temporary_table key5
less
Select key1, key2, key3, key4, key5 from table1)
because me to (select all colulmns
of insert_table
less
Select all columns in table1)
loop
Update table1;
end loop;
Data is loading properly - IF full charge. As the size of the file grows long OPS in Toad/Session browser - sorting becomes huge.
How can I improve the speed and make it better?You can consider using a single command to MERGE instead of your insert and the separate update loop if you're already on 9i.
In addition, you should consider generating statistics to a minimum on the insert_table using DBMS_STATS. GATHER_TABLE_STATS.
Kind regards
RandolfOracle related blog stuff:
http://Oracle-Randolf.blogspot.com/SQLTools ++ for Oracle (Open source Oracle GUI for Windows):
http://www.sqltools-plusplus.org:7676 /.
http://sourceforge.NET/projects/SQLT-pp/ -
Problem with the Table result variable
When you save a document structured in XML, the Table Continuation variable is translated to an entity named "fm.tcont".
Strangely, the content of the entity is a control character (0 x 11). The file is saved in XML format, but the Analyzer Returns an error,
Error message to the file d:\test\100219\doc_test.xml.1F0, line 31, char 22,: Invalid character (Unicode: 0 x 11)
Error on line 31, tank 24, Message: expected a value of literal entity or PUBLIC/SYSTEM identifier
Parse error on line 31, tank 20: not well formed (invalid token)
The abandoned analysis.The contents of the variable nothing suspicious, it's just '(continued)', where the first character is a normal space.
If someone had the same problem and knows how to fix?
It's on FM8.0p277 on Windows XP.
Thank you very much in advance,
Johannes
Johannes,
I don't have the direct response, because I've never tried. But my EDD has a TableContinuation element that is empty; ESD inserts the table continuation variable. When you export to XML, the element is there as a "marker"; It has NO content. When open in the frame, ESD inserts the variable again. My reasoning is that the table continuation variable has meaning ONLY within FrameMaker. It's a formatting object, not a content container. No post processing of the XML data would not need if so, ITS engine could provide what it is able to understand.
Anyway, here's how I deal with it.
Good luck
Van -
Lose the vertical alignment of the table during the conversion of the ditamap to book
FrameMaker Version: 12.0.4.445 (later part of TCS5)
- I have a project structured, where several XML files have been grouped in a ditamap.
- For one of the XML files, I have a table, where I need to set the cell Vertical alignment of cells in the MIDDLE.
- So using Paragraph Designer > table cell, I have change the entries in the top in the Middle (the default values have been Top).
- With the ditamap pane selected, I'll then menu file > > Save Ditamap under
- I save ditamap as ' book with fm components 12.0 (* .book) "file type.
- In the resulting book, the XML files are now. FM files.
However, at this point, when I open the. File of FM which has the table, the cell styles back to the TOP.
I searched high and low for a similar problem. It's look like a bug to me, but can someone confirm?
Thank you
No, this is not a bug by itself. I bet that the alignment is lost before you generate the book. After you set the alignment and saving and closing the file... reopen and see if the alignment is still there... I bet it's gone. As a general rule, you cannot apply put in shape or properties to objects (elements) in a DITA file. This applies to font and paragraph properties as well as table set in shape and other types of development in the form. All you can do is create items and set attributes. Any parameter properties will usually be lost on file save.
You would probably need to have a 'process of publication' (script any) you run your generated book and chapter files that would scan for an attribute that shows some properties must be set on the table. The @outputclass attribute is typically used for this kind of thing. I'm not aware of what anyone in default FrameMaker DITA, who put in place to manage this type of formatting of the tables.
If this formatting that you try to apply is consistent for the whole table, it is possible that you will be able to do this by creating a new table format that has this set of default formatting. When you insert a table in a subject, the table format is assigned to the tgroup/@outputclass attribute and this is the form that is used when rendering the table. Just create a new table in the structured application model and put in place this format to have the properties you want. Then, when you insert the table, be sure to select this format. It can be hard to set this up, but it * should * work.
However, if this does not work, or you need more refined formatting applied to the parts of the table, I produce a tool called DITA-FMx, which offers extended DITA creation and publication of the options for FrameMaker. It offers features that allow this type of table set shaped to be applied by setting the attribute @outputclass to a specific value on the line or cell. You can get more information on DITA-FMx here...
http://leximation.com/DITA-FMX/
Good luck!
Scott Prentice
Leximation, Inc..
www.leximation.com
-
Generate the table of contents with chapter markers?
It has been a while since I had to install and create a table of contents for a long document of single file, but I'm sure that I created TOCs in this way in the past. Then, why the text in the Section markers will appear in the table of contents? It is even possible to generate a table of contents that contains text of article marker?
I use InDesign CS5 in Windows. I have a file single document I'm trying to generate a table of contents for. I designed a 16-page manual in an inDesign file that includes a cover page, table of contents page and seven "chapters."
I created a separate section for each 'chapter' and used Chapter markers in the top of the page master for chapter names. It's something I did in the past of syntactically long documents containing several chapters.
I put the first page of each 'chapter' as a new Section on the Pages panel. In numbering and Section Options for each page, I checked the Section getting started, Automatic Page numbering, the Style of Page numbering: 1,2,3,4... and in Section marker: I put the name of 'chapter' in the text box.
I've set up paragraph and character Styles and has used throughout my document. When I put in place the table of contents I created everything correctly, including a heading style that I used for all the sub lines in my file and my style of Section marker for chapter names.
When I insert the table of contents, generate headers sub with their page numbers, but the titles of the chapters which are chapter markers do not generate. Am I missing something or is it still possible to enter the text of chapter markers in a table of contents? I'm sure that he's worked in the past. Can anyone offer a solution for this?
Thank you
Kat
Looks like the markers section present only in the table of contents if they are on a document page. Try manually to the substitution of the frame.
-
How to use the slider in the insertion of data in table to another
Hi all
I am beginner in oracle and I have a question to deal with my table
I have 2 table lets say (c1) and (c2).
C1 contains the following columns (product_number, product_name, description)
C2 contains the following columns (product_code, product_id, description)
I need to build anonymous blocks including cursor, this extraction of cursor data c2 to insert in c1 in the following way:
product_code = product_number,
product_id = product_name,
description = description
a help can you please...?
Thanks for all,
Best regards.
Sorry to say that this is not "talking nonsense." the statement below, you wrote, updated the TABLE whenever a row is inserted:
Update products
Set service_code = 'VOIP', Charge_type = 'FIXED', PRODUCT_TYPE = 'SERVICE', super_product = 'n',
available = 'Y', default_bill_method = 'TIPS', default_prorate = 'Y', gl_code = '00000',.
service_type = "COMPLEMENTARY", partner_code is "oman", used_service_code = "VOIP."
I can't believe that's what you intend to update an entire table every time that a row is inserted.
The second problem I see is that you try to use v_x and you aren't anything to assign to this variable. Whence 'rownum '? ROWNUM is generated when choosing and assigned to the rows in a result set. Looking at a rewrite of your code that actually works now:
SQL > declare
2
3 v_sku TMP_TABLE. Type % SKU;
v_DESCRIPTION 4 tmp_table. DESCRIPTION of % type;
5 v_MSRP TMP_TABLE. Type of MSRP %;
6 v_BILLING_FREQUENCY TMP_TABLE. Type of BILLING_FREQUENCY %;
7 v_ALLOW_PRICE_CHANGE TMP_TABLE. Type of ALLOW_PRICE_CHANGE %;
8 v_status TMP_TABLE. % OF STATUS TYPE.
v_x 9 varchar2 (20);
10
11 tmp_product of CURSOR IS
12. SELECT "p" | status of prod_id, SKU, LTrim (to_char(rowNum,'0999999')), ALLOW_PRICE_CHANGE, BILLING_FREQUENCY, advised, DESCRIPTION retail price
13 FROM tmp_table
14 where sku is not null;
15
BEGIN 16
17
18 open tmp_product;
19
loop 20
21
22 extract tmp_product in v_x, v_SKU, v_status, v_DESCRIPTION, v_MSRP, v_BILLING_FREQUENCY, v_ALLOW_PRICE_CHANGE;
23 when the output tmp_product % notfound;
24
25 INSERT INTO PRODUCTS (product_code, product_name, description, available, DEFAULT_BILL_FREQ, APPLY_SPECIAL_RATES)
26 values (v_x, v_SKU, v_DESCRIPTION, v_status, v_BILLING_FREQUENCY, v_ALLOW_PRICE_CHANGE);
27
28 END LOOP;
29 close tmp_product;
30
31 products update
32 set service_code = 'VOIP', Charge_type = 'FIXED', PRODUCT_TYPE = 'SERVICE', super_product = 'n',
33 available = 'Y', default_bill_method = 'TIPS', default_prorate = 'Y', gl_code = '00000',.
34 service_type = 'SUPPLEMENTARY', partner_code = 'oman', used_service_code is "VOIP."
35
36 commit;
END 37;
38.PL/SQL procedure successfully completed.
SQL >
SQL > select *.
2 from products
3 where rownum<>PRODUCT_CODE PRODUCT_NAME DESCRIPTION AVAILABLE SERVER PRODUCT_TYPE CHARGE_T DEFAULT_BILL S DEFAULT_BILL D GL_CO PARTNER_ USED_SER APP SERVICE_TYPE
-------------------- ---------------------------------------- -------------------------------------------------------------------------------- ------------ ------------ -------- -------- ------------ - ------------ - ----- -------------------- -------- -------- ---
p0000095 Plerkle213 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000096 Plerkle214 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000097 Plerkle215 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000098 Plerkle216 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000099 Plerkle217 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000100 Plerkle218 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000101 Plerkle219 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000102 Plerkle220 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000103 Plerkle221 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES
p0000104 Plerkle222 Plerkle Best Ever! Y QUARTERLY VOIP FIXED SERVICE N TIPS Y 00000 ADDITIONAL oman VOIP YES10 selected lines.
The update has been moved out of the loop, the useless '<>null' condition has been changed to "is not null" and v_x is generated by the cursor query itself.
David Fitzjarrell
-
Insert the ROWNUM in a column of data type of NUMBER table
Hello
I have a table that has a column named "rank" of the NUMBER data type. Basically, I want to make an analysis of top-n and insert the ROWNUM with other columns in the table.
Definition of table1:
CREATE TABLE
(
col1 VARCHAR2 (10),
Col2 NUMBER,
NUMBER of col3,
rank NUMBER
);
INSERT INTO table1
SELECT col1, col2, col3, rownum
DE)
SELECT col1, col2, col3
FROM table2
ORDER BY DESC of col3
)
WHERE rownum < = 5;
I get an error ORA-01722: invalid number. I think the mistake is virtual ROWNUM is not data type of NUMBER, so I tried to cast as CAST (ROWNUM AS NUMBER), but it does not work, same error. Can can you please shed some light on how to convert a ROWNUM number or if the issue is something else.
you're right, your example worked. It is an example of table I just created just to illustrate the problem, but my real table was always showing the same problem. Weird, isn't? However when I added the column names after that insert the question but statement I resolved. Adding code
INSERT INTO TABLE1
(col1, col2, col3, rank) - added
SELECT col1, col2, col3, rownum
DE)
SELECT col1, col2, col3
FROM table2
ORDER BY DESC of col3
)
WHERE rownum<=>=>
So that means ROWNUM returns number; and another confusion: why the inclusion of the column has solved my problem when it is not necessary for your example. in any case thank you.
-
Click the "add another line" adv table must fill in the data in tbl.
Hi all
I have a requirement of value of column in table adavance automatically filling in read-only mode when the user clicks on the add another button in the row.
Initially when the page loads there is no data and therefore no line in the table in advance. And advanced table will have the "add another line." When the user clicks this button, the first column of the table advance must complete with so-called values a contant '1'.
Can someone please provide a code example in how to achieve this?
Thank you
SunnyHi Sunny,
Please use the controls below before creating and inserting the line so this new line will be created at the end.
custVO1.last ();
custVO1.next ();Thank you
Agnes. -
Hi all
I use forms [32 bit] Version 6.0.8.24.1 (Production)
Oracle Database 10g Release 10.2.0.1.0 - Production
I have settings such as the (optional) emp_code and the year (mandatory field - four digits).
Based on the setting that I have to get the detail of a table and these must be inserted at the other table with columns of additions (to hardcode the additional columns).
To achieve this, I intend to get a cursor by selecting the required fields in the table by the way the where clause of the cursor parameters.
by making a loop through the cursor I will insert the records in the other table.
Here, the thing is that the data is going to be huge (since the year is the parameter).
so my approach causes the performance issue.
I heard that there is a different method of insetions
can anyone suggest me the best way (performance wise) other than what I mentioned (if you are aware of)...
Thank you...user13329002 wrote:
Thanks for everyone.
I have to take the data from the table as e_name, e_code, of the table and insert it into another table with some other values such as
e_name, e_code, as well as I add 'n', 'o'.
its something likeinsert into e_emp(emp_name,emp_code,emp_add,emp_status,emp_type) select e_name,e_code,e_add,'O','N') from e_table where e_date = Parameter.
in other words, the values for Emp_status, emp_type I have no values in the e_table.so table and enter in e_table I have to hard code it.
CAL I hard code as I mentioned in my statement examplecan someone clear me of the foregoing.
Thank you...
Published by: user13329002 on February 15, 2011 20:11
Yes... You can hardcode the values for Emp_status, emp_type.
SQL> CREATE TABLE e_emp(emp_code NUMBER(10),emp_status VARCHAR2(1),emp_type VARCHAR2(1)); Table created. SQL> create table e_table as (select * from e_emp); Table created. SQL> INSERT INTO e_table(emp_code) VALUES('1111'); 1 row created. SQL> insert into e_table(emp_code) values('2222'); 1 row created. SQL> select * from e_table; EMP_CODE E E ---------- - - 1111 2222 SQL> insert into e_emp(emp_code,emp_status,emp_type) (select emp_code,'0','N' from e_table); 2 rows created. SQL> select * from e_emp; EMP_CODE E E ---------- - - 1111 0 N 2222 0 N SQL>
I hope this helps.
Kind regards
Claudy
Maybe you are looking for
-
NEITHER 9233 Microphone conditioning of signals
Following an update of LabVIEW 2009 Pre - polarised FAT microphones work correctly with 9233 modules OR multifunction data acquisition. (They have been used regularly since 2007). There is an important distortion of the signal calibrated showing the
-
Maybe I need to change the size of windows of the vi like the screenshot. Then click on the black arrow pointing to the right, increase the size of the entire window, IE. the right edge will move Zoom window, another chart is displayed. When click on
-
Windows update error 800 has 0046
I have a client who got the E-Set antivirus 2011. I could remove and get IE, Chrome and firefox work again, but when I run windows update I get error 800 a 0046 continuously. I made that says the message and all the rest I can't online with no luck
-
Hello I tried to update my windows service, but the BITS can not start (error 80246008). I tried to solve it using the suggested steps, however, got an error 1079 (account specified for this service is different from the account specified for other s
-
Hello. I can not print on media of any of my Macs (normally print on media roll which still works fine) I can get the paper loaded in the printer without problem and it ends and knows that it is a sheet loaded and not a roll. But when I print from an