Inserting the column values into table from view through procedure!!!
below is my example code
Create or replace procedure test_proc
is
cursor test_cur is
select a.col1 , b.col2, c.col3, d.col4, e.col5
from tableA a, tableB b, tableC c, tableD d, tableE e;
test_cur_rec test_cur%rowtype;
Begin
insert into test_stg ( col1, col2, col3, col4, col5, col6, col7)
Values ( test_cur_rec. col1,
test_cur_rec .col2,
test_cur_rec .col3,
test_cur_rec .col4,
test_cur_rec .col5
-- col6, col7 );
create view test2 (
select f.col6, g.col7 from tableF f,tableG g);
I m trying to insert values into the table test_stg but for col6 and col7 i need to get the data from the view test2.
In simple word, all i need to do is get the 2 columns data from view and insert into a table through procedure. The above code is the example which looks very much like my actual code.
How do i accomplish this task ??
well there is joining condition for a, b,c ,d, e tables, i have not mentioned here. The where condition has nothing to do with the other two columns of the view.
There is no relation ship between the these tables the view. The col 6 and 7 i m inserting from view is sysdate timestamp and the job_id number.
so its pretty straight forward insertion into the table from view columns. These two columns has just one row with id number and timestamp. so i need to insert these data into the the table when i run a procedure.
Thank you so much!!!
Similar Messages
-
Compare String in a table and insert the common values into a New table
Hi all,
Anyone has idea on how to compare a string value in a table.
I have a Students Table with Student_id and Student_Subject_list columns as below.
create table Students( Student_id number,
Student_Subject_list varchar2(2000)
INSERT INTO Students VALUES (1,'Math,Science,Arts,Music,Computers,Law,Business,Social,Language arts,History');
INSERT INTO Students VALUES (2,'Math,Law,Business,Social,Language arts,History,Biotechnology,communication');
INSERT INTO Students VALUES (3,'History,Spanish,French,Langage arts');
INSERT INTO Students VALUES (4,'History,Maths,Science,Chemistry,English,Reading');
INSERT INTO Students VALUES (5,'Math,Science,Arts,Music,Computer Programming,Language arts,History');
INSERT INTO Students VALUES (6,'Finance,Stocks');
output
Student_id Student_Subject_list
1 Math,Science,Arts,Music,Computers,Law,Business,Social,Language arts,History
2 Math,Law,Business,Social,Language arts,History,Biotechnology,communication
3 History,Spanish,French,Langage arts
4 History,Maths,Science,Chemistry,English,Reading
5 Math,Science,Arts,Music,Computer Programming,Language arts,History
6 Finance,Stocks
I need help or some suggestion in write a query which can compare each row string value of Student_Subject_list columns and insert the
common subjects into a new table(Matched_Subjects).The second table should have the below colums and data.
create table Matched_Subjects(Student_id number,
Matching_studesnt_id Number,
Matched_Student_Subject varchar2(2000)
INSERT INTO Matched_Subjects VALUES (1,2,'Math,Law,Business,Social,Language arts,History');
INSERT INTO Matched_Subjects VALUES (1,3,'History,Langage arts');
INSERT INTO Matched_Subjects VALUES (1,4,'History,Maths,Science');
INSERT INTO Matched_Subjects VALUES (1,5,'Math,Science,Arts,Music,Language arts,History');
INSERT INTO Matched_Subjects VALUES (2,3,'History,Langage arts');
INSERT INTO Matched_Subjects VALUES (2,4,'History,Maths');
INSERT INTO Matched_Subjects VALUES (2,5,'Math,Language arts,History');
INSERT INTO Matched_Subjects VALUES (3,4,'History');
INSERT INTO Matched_Subjects VALUES (3,5,'Language arts,History');
INSERT INTO Matched_Subjects VALUES (4,5,'Math,Science');
output:
Student_id Match_Student_id Matched_Student_Subject
1 2 Math,Law,Business,Social,Language arts,History
1 3 History,Langage arts
1 4 History,Maths,Science
1 5 Math,Science,Arts,Music,Language arts,History
2 3 History,Langage arts
2 4 History,Maths
2 5 Math,Language arts,History
3 4 History
3 5 Language arts,History
4 5 Math,Science
any help will be appreciated.
Thanks.
Edited by: user7988 on Sep 25, 2011 8:45 AMuser7988 wrote:
Is there an alternate approach to this without using xmlagg/xmlelement What Oracle version are you using? In 11.2 you can use LISTAGG:
insert
into Matched_Subjects
with t as (
select student_id,
column_value l,
regexp_substr(student_subject_list,'[^,]+',1,column_value) subject
from students,
table(
cast(
multiset(
select level
from dual
connect by level <= length(regexp_replace(student_subject_list || ',','[^,]'))
as sys.OdciNumberList
select t1.student_id,
t2.student_id,
listagg(t1.subject,',') within group(order by t1.l)
from t t1,
t t2
where t1.student_id < t2.student_id
and t1.subject = t2.subject
group by t1.student_id,
t2.student_id
STUDENT_ID MATCHING_STUDESNT_ID MATCHED_STUDENT_SUBJECT
1 2 Math,Law,Business,Social,Language arts,History
1 3 Language arts,History
1 4 Science,History
1 5 Math,Science,Arts,Music,Language arts,History
2 3 Language arts,History
2 4 History
2 5 Math,Language arts,History
3 4 History
3 5 History,Language arts
4 5 History,Science
10 rows selected.
SQL> Prior to 11.2 you can create your own string aggregation function STRAGG - there are plenty of example on this forum. Or use hierarchical query:
insert
into Matched_Subjects
with t1 as (
select student_id,
column_value l,
regexp_substr(student_subject_list,'[^,]+',1,column_value) subject
from students,
table(
cast(
multiset(
select level
from dual
connect by level <= length(regexp_replace(student_subject_list || ',','[^,]'))
as sys.OdciNumberList
t2 as (
select t1.student_id student_id1,
t2.student_id student_id2,
t1.subject,
row_number() over(partition by t1.student_id,t2.student_id order by t1.l) rn
from t1,
t1 t2
where t1.student_id < t2.student_id
and t1.subject = t2.subject
select student_id1,
student_id2,
ltrim(sys_connect_by_path(subject,','),',') MATCHED_STUDENT_SUBJECT
from t2
where connect_by_isleaf = 1
start with rn = 1
connect by student_id1 = prior student_id1
and student_id2 = prior student_id2
and rn = prior rn + 1
STUDENT_ID MATCHING_STUDESNT_ID MATCHED_STUDENT_SUBJECT
1 2 Math,Law,Business,Social,Language arts,History
1 3 Language arts,History
1 4 Science,History
1 5 Math,Science,Arts,Music,Language arts,History
2 3 Language arts,History
2 4 History
2 5 Math,Language arts,History
3 4 History
3 5 History,Language arts
4 5 History,Science
10 rows selected.SY. -
How CallableStatement in JSP use setDate() method to insert the date value into DB?
Dear all,
I met a strange error message when i insert a date value into DB via JSP call PL/SQL procedures.
The error seems caused by the setDate(index, date) method with CallableStatement.
The message is: Can not find the setDate(int, java.util.Date) method in the CallableStatement interfaces.
Any ideas?
Thanks advanced.Thank you!:)
I solved it using this:
String name="david";
stmt = con1.createStatement();
String prikaz1 = "INSERT INTO table (id,age,surname,name) IN 'C:\\Users\\David\\Desktop\\db.mdb' SELECT id,age,surname,' " + name + " ' FROM table2";
stmt.executeUpdate(prikaz1); -
Saving values into table from Interactive Form
Hallo together,
iam trying to do the example "Include Tables" (SAP Interactive Forms by Adobe - Galileo Press).
It works, but not as described. When i want to change data in the interactive_forms ui element and press the webdynpro native button send, the value at the webdynpro table does not change. When i change the value at the webdynpro table and press the send button at the form or change the line at the webdynpro, the value in the adobe formular changes too. Thats one problem.
The other problem is that i want to save the changed/added data from the formular at the database. What to do? The form layout is "ZCI Layout" and i added the script:
DO NOT MODIFY THE CODE BEYOND THIS POINT - 800.20070708051308.406522.403406 - ContainerFoundation_JS
I also added this into "wddomodifyview":
METHOD wddomodifyview .
DATA: lr_interactive_form TYPE REF TO cl_wd_interactive_form,
lr_method_handler TYPE REF TO if_wd_iactive_form_method_hndl.
CHECK first_time = abap_true.
lr_interactive_form ?= view->get_element( 'FORM' ).
lr_method_handler ?= lr_interactive_form->_method_handler.
lr_method_handler->set_legacy_editing_enabled( abap_true ).
ENDMETHOD.
I selected also:
execute at: "Server and Client"
I dont know what to do anymore.
Best regards
PhilipHi,
To make an input enabled table. I would suggest to use TABLE element from the PDF library and then binding the columns from your context.
Step 1: Library -> Standard ->Table
Select create using assistance.
Select body rows vary depending on data .
Select number of Columns in your case it will be 4.
Then proceed further and finish as per your need.
Step 2:
Select a table Column .
Select Pallets->Object then chnage the cell type from Text to text field.
Then click on binding tab and bind it to the respective field from hierarchy.
Select upgrade the following properties radio button and check only "default value" option.
This will create binding something like this $record.SCARR.DATA[*].CARRID
Follow this for all other columns.
Step 3:
Now create a button in the View holding your form(you can also use SUBMIT button of form). On action event of this button right the following code to get all the changed values from Table.
data lt_scarr type wd_this->elements_scarr.
call method lo_nd_scarr->get_static_attributes_table
importing
table = lt_scarr.
LT_SCARR will contain all the new values from Form. Then use this table to update ur database table.
Thanks,
Abhishek -
How to store all the columns values into one single column
Hi All,
this is my file layout,i am receiving the data in below format only
emp_no,c1,c2,c3,c4,c5
100 ,1 ,0 ,1 ,0,1
200 ,1 ,0 ,1 ,0,1
300 ,1 ,0 ,1 ,0,1
but i want to store that above data into my table like(from c1 to c5 columns values i want to store in period column)
emp_no,period
100 ,1
100 ,0
100 ,1
100 ,0
100 ,1
200 ,1
200 ,0
200 ,1
200 ,0
200 ,1
300 ,1
300 ,0
300 ,1
300 ,0
300 ,1
please help meStrange but this is it
Processing ...
with original as (
select 100 as id ,1 as v1,0 as v2,1 as v3,0 as v4,1 as v5
from dual
union all
select 200 ,1 ,0 ,1 ,0,1
from dual
union all
select 300 ,1 ,0 ,1 ,0,1
from dual
select id,v1 as res_row
from original
union all
select id,v2
from original
union all
select id,v3
from original
union all
select id,v4
from original
union all
select id,v5
from original
ID RES_ROW
100 1
200 1
300 1
100 0
200 0
300 0
100 1
200 1
300 1
100 0
200 0
300 0
100 1
200 1
300 1
15 row(s) retrievedBye Alessandro -
Insert data file name into table from sql loader
Hi All,
I have a requirement to insert the data file name dynamically into table using sql loader.
Example:
sqlldr userid=username/passwword@host_string control=test_ctl.ctl data=test_data.dat
test_ctl.ctl
LOAD DATA
FILED TERMINATED BY ','
INTO TABLE test
(empid number,
ename varchar2(20),
file_name varchar2(20) ---------- This should be the data file name which can be dynamic (coming from parameter)
test_data.dat
1,test
2,hello
3,world
4,end
Please help..
Thanks in advance.
Regards
Anujyou'll probably have to write your control file on the fly, using a .bat or .sh file
rem ===== file : test.bat ========
rem
rem ============== in pseudo speak =============
rem
rem
echo LOAD DATA > test.ctl
echo FILED TERMINATED BY ',' >> test.ctl
echo INTO TABLE test >> test.ctl
echo (empid number, >> test.ctl
echo ename varchar2(20), >> test.ctl
echo file_name constant %1% >> test.ctl
echo ) >> test.ctl
rem
rem
rem
sqlldr userid=username/passwword@host_string control=test.ctl data=test_data.dat
rem =============== end of file test.bat =======================
http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_field_list.htm#i1008664 -
Insert the data in sap tables from C SHARP application
Hi All,
I want to save some data in sap table from my CSharp(DOTNET) windows application.I tried with the help of SAP.Net Connector but that connector is not been supported visual studio 2005 or i not have visual studio 2003 .Soo plz any one can help how i can do this .
If any one have a idea then plz give me some example also how we did.
thanks
regards
sandeep DabralYou have to use SAP .NET connetor to make interface with SAP. This is better way of doing interface between .NET and SAP.
You create web service (wsdl) in .NET 2003 and try to use that in .NET 2005.
You're getting the two technologies confused ......
.Net Connector is used for RFC-type interfaces. It calls Bapi's directly. Web services are not involved for this type of interface.
WSDL files are used to generate proxies for the .Net client to call Web Services (typically web-enabled Bapi's). This type of interface uses SOAP protocol not RFC and does not use the .Net Connector. Enterprise Web Services may be discovered using the .Net Enterprise Service Explorer, which is a different component from the .Net Connector.
Regards,
D. -
Problem in Inserting the new values into Ztable
Hi Techies,
I have a requirement that when ever user enters the value in Billing Qty input which is in VF01 tcode and the table is VBRP-FKIMG, and client want billing qty and previous month reading, the fields are not in VBRP. So I have created a custom table name as YSD-EXPORT_QTY with fields of CUSTOMER, MONTH, YEAR, BILL_QTY, PREV_READING, CUMULATIVE... When ever user enter the Billing Qty I want to update database table and initally there is no data in custom table. I tried below code but i am not getting and i am getting the error as
"The type of the database table and work area (or internal table) "WA_EXPORT" are not Unicode convertible. "
So, How can I resolve this issue.. I am trying this since from 3 days... if u have any sample code please give me...
MOVE WA_VBRP-FKIMG TO WA_EXPORT-BILL_QTY.
WA_EXPORT-CUMULATIVE = WA_EXPORT-BILL_QTY + WA_EXPORT-PREV_READING.
WA_EXPORT-PREV_READING = WA_EXPORT-CUMULATIVE.
APPEND WA_EXPORT TO IT_EXPORT.
INSERT INTO YSD_EXPORT_QTY VALUES WA_EXPORT.If it overrides existting record, you should add new key fields to your database table, there can be only one record per set of key values.
I suppose keys look like MANDT, KUNNR, GJAHR, MONAT or MANDT VBELN POSNR or a combination of both set of keys (not sure to understand you requirement)
You have to first read from database if some data already exists,
- if yes, add the new quantities and UPDATE the record
- if no, INSERT a new record
Remember keys define a unique record, and cannot be updated once inserted.
If your program should never update records, add a "technical" key field, and fill it using a timestamp or a number range counter (FM NUMBER_GET_NEXT)
Regards,
Raymond -
Inserting comma seperated values into table
Hi,
There is a variable like this,
var= 'C0001,C0002,C0003';
I want c0001 c0002 and c0003 to get inserted into some temp table as seperate rows, how do I do that.
Thnx again ur your response.Hi,
There is a variable like this,
var= 'C0001,C0002,C0003';
I want c0001 c0002 and c0003 to get inserted into some temp table as seperate rows, how do I do that.
Thnx again ur your response. -
How to insert a default value into MS server in java - help please
hi
suppose if i have a table and one of the column has a default value when the table was created. how can i insert the default value into this column? assuming that the column is the second column and i can't specify the column name when inserting. thanks.thanks for ur response, so if i have insert statement as follow
insert into someTable values (1,'val1', 'val2', 'val3', 'val4')
and column 3 has default value = DEFAULT
then, to insert default value, my insert statement will look like this
insert into someTable values (1,'val1', 'val3', 'val4')
but the number of values will not match the number of columns. -
How to get the column values from a BC4J View Table in UIXML?
I am using a default UiXML Application for Order Entry system with Orders & Order Lines & Customers. I have a uix file OrdersView1_View.uix which displays (no updateable columns) all the Orders. How do I get the column value of a selected row in a BC4J Table (example:OrdersId) when a Submit button is pressed using UIXML or Java Classes?
I appreciate any help on this.Hi,
You need to use keyStamp, an example:
<bc4j table name="orders">
<bc4j:keyStamp>
<bc4j:rowKey name="key" />
</bc4j:keyStamp>
Furthermore, you can automatically send the selected row key using the go event handler, so in the handlers section you could send the key to an orderInfo page:
<event name="show">
<!-- forward to the update page, passing
the selected key as a page property -->
<ctrl:go name="orderInfo" redirect="true">
<ctrl:property name="key">
<ctrl:selection name="orders" key="key" />
</ctrl:property>
</ctrl:go>
</event> -
How to insert column values into database as rows
Hi,
I have 8 columns and some not null columns. Based on not null columns I want to insert into table as rows. The 8 columns may contain values or no value. If the first column contains data, then I have to insert into one row. if the second column contains data I have to insert a row and in second column. respectively...So How can I insert column values into rows. Can I write 8 insert statements. (OR) is it possible to insert data from columns using where clause.
Please help me out....
Thanks in AdvanceLines Table:
line_id, orcl_bank_account_num, product_type, service_type, lease_type,
funding_type, cpi, billing_frequency_unit_cd , annual_due_date ,
pricing_start_date, pricing_end_date, install_date, contract_end_date ,
prdct_replacement_cost_amt, cradle_replacement_amt, supranet_contract,
issuance_fee, board_inactive_date, header_id, creation_date, last_modified_date,
created_by_nam, modified_by_nam, activeinactive_flg, prdct_bill_amt_yr1,
prdct_bill_amt_yr2, prdct_bill_amt_yr3, prdct_bill_amt_yr4, prdct_bill_amt_yr5,
prdct_bill_amt_yr6, prdct_bill_amt_yr7, prdct_bill_amt_yr8, activation_fee_yr1,
activation_fee_yr2, activation_fee_yr3, activation_fee_yr4, activation_fee_yr5,
activation_fee_yr6, activation_fee_yr7, activation_fee_yr8,
In this table the columns structure is :
-- PRDCT_BILL_AMT_YR (1 to 8) NUMBER(14,4)
-- ACTIVATION_FEE_YR (1 to 8) NUMBER(8,2)
I have one more table:
PRDCT_INS_AMT NUMBER(14,4)
ACTIVATION_FEE_AMT NUMBER(14,4)
I want to insert prdct_bill_amt_yr (1 to 8) columns data into PRDCT_INS_AMT column. similarly activation_fee (1 to 8) columns data.
But the data should be inserted based product_type, service_type, lease_type columns values. (These 3 columns may contain upto 45 combinations). -
How to insert an upper value into a column?
Hi!,
I need to insert an upper value into a column.
The data is on a flat file and it could be lowercase or uppercase?
Do I have to create a trigger to solve this problem?
How could the trigger be?
Thanks,
AlexIf you are using SQL*Loader to load the data from flat file into the db table, then you can achieve inserting the UPPER Case of column value in your sqlloader ctl file itself as in below example
LOAD DATA
INFILE *
APPEND INTO TABLE XXX
( field1 position(1:7) char "UPPER(:field1)",
field2 position(8:15) char "UPPER(:field2)"
BEGINDATA
Phil Locke
Jason Durbin
So in this case the Names Phil Locke and Jason Durbin will be inserted as PHIL LOCKE and JASON DURBIN into the target table.
Regards,
Murali Mohan -
How to get the column name and table name with value
Hi All
I have one difficult requirement
I have some column values and they have given some alias column names but i need to find the correct column name and table name from the database.
For example value is "SRI" and i dont know the table and exact column name so is there any possibilities to find the column name and table name for the given value
Thanks & Regards
Srikkanth.MSearching all the database for a word...
Courtesy of michaels...
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
11g upwards
SQL> select table_name,
column_name,
:search_string search_string,
result
from (select column_name,
table_name,
'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
from cols
where table_name in ('EMP', 'DEPT')),
xmltable (str columns result varchar2(10) path '.')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME es RESEARCH
EMP ENAME es JAMES
EMP JOB es SALESMAN
EMP JOB es SALESMAN
4 rows selected. -
How to find the column name and table name with a value
Hi All
How to find the column name and table name with "Value".
For Example i have value named "Srikkanth" This value will be stored in one table and in one column i we dont know the table how to find the table name and column name
Any help is highly appricatable
Thanks & Regards
Srikkanth.M2 solutions by Michaels (the latter is 11g upwards only)...
michaels> var val varchar2(5)
michaels> exec :val := 'as'
PL/SQL procedure successfully completed.
michaels> select distinct substr (:val, 1, 11) "Searchword",
substr (table_name, 1, 14) "Table",
substr (t.column_value.getstringval (), 1, 50) "Column/Value"
from cols,
table
(xmlsequence
(dbms_xmlgen.getxmltype ('select ' || column_name
|| ' from ' || table_name
|| ' where upper('
|| column_name
|| ') like upper(''%' || :val
|| '%'')'
).extract ('ROWSET/ROW/*')
) t
-- where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
order by "Table"or
SQL> select table_name,
column_name,
:search_string search_string,
result
from cols,
xmltable(('ora:view("'||table_name||'")/ROW/'||column_name||'[ora:contains(text(),"%'|| :search_string || '%") > 0]')
columns result varchar2(10) path '.'
where table_name in ('EMP', 'DEPT')
TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
DEPT DNAME ES RESEARCH
DEPT DNAME ES SALES
EMP ENAME ES JONES
EMP ENAME ES JAMES
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES SALESMAN
EMP JOB ES PRESIDENT
EMP JOB ES SALESMAN
9 rows selected.
Maybe you are looking for
-
How do I reformat hard drive without affecting recovery partition?
I would like to know how I can reformat my Toshiba hard drive without affecting the hidden recovery partition? I would like to get rid of the preinstalled Windows 7 OS and replace it with Windows XP, which is not as bloated. Also, does anyone know of
-
How to sort source file beforfe mapping
Dear all, Its a file (fixed length) to Idoc(FIDCC1) scenario. Source file has the following fields: Date Account Cost Center Debit Amount Credit Amount Etablissement The mapping requirement is: 1. Per 'Etablissment' code, an Idoc(FIDCCP01) has to be
-
Hi, I created one payment method of type chech and related this to PN´s. I´m using Payment wizard and i get to pay, but it creates two check´s and I want just one. See that i choose two vendors. Thanks a lot. Wagner
-
How to get rowcount in a query which is built on Infocube
Hi, I would like to show rowcount for a report which is built on Infocube. If i have a query on DSO, i would get Rowcount in the query designer but how can we get this same Rowcount if i create a query on Infocube. Thanks in advance
-
Switching view controller crashes
I set a button to change the view controller and i get this error please help