Unable to insert rows into the table
My insert statement below is not correct, when i try run, its encoutering error "table or view does not exist".
Basically what i am doing here is collecting the table name in FOR variable which stores the table name in this variable. This variable, i am using as table. I know this is not the proper way, please let me how can insert the complete table rows with the following code.
DROP TABLE TEMP;
CREATE TABLE TEMP AS SELECT * FROM Comp WHERE 1=2;
DECLARE
I INTEGER DEFAULT 1;
S VARCHAR2(50);
begin
for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CABLE%' and TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;
dbms_output.put_line(c.table_name);
end loop;
end;
The above insert statement is not correct. How can i write proper way.
Thanks.
Best Regards
Arshad
user13360241 wrote:
My insert statement below is not correct, when i try run, its encoutering error "table or view does not exist".
Basically what i am doing here is collecting the table name in FOR variable which stores the table name in this variable. This variable, i am using as table. I know this is not the proper way, please let me how can insert the complete table rows with the following code.
DROP TABLE TEMP;
CREATE TABLE TEMP AS SELECT * FROM Comp WHERE 1=2;
DECLARE
I INTEGER DEFAULT 1;
S VARCHAR2(50);
begin
for C in (select TABLE_NAME INTO S from USER_TABLES where TABLE_NAME like 'CABLE%' and TABLE_NAME NOT like '%OLD' and Num_ROWS > 0 order by TABLE_NAME) loop
INSERT INTO TEMP SELECT * FROM c.TABLE_NAME;
dbms_output.put_line(c.table_name);
end loop;
end;
The above insert statement is not correct. How can i write proper way.
Thanks.
Best Regards
ArshadSTMT := 'INSERT INTO TEMP SELECT * FROM ';
STMT := STMT || S;
EXECUTE IMMEDIATE STMT;
Similar Messages
-
Help in inserting rows into a table
I have a table called acct_fact,
I need to insert rows in the table using a script but the problem is there's a column called seq_nbr which has random seq nbr of 14character length like 'ZWX98MGD9MVAD6J','ZWX98MG67RVAD6J' etc.,
While inserting rows I need to generate such seq_nbr for those columns and insert rows into the table, can I use any such mechanism in my insert query to insert such random nbr's while inserting rows into a table.
If so please suggest meHi Peter,
Thankyou for the quick reply:)
can you suggest me how to implement it here in my script snippet:
while read var_acct_nbr
do
echo "update acct_attr set acct_attr_exp_dt ='$ExpDate' where Acct_Attr_Value_Text='15' and acct_attr_exp_dt is null and person_id='LDCarrBillAgrm' and acct_nbr='$var_acct_nbr' ;" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
echo "insert into acct_fact values ('$var_acct_nbr','$ExpDate','$ExpTime','*seq_nbr*','N','ProjTereza','Remoção de acordo d; data de expiração: $ExpDate',null,'1','LDE',null);" >> ./$DirectoryName/SQLQuery_$TimeStamp.sql
done < ./$DirectoryName/ExpireAccts_$TimeStamp.LOG
the script takes each acct_nbr nbr form a input file and fires an insert statement.
The one in bold is the column where such sequence need to be inserted.can you help me in implementing the way you suggested in my script i.e., insert statement
Thanks in Advance:)
Edited by: rkrish on Jun 27, 2012 3:04 AM -
Insert Multiple rows into the table from that table data
Hi All,
I have a requirement like to insert mulitple rows into the table from that table data only(I need to replicate the data).
In this table primary key is composite primary key with all foreign keys.primary key also including the Date foreign key.I need to change that date at the of insertion.
INSERT
INTO myschema.Fact_page_performance
time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available ,
date_sk
VALUES
(SELECT time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available
FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
WHERE date_sk=20090509,20090510
But it is giving the error like missing Expression.
Could anyone please help to me.
Thanks and Regards
Swetha.You can have either VALUES or SELECT not both
INSERT
INTO myschema.Fact_page_performance
time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available ,
date_sk
SELECT time_sk ,
batch_id ,
delta_msec ,
delta_user_msec,
error_code_sk ,
content_errs ,
element_count ,
page_bytes ,
Available
FROM myschema.FACT_PAGE_PERFORMANCE_BACKUP
WHERE date_sk=20090509,20090510; -
Need to insert rows into 100 tables at a time
hi there,
below is our script for creation of 100 tables...
we need a plsql script, to insert rows into 100 tables at a single time...
please help us...vey urgent...
DECLARE
counter NUMBER;
sql_string VARCHAR2(2000);
BEGIN FOR counter IN 1..100 LOOP sql_string := 'CREATE TABLE emp_table'||counter||'
(id integer primary key, col_a VARCHAR2(42),col_b date,col_c number,col_d varchar2(20),col_e varchar2(20),
col_f varchar2(20),col_g varchar2(20),col_h date,col_i varchar2(20),col_j varchar2(20),col_k date)';
EXECUTE IMMEDIATE sql_string;
END LOOP;
END;
/hi,
below is our procedure and the error we are getting...
Name Null? Type
ID VARCHAR2(10)
COL_A VARCHAR2(10)
COL_B VARCHAR2(10)
COL_C VARCHAR2(10)
COL_D VARCHAR2(10)
COL_E VARCHAR2(10)
COL_F VARCHAR2(10)
COL_G VARCHAR2(10)
COL_H VARCHAR2(10)
COL_J DATE
DECLARE
counter NUMBER;
sql_string VARCHAR2(4000);
BEGIN FOR counter IN 1..100 LOOP sql_string := 'CREATE TABLE emp_a'||counter||'
(id varchar2(10), col_a varchar2(10), col_b varchar2(10), col_c varchar2(10), col_d varchar2(10), col_e varchar2(10),
col_f varchar2(10), col_g varchar2(10), col_h varchar2(10), col_j date)';
EXECUTE IMMEDIATE sql_string;
END LOOP;
END;
DECLARE
counter NUMBER;
sql_string VARCHAR2 (2000);
BEGIN
FOR OuterCounter IN 1 .. 100 LOOP --- table prefix in which it is to be inserted
FOR InnerCounter IN 1 .. 100 LOOP --- records to be inserted
sql_string := 'INSERT INTO emp_a' || Outercounter || ' (id, col_a, col_b, col_c, col_d, col_e, col_f, col_g, col_h, col_j)
VALUES ('
|| InnerCounter || ', to_char( ''col_a''' || innercounter || '),'
|| InnerCounter || ', to_char( ''col_d''' || innercounter || '),'
|| ', to_char( ''col_e''' || innercounter || '),'
|| ', to_char( ''col_f''' || innercounter || '),'
|| ', to_char( ''col_g''' || innercounter || '),'
|| ', to_char( ''col_h''' || innercounter || '),'
|| ', to_char( ''col_j''' || innercounter || '), SYSDATE)';
EXECUTE IMMEDIATE sql_string;
END LOOP;
END LOOP;
END;
DECLARE
ERROR at line 1:
ORA-00907: missing right parenthesis
ORA-06512: at line 17
please check the procedure and write the correct one... -
Hi,
I want to insert values into a table 'Reasons'.
The table 'Reason' has 5 columns
out of 5 two columns has static data say
column A value 'A'
column E value sysdate
But in the other three columns the vlues are repeating and as follows.
Column B all rows of column x from table B
Column C all rows of column y from table C
Column D list of values as (ONE,TWO,THREE,FOUR)
Please Help
Thanks
Rohit Tanejacreate table tableb(id number,x varchar2(20));
insert into tableb values(1,'APPLE');
insert into tableb values(2,'BANANA');
insert into tableb values(3,'MANGO');
create table tablec(id number,y varchar2(20));
insert into tablec values(1,'ROHIT1');
insert into tablec values(2,'ROHIT2');
insert into tablec values(3,'ROHIT3');
insert into tablec values(4,'ROHIT4');
select 'A' AS COL_A, d.X AS COL_B,d.Y AS COL_C,
to_char(to_date(ROW_NUMBER() OVER(PARTITION BY X,y ORDER BY X,Y),'YYYY'),'YYYYSP') AS COL_D,SYSDATE
FROM ( select a.id , a.x X, b.y Y from tableb a,tablec b , tablec e order by a.x) d
ORDER BY d.X,d.Y
C COL_B COL_C COL_D SYSDATE
A APPLE ROHIT1 ONE 30-SEP-02
A APPLE ROHIT1 TWO 30-SEP-02
A APPLE ROHIT1 THREE 30-SEP-02
A APPLE ROHIT1 FOUR 30-SEP-02
A APPLE ROHIT2 ONE 30-SEP-02
A APPLE ROHIT2 TWO 30-SEP-02
A APPLE ROHIT2 THREE 30-SEP-02
A APPLE ROHIT2 FOUR 30-SEP-02
A APPLE ROHIT3 ONE 30-SEP-02
A APPLE ROHIT3 TWO 30-SEP-02
A APPLE ROHIT3 THREE 30-SEP-02
A APPLE ROHIT3 FOUR 30-SEP-02
A APPLE ROHIT4 ONE 30-SEP-02
A APPLE ROHIT4 TWO 30-SEP-02
A APPLE ROHIT4 THREE 30-SEP-02
A APPLE ROHIT4 FOUR 30-SEP-02
A BANANA ROHIT1 ONE 30-SEP-02
A BANANA ROHIT1 TWO 30-SEP-02
A BANANA ROHIT1 THREE 30-SEP-02
A BANANA ROHIT1 FOUR 30-SEP-02
A BANANA ROHIT2 ONE 30-SEP-02
A BANANA ROHIT2 TWO 30-SEP-02
A BANANA ROHIT2 THREE 30-SEP-02
A BANANA ROHIT2 FOUR 30-SEP-02
A BANANA ROHIT3 ONE 30-SEP-02
A BANANA ROHIT3 TWO 30-SEP-02
A BANANA ROHIT3 THREE 30-SEP-02
A BANANA ROHIT3 FOUR 30-SEP-02
A BANANA ROHIT4 ONE 30-SEP-02
A BANANA ROHIT4 TWO 30-SEP-02
A BANANA ROHIT4 THREE 30-SEP-02
A BANANA ROHIT4 FOUR 30-SEP-02
A MANGO ROHIT1 ONE 30-SEP-02
A MANGO ROHIT1 TWO 30-SEP-02
A MANGO ROHIT1 THREE 30-SEP-02
A MANGO ROHIT1 FOUR 30-SEP-02
A MANGO ROHIT2 ONE 30-SEP-02
A MANGO ROHIT2 TWO 30-SEP-02
A MANGO ROHIT2 THREE 30-SEP-02
A MANGO ROHIT2 FOUR 30-SEP-02
A MANGO ROHIT3 ONE 30-SEP-02
A MANGO ROHIT3 TWO 30-SEP-02
A MANGO ROHIT3 THREE 30-SEP-02
A MANGO ROHIT3 FOUR 30-SEP-02
A MANGO ROHIT4 ONE 30-SEP-02
A MANGO ROHIT4 TWO 30-SEP-02
A MANGO ROHIT4 THREE 30-SEP-02
A MANGO ROHIT4 FOUR 30-SEP-02
48 rows selected.hope this is helpfull
cheers
prakash -
Insert row into database table via dynamic form -
I have developed a portlet via Portal. I used a dynamic page. I replaced the default "<ORACLE>select * from scott.emp</ORACLE>" text to call a package procedure that uses HTP.P to render the web page. My goal is to show all rows in a table and allow edits to any row, and also add a checkbox on each row to allow the user to mark for delete. I am successfully using a FOR loop and showing all of the data in a grid. My problem - How do I update and delete the data? I have a submit button with nothing behind it currently. I would ideally like to use pl/sql code to do the updates and/or deletes as marked on the page by the user, but I'm not sure how to hook the submit button to calling a procedure to execute the updates/deletes.
Any help would be appreciated -
Thanks -
KentHi Patrick - Thanks for your response! I have browsed your page quickly - very informative and I will look in more detail. My form design looks as below (using a simple example with emp id and emp name columns) - perhaps this will have to change, but I wanted the user to be able to insert using html fields id_add and name_add, then update (or mark for deletion) any of the existing rows (they are rendered with for loop in pl/sql - eg, id_1/name_1, id_2/name_2, etc for each row in the table). I was hoping the submit action would call a pl/sql that would look at all rows, and then act if an update or delete were required. This makes it difficult to use parms, I believe - I may be able to change the design to show an "update row" below the current "insert row" so that, as in your example, when the user highlights a row, it populates in the update area where changes can be made, and an update button used to effect the changes to a single row at a time.
Thanks again, I appreciate your input!
Kent
______________ _________________ <insert_button>
Emp Id (textbox) Emp Name (textbox) Del_Checkbox
______________ _________________ ___ <SUBMIT_BUTTON>
------------------------- ----------------------------- ------ -
ORA-1013 when trying to insert data into the table
Hi,
While inserting record into a table, we are getting the following error:
ORA-1013
01013, 00000, "user requested cancel of current operation"
I could not find any information in alert log also.
We have a bitmap index on this table. However, we never got this error till now.
Also i found that the tablespace who stores data has lot of space and tablespace which consists of the indexes is close to 90% full today ( i dont know what was the space available yesterday when there was error).
I know that information i provided might be very less, but i gave as much information as i can provide.
Can you please help me in trouble shooting this problem.
Thank you
GiridharSorry. i forgot to give version information
Oracle version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0
OS: SunOS 5.10
we got it only once yesterday. only for one table. not for any other tables.
Thanks aalap for your quick response.
Giridhar -
Hi all,
In my SQL Server 2012 Management Studio (SSMS2012), I tried to create a Database (MacLochainnsDB) and a dbo Table (marvel). then I wanted insert 8 VALUES into the Table by using the following code:
USE master
IF EXISTS
(SELECT 1
FROM sys.databases
WHERE name = 'MacLochlainnsDB')
DROP DATABASE MacLochlainnsDB
GO
CREATE DATABASE MacLochlainnsDB
GO
CREATE TABLE [dbo].[marvel] (
[avenger_name] [char] (30) NULL)
INSERT INTO marvel
(avenger_name)
VALUES
('Hulk', 1),
('Iron Man', 2),
('Black Widow', 3),
('Thor', 4),
('Captain America', 5),
('Hawkeye', 6),
('Winter Soldier', 7),
('Iron Patriot', 8)
I got the following error Message:
Msg 110, Level 15, State 1, Line 5
There are fewer columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.
How can I correct this problem?
Please kindly help and advise.
Thanks in advance,
Scott Chang
P. S.
The reason I tried to create the Database, dbo Table, and then to insert the VALUES is to learn the following thing:
You can query the entire node tree with the following xquery statement because it looks for the occurrence of any node with the /* search string:
DECLARE @x xml;
SET @x = N'<marvel>
<avenger_name>Captain America</avenger_name>
</marvel>';
SELECT @x.query('/*');
You can query the avenger_name elements from the marvel_xml table with the following syntax:
SELECT xml_table.query('/marvel/avenger_name')
FROM marvel_xml;
It returns the following set of avenger_name elements:
<avenger_name>Hulk</avenger_name>
<avenger_name>Iron Man</avenger_name>
<avenger_name>Black Widow</avenger_name>
<avenger_name>Thor</avenger_name>
<avenger_name>Captain America</avenger_name>
<avenger_name>Hawkeye</avenger_name>
<avenger_name>Winter Soldier</avenger_name>
<avenger_name>Iron Patriot</avenger_name>
You can query the fourth avenger_name element from the marvel_xml table with the following xquery statement:
SELECT xml_table.query('/marvel[4]/avenger_name')
FROM marvel_xml;
It returns the following avenger_name element:
<avenger_name>Thor</avenger_name>Hi Scott,
The master database records all the system-level information for a SQL Server system, so best practise would be not to create any user-defined
object within it.
To change your default database(master by default) of your login to another, follow the next steps so that next time when connected you don't have to use "USE dbname" to switch database.
Open SQL Server Management Studio
--> Go to Object explorer(the left panel by default layout)
--> Extend "Security"
--> Extend "Logins"
--> Right click on your login, click "propertites"
--> Choose the "Default database" at the bottom of the pop-up window.
--or simply by T-SQL
Exec sp_defaultdb @loginame='yourLogin', @defdb='youDB'
Regarding your question, you can reference the below.
SELECT * FROM master.sys.all_objects where name ='Marvel'
--OR
SELECT OBJECT_ID('master.dbo.Marvel') --if non empty result returns, the object exists
--usually the OBJECT_ID is used if a if statement as below
IF OBJECT_ID('master.dbo.Marvel') IS NOT NULL
PRINT ('TABLE EXISTS') --Or some other logic
What is the sys.all_objects? See
here.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Unable to store data into the Table(R/3)
Dear All,
our requirment is to store few records into the Table in R/3.
We have update RFC which takes input arguments as AbstractList , the following is the code used to store data in the table(R/3)
Zhr_Update input = new Zhr_Update();
AbstractList list= new Zhr_Aprsl_Crs.Zhr_Aprsl_Crs_List();
for(in i=0;i<wdContext.DvelpmntCodes().size();i++)
crs= new Zhr_Aprsl_Crs();
crs.setcid(wdContext.DvelpmntCodes().getDvelpmntCodesElementAt(i).getcode(i));
crs.setDesp(wdContext.DvelpmntCodes().getDvelpmntCodesElementAt(i).getcodDesp(i));
crs.setYear(wdContext.DvelpmntCodes().getDvelpmntCodesElementAt(i).getcodeYear(i));
list.add(crs);;
input.setcrs_chr_data(list);
wdContext.Zhr_Update_Input().bind(input);
wdContext.nodeZhr_Update_Input().currentZhr_Update_InputElement().modelObject().execute();
The RFC is executing sucessfully without errors but data is not stored in the R/3 table
Thanks,
vijay.
Edited by: vijay krishna on Oct 12, 2009 11:21 AMHi,
Use the following code to fix the issue
for(in i=0;i<wdContext.DvelpmntCodes().size();i++)
crs= new Zhr_Aprsl_Crs();
crs.setcid(wdContext.DvelpmntCodes().getDvelpmntCodesElementAt(i).getcode(i));
crs.setDesp(wdContext.DvelpmntCodes().getDvelpmntCodesElementAt(i).getcodDesp(i));
crs.setYear(wdContext.DvelpmntCodes().getDvelpmntCodesElementAt(i).getcodeYear(i));
input.addcrs_Obj_data(crs);
wdContext.nodeZhr_Update_Input().moveNext();
wdContext.Zhr_Update_Input().bind(input); -
Unable to insert row into table.
hi all,
here i am using oracle apex 3.2.0.0.0.27 version.
i am unable to insert a row in the database table.when i press a save button i get an error is
0.07:
0.08: S H O W: application="132" page="4" workspace="" request="" session="3286250612369434"
0.14: Language derived from: FLOW_PRIMARY_LANGUAGE, current browser language: en-us
0.15: alter session set nls_language="AMERICAN"
0.16: alter session set nls_territory="AMERICA"
0.16: NLS: CSV charset=WE8MSWIN1252
0.16: ...NLS: Set Decimal separator="."
0.16: ...NLS: Set NLS Group separator=","
0.16: ...NLS: Set date format="DD-MON-RR"
0.17: ...Setting session time_zone to +05:30
0.17: Setting NLS_DATE_FORMAT to application date format: DD-MON-YYYY HH:MIPM
0.18: ...NLS: Set date format="DD-MON-YYYY HH:MIPM"
0.19: NLS: Language=en-us
0.21: Application 132, Authentication: CUSTOM2, Page Template: 102166708405540699
0.27: ...Session ID 3286250612369434 can be used
0.27: ...Application session: 3286250612369434, user=COMP
0.28: ...Determine if user "COMP" workspace "16032411264866286" can develop application "132" in workspace "16032411264866286"
0.29: ...Check for session expiration:
0.31: Session: Fetch session header information
0.33: ...Metadata: Fetch page attributes for application 132, page 4
0.34: Fetch session state from database
0.38: Branch point: BEFORE_HEADER
0.39: Fetch application meta data
0.49: Setting NLS_DATE_FORMAT to application date format: DD-MON-YYYY HH:MIPM
0.49: ...NLS: Set date format="DD-MON-YYYY HH:MIPM"
0.49: Computation point: BEFORE_HEADER
0.49: Processing point: BEFORE_HEADER
0.49: ...Process "Row_fetch": DML_FETCH_ROW (BEFORE_HEADER) F|#OWNER#:PC_MASTER:P4_PC_ID:PC_ID
0.73: Show ERROR page...
0.73: Performing rollback...
0.79: Processing point: AFTER_ERROR_HEADER
ORA-06550: line 1, column 17: PL/SQL: ORA-00936: missing expression ORA-06550: line 1, column 9: PL/SQL: SQL Statement ignored
Error UNABLE TO FETCH
OK
please anyone can help me to come out this problem.
thanks
regards,
tipanHi Tipan,
This error isn't due to you pressing save, it occurs when the page reloads because you are trying to fetch a record from a database table and the Primary Key APEX Page Item field doesn't have a value in it. You need to add a condition to your fetch so it only runs when the primary key page item has a value in it.
Hope this helps
Paul -
How to insert records into the Table?
Dear Sir,
I'm new to JDeveloper. Now I managed to create a Frame in JDeveloper with many Text fields and a button. In the back end, I have a procedure to insert records to a table, to which I pass the values of the fields as parameters. Now I'm not getting the steps to call the PL/SQL Stored procedure when I click on the button. I'm using Oracle 9i JDeveloper version 9.0.3.1. and Oracle 9i Database.
Please give me the complete steps to achieve my task - it is quite urgent.
Thanking You in advance.
Regards,
Senthil .A. Perumal.The JDBC tutorial will show you how to call a stored procedure from Java:
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/basic.htm
One more thing, why are you using such an old version of JDeveloper? any reason not to upgrade to the 10.1.3 version of JDeveloper?
Also you might want to look into ADF and how it makes these type of database interactions easier.
See this demo:
http://www.oracle.com/technology/obe/obe1013jdev/adf_swing/master_detail_page_adfswing_bc.htm -
Unable to insert data in the table
Hi,
I've a document which has a doctype that points to a URL. When I try to insert this document in the table (xmltype column), I am getting the following errors:
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00263: couldn't connect to host URL port 80
Error at line 2
ORA-06512: at "SYS.XMLTYPE", line 0
ORA-06512: at line 1
Can someone please suggest how should I resolve this issue?
Thanks in advance for all your help.Hi,
Have you just added a new field or you have adjusted the dimensions of the cube along with that. Any change in dimension or change in structure you need to delete the data and reload.
Regards
Akhan -
Unable to insert rows in the Web ADI document
Hi,
I am facing issue with Web ADI document while inserting the new rows. I have configured the Web ADI to update the SIT information of employees. I am able to download the data, modify the data and upload it successfully. However, when I try to add new rows in the document, it says 'Context values cannot be changed'.
Could anyone help me out as to what needs to be done to add new rows to the sheet ?
Regards
JhansiThere are certain areas of the Web ADI template where information cannot be changed, particularly in the Context area. Trying to change values in this area will result in the error
-
Unable to insert rows into ORACLE database using ABAP code
Hai,
I am facing problem while creating a table in Oracle database with 15 attributes in a table. To create a table I am using the classes:
cl_sql_connection -
> to create the connection
cl_sql_statement -
> to execute the query
This I used by reffering the SAP program ADBC_DEMO. Without any trouble I am able to create a Table with 6 attributes by following the same procedure in ABCD_DEMO program but the same is not working for the table with 15 attributes .
Please help me.
Regards,
SwethaHai,
here is my code.
DATA: V_con_name TYPE dbcon-con_name,
con_ref TYPE REF TO cl_sql_connection,
sqlerr_ref TYPE REF TO cx_sql_exception,
c_tabname TYPE string VALUE `TO_DETAILS`,
c_coldefs TYPE string.
DATA: IT_ORA LIKE ZVOP_X_ORA_UPDATE OCCURS 0 WITH HEADER LINE.
V_CON_NAME = 'TVL-DSS-01'.
concatenate '(LGNUM CHAR(3) primary key,'
'TANUM VARCHAR2(10),'
'FLAG CHAR(1),'
'BDATU timestamp(3),'
'TAPOS VARCHAR2(4),'
'MATNR CHAR(18))'
'VLQNR VARCHAR2(10),'
'VLPLA CHAR(10),'
'VLBER CHAR(3),'
'NLPLA CHAR(10),'
'NLBER CHAR(3),'
'VDATE DATE(3) ,'
'BNAME CHAR(12),'
'VTIME DATE(4),'
'PROTYPEFLAG CHAR(1),'
'PROCOMFLAG CHAR(1))'
into c_coldefs separated by space .
TRY.
PERFORM: CONNECT USING V_CON_NAME CON_REF,
CREATE_TABLE USING con_ref c_tabname c_coldefs.
CATCH cx_sql_exception INTO sqlerr_ref.
TB_ERROR-MESSAGE = SQLERR_REF->SQL_MESSAGE.
APPEND TB_ERROR. CLEAR TB_ERROR.
ENDTRY.
form create
form CONNECT using p_con_name TYPE dbcon-con_name
p_con_ref TYPE REF TO cl_sql_connection
RAISING cx_sql_exception.
p_con_ref = cl_sql_connection=>get_connection( p_con_name ).
endform. " CONNECT
form create
form CREATE_TABLE USING p_con_ref TYPE REF TO cl_sql_connection
p_tabname TYPE string
p_coldefs TYPE string
RAISING cx_sql_exception.
DATA:
l_sqlerr_ref TYPE REF TO cx_sql_exception,
l_stmt TYPE string,
l_stmt_ref TYPE REF TO cl_sql_statement.
create a statement object
l_stmt_ref = p_con_ref->create_statement( ).
create the statement string
CONCATENATE
'create table' p_tabname p_coldefs
INTO l_stmt SEPARATED BY space.
execute the DDL command; catch the exception in order to handle the
case if the table already exists
TRY.
l_stmt_ref->execute_ddl( l_stmt ).
CATCH cx_sql_exception INTO l_sqlerr_ref.
IF l_sqlerr_ref->dbobject_exists = 'X'
OR l_sqlerr_ref->internal_error = 1024.
table already exists => drop it and try it again
PERFORM:
drop_table USING p_con_ref p_tabname,
create_table USING p_con_ref p_tabname p_coldefs.
ELSE.
RAISE EXCEPTION l_sqlerr_ref.
ENDIF.
ENDTRY.
endform. " CREATE_TABLE
please do help me
Regards,
Swetha -
Unable to insert row in object table from plsql block
I have table called test based on an object type. When I issue an insert statement from sqlplus, the row is inserted. The exact same sql statement in a plsql block gives the error below. Any ideas? (it is not a constraint problem).
SQL> insert into test values( 3,2,1,1,'asp',1,'mach' );
1 row created.
SQL> begin
2 insert into test values( 3,2,1,1,'asp',1,'mach' );
3 end;
4 /
insert into test values( 3,2,1,1,'asp',1,'mach' );
ERROR at line 2:
ORA-06550: line 2, column 16:
PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated
ORA-06553: PLS-302: component 'DOCUMENT' must be declared
ORA-06550: line 2, column 4:
PL/SQL: SQL Statement ignored
(ddl)
CREATE OR REPLACE type document as object
DOC_ID NUMBER (38),
BATCH_ID NUMBER (38),
STATE NUMBER (2),
TRANSIENT NUMBER (2),
ASP VARCHAR2 (20),
USER_ID NUMBER (6),
MACHINE VARCHAR2 (30),
MEMBER PROCEDURE setState,
MEMBER function getState RETURN NUMBER
) not final;
create table test of document;Hi Adam
You need to instantiate your object type in your insert statement(while doing through PL/SQL block), so try like this
Insert into test values(document(1,2,'CO',55,'xyz','kkk','PENTIUM'));
The reason you were successful through SQLPLUS was that, SQLPLUS automatically instantiate the values into object type.
Qurashi
Maybe you are looking for
-
I understand the value of the time code in projects but am baffled by what it exactly means when I click on a project when it starts off with 10 hours or so, wherever that may come from, and what exactly is its use, except for measuring the time and
-
0EC_PCA_ 1 and balance sheet
Hello Everyone, I am using datasource 0EC_PCA_1 in full load. I have created a balance sheet query (via a hierarchy). My query is showing data incorrectly. In incorrectly I mean the data doesn't look like it has a begining balance, so the numbers
-
Hi All, I have created my business partner with the roles of employee and general bp I ahve also checked that all the fields are filled out just like the one from the default solman bp. But when I ceate a suppot message and I want to assign my bp to
-
Default dml statements.
Hi Everybody, Season Greetings! I've a form using one base table block (multi-record format), lets say I'm creating a new row, Oracle forms builds a Default Insert statement when I commit the transaction. Same as with Update and Delete commands, my q
-
Oracle BPA import model BPM Studio
We cant import BPA models inside BPM Studio 11g. This tool cant 'see' the models inside BPA Server. How we can make this models inside BPA to be converted to BPM Studio 11g? What can be done? Does anyone know any samples or links or tutorials or some