Insert statement required
Hi masters,
I have a package with one procedure. I need to write an insert statement in that procedure. Please help me in this regard
Package spc
create or replace
PACKAGE PKG_RAC_SEG_DATA AS
TYPE tr_seg_summary IS RECORD
seg_id number,
seg_nm varchar2(500),
seg_desc varchar2(500),
src_sys varchar2(20),
rec_comp varchar2(20),
REC_SYS VARCHAR2(20),
EFFCT_ST_DT DATE,
EFFCT_END_DT DATE,
az_prod_id number,
src_prod_id varchar2(20),
prod_src_sys varchar2(20),
AZ_PROD_NAME VARCHAR2(50),
PRCS_ID NUMBER,
ins_prcs_run_id number,
ins_init_methd varchar2(20),
INS_DT DATE
type tt_seg_summary is table of tr_seg_summary; --table type
procedure prc_ins_seg_summary(p_seg_summary in tt_seg_summary,p_proc_id out varchar2);
END PKG_RAC_SEG_DATA;Package body
create or replace package body PKG_RAC_SEG_DATA
is
procedure prc_ins_seg_summary(p_seg_summary in tt_seg_summary,
p_proc_id out varchar2)
is
begin
p_proc_id := 'SUCCESS';
Need to write an insert statement here ......!!!
end prc_ins_seg_summary;
end PKG_RAC_SEG_DATA;table structure -- SEG_SUMM_STG (TABLE NAME)
Seg_id Number,
seg_nm varchar2(500 bytes),
seg_desc varchar2(500 bytes),
src_sys varchar2(20 byte),
rec_comp varchar2(20 byte),
rec_sys varchar2(20 byte),
effect_st_dt date,
effct_end_dt date,
az_prod_id number,
src_prod_name varchar2(50 byte),
procs_id number,
ins_prcs_run_id number,
ins_init_methd varchar2(20 byte),
ins_dt datePseudo code
IF count of parameter_seg_summary > 0 then //check the count syntax
For variable_iterator IN parameter_seg_summary //check the syntax to iterate from first to last record.
Loop
Initiate Seg_summary_record; // just to initiate.. it is mandatory..you cannot assign records without initiating
Seg_summary_record = parameter_seg_summary (variable_iterator); //assign seg_summary_record with first record
Begin
Insert into table name( column names..) values (seg_summary_record. seg_id , seg_summary_record. seg_desc..);
end
End Loop
End ifPlease help me
Regards
SA
Hi EdStevens,
Sorry ... I was in tension, need to complete this task with in 1 hour.
Karthik has given some solution, but he forgotten if statement in my pseudo code. if you have any idea help me.
create or replace package body PKG_RAC_SEG_DATA
is
procedure prc_ins_seg_summary
p_seg_summary in tt_seg_summary,
p_proc_id out varchar2
is
begin
p_proc_id := 'SUCCESS';
for i in 1..p_seg_summary.count
loop
Insert into table_name
column names..
values
p_seg_summary(i).seg_id ,
p_seg_summary(i).seg_desc..
end loop;
end prc_ins_seg_summary;
end PKG_RAC_SEG_DATA;pseudo code
IF count of parameter_seg_summary > 0 then //check the count syntax
For variable_iterator IN parameter_seg_summary //check the syntax to iterate from first to last record.
Loop
Initiate Seg_summary_record; // just to initiate.. it is mandatory..you cannot assign records without initiating
Seg_summary_record = parameter_seg_summary (variable_iterator); //assign seg_summary_record with first record
Begin
Insert into table name( column names..) values (seg_summary_record. seg_id , seg_summary_record. seg_desc..);
end
End Loop
End ifPlease help me....!!
regards
SA
Similar Messages
-
Insert statement will not work if select statement has less number of colum
Hi,
One of my thread is already resolved on the following URL : unable to insert rows into the table
DROP TABLE TEMP;
CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
DECLARE
S VARCHAR2(200);
STMT VARCHAR2(500);
begin
for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
STMT := 'INSERT INTO TEMP SELECT * FROM ';
STMT:=STMT || C.TABLE_NAME;
EXECUTE IMMEDIATE STMT;
dbms_output.put_line(c.table_name);
end loop;
end;
i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
Please let me know , how can i execute proper way.
Thanks.
Best Regards
Arshaduser13360241 wrote:
Hi,
One of my thread is already resolved on the following URL : unable to insert rows into the table
DROP TABLE TEMP;
CREATE TABLE TEMP AS SELECT * FROM CASE_101 WHERE 1=2;
DECLARE
S VARCHAR2(200);
STMT VARCHAR2(500);
begin
for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CASE%' TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
STMT := 'INSERT INTO TEMP SELECT * FROM ';
STMT:=STMT || C.TABLE_NAME;
EXECUTE IMMEDIATE STMT;
dbms_output.put_line(c.table_name);
end loop;
end;
i am facing now some different; almost all the tables have same number of columns except in few of tables have some additional columns. As above i am creating a table "TEMP" who has highest column temp(by doing some manual process). The table who has less columns than "TEMP" table : Insert statement will not work. 'INSERT INTO TEMP SELECT * FROM less_columns_table_name'.
Please let me know , how can i execute proper way.
Thanks.
Best Regards
Arshadmore often than not "TEMP" tables are NOT required & are highly inefficient in Oracle.
Either only specify explicit column in TEMP to get data,
or provide value for "extra" column in TEMP -
INSERT statement in Java and MS Access
Hi all,
can anyone please tell me how to insert data to an MS Access table using JSP i tried INSERT statement of java but it is getting errors saying INSERT statement is wrong. I have no idea about MS access insert statement. i am totally tired of this. Please someone help me.Hello,
MS Sql can cause problems where it goes off standard, however I dont think insert is any different.
INSERT INTO table_name (column1, column2) VALUES (variable1, variable2)
Make sure your table and column names are exactly right, Java is case sensitive, so make sure the case is correct also.
The other common error is if you have a required field in the database that is not populated by your program, so, if for instance there was a column3 in the table for the above example, which was a required field, the sql would fail as there is no data being entered for column3. -
Hi all
I had problem in insert statement.
I know the column of the table, tablename and the value to be insert.
My code:
Data: column(20) type c. -
>refer to the tablecolumn
Data: tablename(20) type c. -
>refer to table name
Data: value(20) type c. -
>value to be insert to the column in the table
column = 'Admino'.
tablename = 'Student'.
value = '123456'.
<b>insert <column> into <tablename> values <value>.</b>
i know there something wrong with my insert statement. How to do it in abap insert code where i can put in all the parameter in the insert statement.
Anycode or sample to show. Many thank.From f1 help....
EXTRACT
Basic form
EXTRACT fg.
Effect
Writes all fields of the field group fg (FIELD-GROUPS) as an entry in asequential dataset. If you have defined a field group HEADER,its fields precede each entry as a sort key. Afterwards, you canuse SORT and LOOP ... ENDLOOP to sort or process the datasetrespectively. No further EXTRACT statements are possible afterthis.
Notes
General:
As soon as you have extracted a dataset using EXTRACT, you canno longer extend the field group using INSERT. In particular, you cannot change the HEADERfield group at all after the first EXTRACT (regardless of thefield group to which it applied).
Large extract datasets are not stored in main memory. Instead, theyare kept in an external auxiliary file. You can set the directory inwhich this file is created using the SAP profile parameterDIR_EXTRACT. The default directory is the SAP data directory(SAP profile parameter DIR_DATA).
Notes
Runtime errors:
EXTRACT_AFTER_SORT/LOOP: EXTRACT after SORT, orLOOP. EXTRACT_BUFFER_NO_ROLL: Unable to create the required main
EXTRACT_FIELD_TOO_LARGE: Occupied length of a field is toolarge.
EXTRACT_HEADER_NOT_UNIQUE: Field group HEADER wasmodified after an EXTRACT statement.
EXTRACT_OPEN_EXTRACTFILE_OPEN:
Error opening the external extract dataset file.
EXTRACT_RESOURCEHANDLER_FAILED: Error deleting the externalextract dataset file.
EXTRACT_TOO_LARGE: Total length of the entry for extraction(including HEADER fields) is too large.
Additional help
Filling anExtract with Data
Extracts
Since internal tables have fixed line structures, they are not suited to handle data sets with varying structures. Instead, you can use extract datasets for this purpose.
An extract is a sequential dataset in the memory area of the program. You can only address the entries in the dataset within a special loop. The index or key access permitted with internal tables is not allowed. You may only create one extract in any ABAP program. The size of an extract dataset is, in principle, unlimited. Extracts larger than 500KB are stored in operating system files. The practical size of an extract is up to 2GB, as long as there is enough space in the filesystem.
An extract dataset consists of a sequence of records of a pre-defined structure. However, the structure need not be identical for all records. In one extract dataset, you can store records of different length and structure one after the other. You need not create an individual dataset for each different structure you want to store. This fact reduces the maintenance effort considerably.
In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required. In addition, you need not specify the structure of an extract dataset at the beginning of the program, but you can determine it dynamically during the flow of the program.
You can use control level processing with extracts just as you can with internal tables. The internal administration for extract datasets is optimized so that it is quicker to use an extract for control level processing than an internal table.
Procedure for creating an extract:
Define the record types that you want to use in your extract by declaring them as field groups. The structure is defined by including fields in each field group.
Defining an Extract
Fill the extract line by line by extracting the required data.
Filling an Extract with Data
Once you have filled the extract, you can sort it and process it in a loop. At this stage, you can no longer change the contents of the extract.
Processing Extracts
INSERT Statement
The INSERT statement is used to insert values into a single database table.
<insert statement> ::= INSERT INTO <table name> <insert column list> <insert source>.
<insert source> ::= VALUES '(' <value> ( ',' <value> )* ')'
| <query specification>.
<value> ::= <value expression>
| <dynamic parameter specification>
| NULL.
<insert column list> ::= '(' <column name> ( ',' <column name> )* ')'.
In Open SQL the <insert column list> is not optional.
You cannot specify string literals as values for CLOB columns. Hex literals are not supported in Open SQL.
Examples
INSERT INTO employees (employee_id, employee_name)
VALUES (4711, 'John Smith')
Inserting Values. A new row is inserted into the table employees with the values 4711 and 'John Smith' for the columns employee_id and employee_name respectively.
INSERT INTO well_paid_employees (employee_id, salary)
SELECT employee_id, salary
FROM employees
WHERE salary > ?
Inserting the Result of a Query. The employee_idand the salaryof all employees from table employeeswith a salary exceeding a certain value are inserted into the table well_paid_employees.
Please reward points if helpful. -
Record Group In Insert Statement
Hi All,
I am using Oracle 9i Ver 2 & Developer 6i on Windows platform. I want to ask, can we pass a Form's Record Group object to a select statement as a whole. I mean something like this,
Suppose emp_rg is a Forms RecordGroup which has all the columns of scott.emp table & it contains 10 rows. So, can I write like this:
INSERT INTO emp VALUES(emp_rg);
Or anything like this, if this is wrong.
Or, I need to create a PL/SQL record object & then I can pass. Pls clarify.
Thanks in Advance,
Inderjeet SinghYes I often have trouble deciding whether to use a record group or a pl/sql table. They both have their own advantages in different situations. Manipulating record groups programatically requires rather more cumbersome syntax, but they do come with some handy built-ins (such as populate_group), and they also integrate with LOVs, Trees etc.
If you want the pl/sql table to be available throughout the form you will need to declare it in a package spec.
Even with a pl/sql table, you will need to write code to feed it into your insert statement. I reckon a global temporary table might allow the most straightforward syntax. -
Hi all,
I have a Insert statement as follows.
insert into mytable(description)
values('Spoon 'n Fork');
In order to have the single quote before the n, I can frame the sentence as follows,
insert into mytable(description)
values('Spoon ''n Fork');
But if the same comes in a sql script there many rows will have single quote as 'n.
How can I fix this?
any ideas
thanks
aspHi,
sorry..i actually misunderstood the requirement... its like follows..
I have a flat file coming generated from system with column values:
Description1 Description2 Description3 Description4 Description5
prasanth baby'sdayout prime minister dad's book my work
world's clock president computer printer's laptop
alphabets party's spoon 'n foke icecream's etcThe above flat file is dynamic which
will have some times 100 rows sometimes 1000 rows.
I should write a insert build procure that should work such a way that
it should check all columns values in each to find ' (single quote) and if present then it should build insert statement accordingly.. i.e incude '' so that single quote will be inserted.
Here the tricky thing is that in 1st row '(single quote) present in 2nd column (baby'sdayout) and 3rd column 4th(dad'sbook) so my prgoram should build insert statement like
insert into mytable(description1,description2,description3,description4,description5)
values('prasanth','baby''sdayout','prime minister','dad''sbook','my work');
So here tricky is i really dont know which column value has ' (quote) with in it and i should find out build insert accordingly..
if you see second row above then '(quote) came in Description1 and Description 4 so, insert statement should only place that '' in those column alone..
any ideas how to achieve this
thanks
asp
Edited by: Onenessboy on Aug 1, 2011 8:03 AM -
Want to construct insert statement from all_tab_columns
I am using Oracle 10GR2 and a new user for plsql
I want to write a plsql block or SQL in order to insert some dummy data.
I want to use the column list from all_tab_columns and want to construct insert statement
EX: I am trying to construct SQL as below
for i in (select column_name from all_tab_columns where table_name='EMP')
loop
v_sql := insert into emptest valuesi.column_name
could you please let me know any pointer for the same ..?
can I use any other technique for the same .. like collection, nested table etcAm not clear for this requirement, if possible could you please elaborate.
Also specify the requirement, inputs and expected outputs with your query in code format...
This will help.. -
How to convert XML content into SQL INSERT statements
Hi all,
I'm very new to XML. Forgive me if I don't use technical XML terms. :-)
We are planning to convert SQL queries into XML format using a third party tool.
After that we have to read the XML files and use the tokens to insert into custom tables.
So, basically we have to create INSERT statements using the data stored in the XML file.
How do we go about reading / parsing the XML file in Java?
Pls help!
Regards,
SamThis is the requirement with an example.
eg. if the following SQL query is fed into the 3rd party system,
select last_name,job_id,salary from employees a, deptno b
where a.deptno = b.deptno
the output would be,
<?xml version="1.0" ?>
<sqlscript dbvendor="MSSQL">
<fullselectstmt nestlevel="0">
<subselectstmt><selectclause><fieldlist>
<field><fieldname>
<attr>
<sourcetoken toketype="" dbobjtype="field">last_name</sourcetoken>
</attr>
</fieldname>
</field>
<field><fieldname>
<attr>
<sourcetoken toketype="" dbobjtype="field">job_id</sourcetoken>
</attr>
</fieldname>
</field>
<field><fieldname>
<attr>
<sourcetoken toketype="" dbobjtype="field">salary</sourcetoken>
</attr>
</fieldname>
</field>
</fieldlist></selectclause>
<fromclause><joinlist><join nestlevel="0">
<lztable><simpletable><attr>
<sourcetoken toketype="" dbobjtype="table">employees</sourcetoken>
</attr><aliasclause withas="false"><sourcetoken toketype="" dbobjtype="table alias">a</sourcetoken></aliasclause></simpletable></lztable></join><join nestlevel="0">
<lztable><simpletable><attr>
<sourcetoken toketype="" dbobjtype="table">deptno</sourcetoken>
</attr><aliasclause withas="false"><sourcetoken toketype="" dbobjtype="table alias">b</sourcetoken></aliasclause></simpletable></lztable></join></joinlist></fromclause>
<whereclause><expression exprtype="Expr_Comparison" exproop="="><attr>
<sourcetoken toketype="" dbobjtype="table alias">a</sourcetoken>
<sourcetoken toketype="" dbobjtype="unknown">.</sourcetoken>
<sourcetoken toketype="" dbobjtype="field">deptno</sourcetoken>
</attr><attr>
<sourcetoken toketype="" dbobjtype="table alias">b</sourcetoken>
<sourcetoken toketype="" dbobjtype="unknown">.</sourcetoken>
<sourcetoken toketype="" dbobjtype="field">deptno</sourcetoken>
</attr></expression>
</whereclause></subselectstmt></fullselectstmt>
</sqlscript>
So, using the output file, the list of columns (under token "field") last_name,job_id and salary should be inserted into LIST_COLUMNS table. So 3 INSERT statements should be created for 3 columns.
The list of tables (under token "table") employees and dept should be inserted into LIST_TABLES table. So 2 INSERT statements should be created for the 2 tables.
Regards,
Sam -
Handle the Insert statement my self.
Hi
I am looking to handle the insert statement myself via a page process. The user is only required to populate 3 fields, and I want to insert the others with clock numbers and sysdate. In forms I would have block_name.field_name is there something similar in APEX.
Insert into institution
(ID ,
CLOCK_NO ,
INSTITUTION ,
MEMBERSHIP_NO ,
MENTOR,
USER_NAME ,
UPDATE_DATE )
values
(institution_seq.next_val,
:p_clock_no,
institution,
membership_no,
mentor,
:p_clock_no,
sysdate);
Thanks
FionaFiona,
Do you mean you want to pickup values from page items, which have been populated by the User? If so you reference the page items with :PX_PAGE_ITEM_NAME
Cheers,
Mike -
Insert Statement - Turning off logging
We have processes that loads data from a linked server via an insert statement. There is really no need to log the data loads. Is there away to turn off the logging via T-SQL?
TIA,
ToddChange the database recovery model to Bulk Logged.
http://msdn.microsoft.com/en-us/library/ms189275(v=sql.105).aspx
Bulk logged
Requires log backups.
An adjunct of the full recovery model that permits high-performance bulk copy operations.
Reduces log space usage by using minimal logging for most bulk operations. For more information, see Operations
That Can Be Minimally Logged.
If the log is damaged or bulk-logged operations occurred since the most recent log backup, changes since that last backup must be redone.
Otherwise, no work is lost.
Can recover to the end of any backup. Point-in-time recovery is not supported.
Best Wishes, Arbi; Please vote if you find this posting was helpful or Mark it as answered. -
Hi,
RDBMS : 102 Standard Edition
I have to compute load (CPU,DISK, memory etc) of my insert statements . What is the best practice to achieve it?
I have to computer select statement too, currently I am using explain plan to analyze select query performance. Is there any other best option ?I have verified that all required pre-requisite are meet for sql tracing. After that I have issued following command as sys
ALTER SYSTEM SET SQL_TRACE = TRUE;
ALTER SESSION SET TRACEFILE_IDENTIFIER = 'identifier';
ALTER System SET EVENTS '10046 trace name context forever, level 8';
Then login as non-sys account and processed some sql.
select * from table;
Then again as sys, I issued
ALTER SYSTEM SET EVENTS '10046 trace name context off';
ALTER system SET SQL_TRACE = false;
No I used tkproof to view results
TKPROF D:\oracle\product\10.2.0\admin\orcl\udump\orcl_ora_2736_trace_benchmark.trc D:\oracle\product\10.2.0\admin\orcl\udump\trace_benchmark.PRF EXPLAIN=user/pwd
I have viewed the generated file, but there is no trace for the non-sys user command.
Can you please tell me where I am missing something? -
Extract statement and insert statement
can anyone explain me the use of this insert statement and extract statement.
INSERT lfa1-name1 INTO fg01
extract fg01.
thanks
phyroseHi,
From f1 help....
EXTRACT
Basic form
EXTRACT fg.
Effect
Writes all fields of the field group fg (FIELD-GROUPS) as an entry in asequential dataset. If you have defined a field group HEADER,its fields precede each entry as a sort key. Afterwards, you canuse SORT and LOOP ... ENDLOOP to sort or process the datasetrespectively. No further EXTRACT statements are possible afterthis.
Notes
General:
As soon as you have extracted a dataset using EXTRACT, you canno longer extend the field group using INSERT. In particular, you cannot change the HEADERfield group at all after the first EXTRACT (regardless of thefield group to which it applied).
Large extract datasets are not stored in main memory. Instead, theyare kept in an external auxiliary file. You can set the directory inwhich this file is created using the SAP profile parameterDIR_EXTRACT. The default directory is the SAP data directory(SAP profile parameter DIR_DATA).
Notes
Runtime errors:
EXTRACT_AFTER_SORT/LOOP: EXTRACT after SORT, orLOOP. EXTRACT_BUFFER_NO_ROLL: Unable to create the required main
EXTRACT_FIELD_TOO_LARGE: Occupied length of a field is toolarge.
EXTRACT_HEADER_NOT_UNIQUE: Field group HEADER wasmodified after an EXTRACT statement.
EXTRACT_OPEN_EXTRACTFILE_OPEN:
Error opening the external extract dataset file.
EXTRACT_RESOURCEHANDLER_FAILED: Error deleting the externalextract dataset file.
EXTRACT_TOO_LARGE: Total length of the entry for extraction(including HEADER fields) is too large.
Additional help
Filling anExtract with Data
Extracts
Since internal tables have fixed line structures, they are not suited to handle data sets with varying structures. Instead, you can use extract datasets for this purpose.
An extract is a sequential dataset in the memory area of the program. You can only address the entries in the dataset within a special loop. The index or key access permitted with internal tables is not allowed. You may only create one extract in any ABAP program. The size of an extract dataset is, in principle, unlimited. Extracts larger than 500KB are stored in operating system files. The practical size of an extract is up to 2GB, as long as there is enough space in the filesystem.
An extract dataset consists of a sequence of records of a pre-defined structure. However, the structure need not be identical for all records. In one extract dataset, you can store records of different length and structure one after the other. You need not create an individual dataset for each different structure you want to store. This fact reduces the maintenance effort considerably.
In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required. In addition, you need not specify the structure of an extract dataset at the beginning of the program, but you can determine it dynamically during the flow of the program.
You can use control level processing with extracts just as you can with internal tables. The internal administration for extract datasets is optimized so that it is quicker to use an extract for control level processing than an internal table.
Procedure for creating an extract:
Define the record types that you want to use in your extract by declaring them as field groups. The structure is defined by including fields in each field group.
Defining an Extract
Fill the extract line by line by extracting the required data.
Filling an Extract with Data
Once you have filled the extract, you can sort it and process it in a loop. At this stage, you can no longer change the contents of the extract.
Processing Extracts
INSERT Statement
The INSERT statement is used to insert values into a single database table.
<insert statement> ::= INSERT INTO <table name> <insert column list> <insert source>.
<insert source> ::= VALUES '(' <value> ( ',' <value> )* ')'
| <query specification>.
<value> ::= <value expression>
| <dynamic parameter specification>
| NULL.
<insert column list> ::= '(' <column name> ( ',' <column name> )* ')'.
In Open SQL the <insert column list> is not optional.
You cannot specify string literals as values for CLOB columns. Hex literals are not supported in Open SQL.
Examples
INSERT INTO employees (employee_id, employee_name)
VALUES (4711, 'John Smith')
Inserting Values. A new row is inserted into the table employees with the values 4711 and 'John Smith' for the columns employee_id and employee_name respectively.
INSERT INTO well_paid_employees (employee_id, salary)
SELECT employee_id, salary
FROM employees
WHERE salary > ?
Inserting the Result of a Query. The employee_idand the salaryof all employees from table employeeswith a salary exceeding a certain value are inserted into the table well_paid_employees.
Regards -
Hi...
I want to make an insert statement with a cursor, and if in the destination table exists allready a record like in start table, I would like to skip to insert that record.....and inserting the other records from the start table......
Can anyone help me?
Thanks.Why not a plain insert statement like this
insert into dest_table (col1, col2)
select col3, col4
from source_table
where not exists(select 1 from dest_table where col1=col4); -
Insert statement in when-checkbox-checked trigger doesn't work
in a when-checkbox-checked trigger, I wrote the follwing code :
IF :sunday = 'Y' THEN
msg_alert('Y','I',false);
pkg_var.v_day_count := pkg_var.v_day_count + 1;
msg_alert('1','I',false);
:schtm_skmk.day_id := '1';
msg_alert('2 ',I',false);
INSERT INTO schtm
(ROUTE_ID, DAY_ID, FLIGHT_ID)
VALUES
(:schmf.ROUTE_ID, :schtm_skmk.day_id, 1);
COMMIT;
msg_alert('end insert schtm','I',false);
END IF;
if the checkbox is checked, I assigned value '1' to day_id. Then, I want to insert a row into table SCHTM. But, the insert statement fail. The msg_alert '2' pop up. The msg_alert 'end insert schtm' does not pop up, meaning the insert statement fail. It also fail after I replace the insert statement with the exact value of the item. But if I execute this statement in SQL plus, it insert a row into the database.
What is strange here is it did work before, I successfully insert 2 rows into database. But when I test it again just a while later, it never work anymore.
Please help.
Thanks,
Shu WenIt seems that you have missed ELSE. By the way there is only one INSERT ...
-
Urgent help needed... PL/SQL Insert statement
Hi...
I need some urgent help on this project. I have a 2 column table with values that need to be inserted into another existing table which has a sequence.
This is the 2 column table:
FUND YEAR
29587 05
29587 07
Existing table:
Name Null? Type
LIST_ID NOT NULL NUMBER(6) -- This is a sequence
WEB_USER_ID NOT NULL VARCHAR2(10)
RESOURCE_TYPE NOT NULL VARCHAR2(8)
LIST_TYPE NOT NULL VARCHAR2(10)
LIST_NAME NOT NULL VARCHAR2(50)
LIST_CODE_1 NOT NULL VARCHAR2(6) -- FUND from table above
LIST_CODE_2 NOT NULL VARCHAR2(6) -- YEAR from table above
LIST_CODE_3 NOT NULL VARCHAR2(6)
LAST_UPDATED_DT NOT NULL DATE
LAST_UPDATED_BY NOT NULL VARCHAR2(10)
LIST_CODE_4 NOT NULL VARCHAR2(20)
The columns from table 1 (FUND, YEAR) correspond to columns (LIST_CODE_1, LIST_CODE_2) in table 2. The column LIST_ID is a sequence. I can put in sysdate for LAST_UPDATED_DT and my initials SN for LAST_UPDATED_BY. This is going to be for 2 unique WEB_USER_IDs which would be in the WHERE clause. I will be inserting 2200 rows for each id. A single insert statement would look like this -
INSERT INTO EXISTING_TBL (list_id,web_user_id,resource_type,list_type,list_name,list_code_1,list_code_2,list_code_3,list_code_4,last_updated_dt,last_updated_by) VALUES ('470027','WEBUSER','GL','FUNDFYF',' FUND BALANCE SUM','12010','01',' ',' ',{ts '2010-5-19 10:16:9'},'SN')
How would I do this to insert the 2200 values from my 2 column table to the existing table?
All help is greatly appreciated!!
SNHello ,
I think this will work
INSERT INTO TABLE2
LIST_ID,
WEB_USER_ID,
RESOURCE_TYPE,
LIST_TYPE,
LIST_NAME,
LIST_CODE_1,
LIST_CODE_2,
LIST_CODE_3,
LIST_CODE_4,
LAST_UPDATED_DT,
LAST_UPDATED_BY
SELECT
SEQ.NEXTVAL,
FUND,
YEAR,
<VALUE FOR RESOURCE_TYPE>,
<VALUE FOR LIST_TYPE>,
<VALUE FOR LIST_NAME>,
<VALUE FOR LIST_CODE_1>,
<VALUE FOR LIST_CODE_2>,
<VALUE FOR LIST_CODE_3>,
<VALUE FOR LIST_CODE_4>,
SYSDATE,
'SN'
FROM
TABLE1
REGARDS
Rahul Sharma
Maybe you are looking for
-
How to add the quantities in a certain column?
Hi All, I am extracting data from an SAP table. One of the columns in the output is 'Confirmed Quantities'. I would like to sum up these individual confirmation quantities and display the 'Total'. Could somebody tell me the best way and how to do it?
-
Is there a how-to guide for setting up a small publically-visible home web server, basically for testing purposes? I have a DSL modem, Westell. The web server software is running and I can see the site on my home network, but everyone else on the Int
-
How to exchange data between two web application (servlet)
Hello, all, I have two servlets: SerlvetA and ServletB, they are deployed as web appA and appB in the same web container(tomcat) How ServletA exchange data with ServletB? I have tried follow methods: 1) appA and appB could not share HttpSession, so I
-
Custom colors for Keynote charts?
I'm using the charts in Keynote for the first time, and I'm finding it surprising inflexible. As far as I can tell, I can not choose custom colors but have to choose between a few color sets chosen by Apple. Is that right? I would like 3 columns, wit
-
Why bdb-ha is not working normal?
in out company project,we used the bdb-ha to replication master bdb data to slave bdb. but we find that datareplication is not working well,and we will lose some important data, which will bring up serious problem for us. i want to know what will the