How to insert subtype data from another table in a object table ?
Hi all
I have been looking at the differences answers there are about insert data form a subtype in a object table of a supertype ,but have not found a solution yet.
I hope you can help me.
I my code Action_Logs is the object table and CloseStore_Logs_t is a subtype of Action_Logs_t
My code is
insert into Action_Logs(CloseStore_Logs_t (action_logs_id , physicalstores.physicalstores_id , brandedstores.BRANDEDSTORES_ID ,physicalstores.COMPANIES_ID ,brandedstores.CREATED_BY ,
brandedstores.CREATED_DATE , brandedstores.DELETED ,brandedstores.CLOSED_DATE as brandedstore_closedate,
physicalstores.CLOSED_DATE as physicalstore_closedate)
select CloseStore_Logs_t((null as action_logs_id , physicalstores.physicalstores_id , brandedstores.BRANDEDSTORES_ID ,physicalstores.COMPANIES_ID ,brandedstores.CREATED_BY ,
brandedstores.CREATED_DATE , brandedstores.DELETED ,brandedstores.CLOSED_DATE as brandedstore_closedate,
physicalstores.CLOSED_DATE as physicalstore_closedate)
from physicalstores , brandedstores ,companies
where physicalstores.physicalstores_id = brandedStores.PHYSICALSTORES_ID and
physicalstores.COMPANIES_ID = companies.COMPANIES_ID and
brandedstores.closed_date is not null
oracle gives a ora _917 fault about a missing comma , but I can not se what is wrong.
I will be glad, if you can give me an example with a right syntax where a subtype is selected from other/s tables an inserted in table of its supertype.
kinds regards
steen ostersen
Hi
I see two problems with your statement:
1) The utilization of the values clause is not permitted along with a subquery.
2) The AS are not allowed.
So, something like that should work:
insert into Action_Logs
select CloseStore_Logs_t(null,
physicalstores.physicalstores_id,
brandedstores.BRANDEDSTORES_ID,
physicalstores.COMPANIES_ID,
brandedstores.CREATED_BY,
brandedstores.CREATED_DATE,
brandedstores.DELETED,
brandedstores.CLOSED_DATE,
physicalstores.CLOSED_DATE)
from physicalstores , brandedstores ,companies
where physicalstores.physicalstores_id = brandedStores.PHYSICALSTORES_ID and
physicalstores.COMPANIES_ID = companies.COMPANIES_ID and
brandedstores.closed_date is not null
HTH
Chris
Similar Messages
-
How to insert the data from XML to a table
Hi,
I'm using Oracle 10g Express Edition
I need help in How to insert the data from XML file into the table.
Below is the example i'm working on..
I have create ridb user with below mentioned privileges:
Account Status Locked Unlocked
Default Tablespace: USERS
Temporary Tablespace: TEMP
User Privileges :
Roles:
CONNECT
RESOURCE
Direct Grant System Privileges:
CREATE DATABASE LINK
CREATE MATERIALIZED VIEW
CREATE PROCEDURE
CREATE PUBLIC SYNONYM
CREATE ROLE
CREATE SEQUENCE
CREATE SYNONYM
CREATE TABLE
CREATE TRIGGER
CREATE TYPE
CREATE VIEW
& table is created TRIALZIPCODES below mentioned is the DDL:
CREATE TABLE TRIALZIPCODES
STATE_ABBR VARCHAR2(20) NOT NULL
, ZIP_CODE NUMBER(10, 0) NOT NULL
, ZIP_CODE_EXT VARCHAR2(20)
Below is the XML FILE: which is stored in C:\OracleProject Folder
File name: trial.xml
<?xml version="1.0" ?>
<metadata>
- <Zipcodes>
- <mappings Record="4">
<STATE_ABBREVIATION>CA</STATE_ABBREVIATION>
<ZIPCODE>94301</ZIPCODE>
</mappings>
- <mappings Record="5">
<STATE_ABBREVIATION>CO</STATE_ABBREVIATION>
<ZIPCODE>80323</ZIPCODE>
<ZIP_CODE_EXTN>9277</ZIP_CODE_EXTN>
</mappings>
</Zipcodes>
</metadata>
PL/SQL Procedure:which i'm trying to execute from SQLDeveloper
create or replace
PROCEDURE TRIAL AS
BEGIN
DECLARE
-- declare attributes
charString varchar2(80);
finalStr varchar2(4000) := null;
rowsp integer;
v_FileHandle UTL_FILE.FILE_TYPE;
l_context_handle dbms_xmlgen.ctxHandle;
insCtx DBMS_XMLStore.ctxType;
begin
-- DBMS_XMLGEN.setRowTag ( ctx IN ctxHandle, rowTag IN VARCHAR2);
-- DBMS_XMLGEN.setRowSetTag ( ctx IN ctxHandle, rowSetTag IN VARCHAR2);
-- the name of the table as specified in our DTD
DBMS_XMLGEN.SETROWSETTAG(l_context_handle,'zipcodes');
-- the name of the data set as specified in our DTD
DBMS_xmlgen.setRowTag(l_context_handle,'mappings');
-- for getting the output on the screen
dbms_output.enable(1000000);
-- open the XML document in read only mode
v_FileHandle := utl_file.fopen('c:/OracleProject','trial.xml', 'r');
loop
BEGIN
utl_file.get_line(v_FileHandle, charString);
exception
when no_data_found then
utl_file.fclose(v_FileHandle);
exit;
END;
dbms_output.put_line(charString);
if finalStr is not null then
finalStr := finalStr || charString;
else
finalStr := charString;
end if;
end loop;
-- for inserting the XML data into the table
insCtx := DBMS_XMLSTORE.NEWCONTEXT('RIDB.TRIALZIPCODES');
insCtx := DBMS_XMLSTORE.INSERTXML(insCtx, finalStr);
dbms_output.put_line('INSERT DONE '||TO_CHAR(rowsp));
DBMS_XMLStore.closeContext(insCtx);
END;
END TRIAL;
For the first time when i complied i got the errors as :
Procedure RIDB.PROCEDURE1@RIDB
Error(16,14): PLS-00201: identifier 'UTL_FILE' must be declared
Error(16,14): PL/SQL: Item ignored
Error(29,1): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(29,1): PL/SQL: Statement ignored
Error(33,1): PL/SQL: Statement ignored
Error(33,19): PLS-00320: the declaration of the type of this expression is incomplete or malformed
Error(36,1): PL/SQL: Statement ignored
Error(36,17): PLS-00320: the declaration of the type of this expression is incomplete or malformed
So i logged in as sys & grant the permission to execute on UTL_FILE to ridb (user):
SQL Statement:
grant execute on utl_file to ridb
So, it got compiled successfully but when i execute it gives me error as:
Source does not have a runnable target.
What does this mean?
So I browse through forum & i got to know that i need to initial the UTL_FILE_DIR ="C:/OracleProject" in init.ora
So can i edit the init.ora with notepad.When i tried to do that it says permission denied
In my system it shows the init.ora file in path C:\oraclexe\app\oracle\product\10.2.0\server\config\scripts
but there is also other file initXETemp in the same path do i need to do the changes in it.
I have tried even editing the SPFILE as mentioned below:
C:\oraclexe\app\oracle\product\10.2.0\server\dbs\SPFILEEXE - I had edit this file using notepad & set the value of UTL_FILE_DIR ="C:/OracleProject". So next time when i restarted i'm unable to log on to the database.
So i had reinstall the software again.
Could you please let me know how to proceed..hi,
I have created the directory from sys database
CREATE or replace DIRECTORY XML_DIR2 AS 'C:\OracleProject';
& grant read,write access to the user
grant read,write on directory XML_DIR2 to RIDB;
& i had change the tag name in the xml file as shown below:
<?xml version = '1.0'?>
<metadata>
<Zipcodes>
<mappings Record="4">
<STABBRE>CA</STABBRE>
<ZIPCODE>94301</ZIPCODE>
</mappings>
<mappings Record="5">
<STABBRE>CO</STABBRE>
<ZIPCODE>80323</ZIPCODE>
<ZIPCODEEXT>9277</ZIPCODEEXT>
</mappings>
</Zipcodes>
</metadata>
TRIALZIPCODE table as shown below:
CREATE TABLE "RIDB"."TRIALZIPCODE"
( "STABBRE" VARCHAR2(20 BYTE),
"ZIPCODE" NUMBER(*,6) NOT NULL ENABLE,
"ZIPCODEEXT" NUMBER
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ;
I have tried two methods as shown below:
Procedure 1:
create or replace
PROCEDURE TRIAL_V2 AS
BEGIN
DECLARE
-- declare attributes
charString varchar2(80);
finalStr varchar2(4000) := null;
rowsp integer;
v_FileHandle UTL_FILE.FILE_TYPE;
l_context_handle dbms_xmlgen.ctxHandle;
insCtx DBMS_XMLStore.ctxType;
cnt NUMBER;
xmldoc xmltype := xmltype( bfilename('XML_DIR2','trialxml.xml'), nls_charset_id('AL32UTF8') );
--XML_DIR VARCHAR2(40) := 'C:\\OracleProject';
BEGIN
insCtx := DBMS_XMLStore.newContext('DEV.TRIALZIPCODES');
DBMS_XMLStore.setUpdateColumn(insCtx, 'STABBRE');
DBMS_XMLStore.setUpdateColumn(insCtx, 'ZIPCODE');
DBMS_XMLStore.setUpdatecolumn(insCtx, 'ZIPCODEEXT');
DBMS_XMLStore.setRowTag(insCtx, 'mappings');
cnt := DBMS_XMLStore.insertXML(insCtx, xmldoc);
DBMS_XMLStore.closeContext(insCtx);
END;
Procedure 1 was compiled with out errors but when i execute i got the error as :
Source does not have a runnable target.
Procedure 2_
CREATE OR REPLACE PROCEDURE TRIAL_V3 AS
BEGIN
DECLARE
-- declare attributes
charString varchar2(80);
finalStr varchar2(4000) := null;
rowsp integer;
v_FileHandle UTL_FILE.FILE_TYPE;
l_context_handle dbms_xmlgen.ctxHandle;
insCtx DBMS_XMLStore.ctxType;
cnt NUMBER;
xmldoc xmltype := xmltype( bfilename('XML_DIR2','trialxml.xml'), nls_charset_id('AL32UTF8') );
--XML_DIR VARCHAR2(40) := 'C:\\OracleProject';
BEGIN
INSERT INTO trialzipcode (STABBRE, ZIPCODE, ZIPCODEEXT)
SELECT extractvalue(x.column_value, 'mappings/STABBRE'),
extractvalue(x.column_value, 'mappings/ZIPCODE'),
extractvalue(x.column_value, 'mappings/ZIPCODEEXT')
FROM TABLE(
XMLSequence(
EXTRACT(
xmltype( bfilename('XML_DIR2','trialxml.xml'), nls_charset_id('AL32UTF8') ),
'metadata/Zipcodes/mappings'
) x
END;
END TRIAL_V3;
Procedure 2 was complied without errors but when i execute i got the error as:
Connecting to the database RIDB.
ORA-22288: file or LOB operation FILEOPEN failed
The system cannot find the file specified.
ORA-06512: at "SYS.DBMS_LOB", line 523
ORA-06512: at "SYS.XMLTYPE", line 287
ORA-06512: at "RIDB.TRIAL_V3", line 12
ORA-06512: at line 2
Process exited.
Disconnecting from the database RIDB.
Could you please let me know how to proceed... -
How can i get data from another database SQL Server use database link from
I have a database link from Oracle connect to SQL Server database with user cdit connect default database NorthWind.How can I get data from another database(this database in this SQL Server use this database link)?
hi,
u should see following documentation:
Oracle9i Heterogeneous Connectivity Administrator's Guide
Release 1 (9.0.1)
Part Number A88789_01
in it u just go to chapter no. 4 (using the gateway),,u'll find ur answer there.
regards
umar -
How to insert 300 data from associative array to backend table in PL/SQL
HI ALL,
I'm posting my code here:
Creating back end table:
Create table orlando
( id number(20),
calltype number(12),
gateway_name varchar2(25),
accounting_id varchar2(18),
start_time_system_ticks number(11),
node_time_zone varchar2(25),
start_date varchar2(10),
start_time varchar2(10),
softswitch_response number(11),
alerting number(11)
Creating package:
CREATE OR REPLACE PACKAGE r IS
type apollo_rec is record(
id number(20),
calltype number(12),
gateway_name varchar2(25),
accounting_id varchar2(18),
start_time_system_ticks number(11),
node_time_zone varchar2(25),
start_date varchar2(10),
start_time varchar2(10),
softswitch_response number(11),
alerting number(11)
TYPE bin_array IS TABLE OF apollo_rec INDEX BY BINARY_INTEGER;
PROCEDURE rr (state_array bin_array);
END ;
SET SERVEROUT ON
CREATE OR REPLACE PACKAGE BODY r IS
PROCEDURE rr (state_array bin_array) IS
BEGIN
FOR i IN 1 .. state_array.COUNT LOOP
INSERT INTO orlando(id,calltype,gateway_name,accounting_id,start_time_system_ticks)VALUES(state_array(i).id,state_array(i).calltype,state_array(i).gateway_name,
state_array(i).accounting_id,state_array(i).start_time_system_ticks);
COMMIT;
END LOOP;
END ;
END ;
I've run this code in i*SQL PLUS.But when I run this code for 5 entries there is no error but when I modify the insert statement for 300 entries(300 identifiers in the insert statement)
it gives me error:
Warning: Package Body created with compilation errors.
Errors for PACKAGE BODY R:
LINE/COL ERROR
7/2 PL/SQL: SQL Statement ignored
7/14 PL/SQL: ORA-00913: too many values
Is there any feature in PL/SQL to decrease the entries in insert statement and make the insert statement along with the program small and increase the program performance.
Edited by: 983040 on Jan 20, 2013 11:11 PMBasic example (ran on 11.2.0.3):
SQL> create table testtab( id number, day date, val varchar2(30) );
Table created.
SQL>
SQL> create or replace package TestTabLib as
2
3 type TTestTab is table of testtab%rowtype;
4
5 procedure InsertRows( rowArray TTestTab );
6
7 end;
8 /
Package created.
SQL>
SQL> create or replace package body TestTabLib as
2
3 procedure InsertRows( rowArray TTestTab ) is
4 begin
5 forall i in 1..rowArray.Count
6 insert into testtab values rowArray(i);
7 end;
8
9 end;
10 /
Package body created.
SQL>
SQL> declare
2 rowArray TestTabLib.TTestTab;
3 begin
4 --// populating the array - using a bulk fetch as
5 --// an example
6 select
7 object_id, created, object_name
8 bulk collect into
9 rowArray
10 from all_objects
11 where rownum < 11;
12
13 --// bulk insert array
14 TestTabLib.InsertRows( rowArray );
15 end;
16 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from testtab;
ID DAY VAL
100 2011/12/05 09:16:03 ORA$BASE
116 2011/12/05 09:16:04 DUAL
117 2011/12/05 09:16:04 DUAL
280 2011/12/05 09:19:09 MAP_OBJECT
365 2011/12/05 09:19:10 SYSTEM_PRIVILEGE_MAP
367 2011/12/05 09:19:10 SYSTEM_PRIVILEGE_MAP
368 2011/12/05 09:19:10 TABLE_PRIVILEGE_MAP
370 2011/12/05 09:19:11 TABLE_PRIVILEGE_MAP
371 2011/12/05 09:19:11 STMT_AUDIT_OPTION_MAP
373 2011/12/05 09:19:11 STMT_AUDIT_OPTION_MAP
10 rows selected.
SQL>
SQL> declare
2 rowArray TestTabLib.TTestTab;
3 begin
4 --// populating the array - using a custom build
5 --// loop example such as a Java front-end will
6 --// use reading data from user input form
7 rowArray := new TestTabLib.TTestTab();
8 rowArray.Extend(2); --// user entered 2 values
9 for i in 1..rowArray.Count loop
10 rowArray(i).id := i;
11 rowArray(i).day := trunc(sysdate);
12 rowArray(i).val := 'value '||to_char(i,'000');
13 end loop;
14
15 --// bulk insert array
16 TestTabLib.InsertRows( rowArray );
17 end;
18 /
PL/SQL procedure successfully completed.
SQL>
SQL> select * from testtab where val like 'value%';
ID DAY VAL
1 2013/01/21 00:00:00 value 001
2 2013/01/21 00:00:00 value 002
SQL> -
How to insert test data of 10,000 records into emp table
Hi I'm new to oracle can anyone please help me in writing a program so that i can insert test data into emp table
Hi,
user11202607 wrote:
thanks sanjay , frank . But how can i insert only 4 deptno's randomly and how can i insert only 10 managers randomly ,
Sorry to pull Your legs and thanks for bearing my question. I want to insert into emp table where it has the empno, ename, sal, job, hiredate, mgr and deptnoThis should give you some ideas:
INSERT INTO emp (empno, ename, sal, job, hiredate, mgr, deptno)
SELECT LEVEL -- empno
, dbms_random.string ('U', 4) -- ename
, ROUND ( dbms_random.value (100, 5000)
, -2
) -- sal
, CASE
WHEN LEVEL = 1 THEN 'PRESIDENT'
WHEN LEVEL <= 4 THEN 'MANAGER' -- Change to 11 after testing
WHEN dbms_random.value < .5 THEN 'ANALYST'
WHEN dbms_random.value < .5 THEN 'CLERK'
ELSE 'SALESMAN'
END -- job
, TRUNC ( SYSDATE
- dbms_random.value (0, 3650)
) -- hiredate
, CASE
WHEN LEVEL > 1
THEN TRUNC (dbms_random.value (1, LEVEL))
END -- mgr
, TRUNC (dbms_random.value (1, 5)) -- deptno
FROM dual
CONNECT BY LEVEL <= 10 -- Change to 10000 after testing
;The interesting part (to me, at least) is mgr. What I've done above is guarantee that the mgr-empno relationship reflects a tree, with the 'PRESIDENT' at its sole root. The tree can be any number of levels deep.
Sample results:
EMPNO ENAME SAL JOB HIREDATE MGR DEPTNO
1 GDMT 2800 PRESIDENT 30-AUG-04 2
2 CVQX 400 MANAGER 24-MAY-06 1 2
3 QXJD 1300 MANAGER 17-JUN-05 1 4
4 LWCK 4800 MANAGER 15-JUN-06 2 2
5 VDKI 3700 CLERK 08-SEP-01 4 2
6 FKZS 2600 CLERK 18-DEC-06 4 1
7 SAKB 700 ANALYST 30-JUN-00 5 4
8 DVYY 300 ANALYST 22-SEP-01 2 1
9 CLEO 2700 ANALYST 27-MAY-08 5 4
10 RDVQ 3400 ANALYST 14-DEC-08 5 4For details on the built-in packages (such as dbms_random) see the [Parckages and Types manual|http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_random.htm#i998925]. -
How to get parents data from a leaf in a recursive table
I want to get a list of all parents data related to a leaf in a table.
The table has 3 rows id, description, parent.
if I have the id of one of this items I want to get all his parents, is there a way to get this with a select or with connect by prior?Maybe
select substr(sys_connect_by_path(to_char(empno),','),2) parant_chain
from emp
where connect_by_isleaf = 1
start with empno = 7369
connect by empno = prior mgr
PARANT_CHAIN
7369,7902,7566,7839
Regards
Etbin -
How to get the data from the model node like a table ?
I want to get the data from the model node once a record ,and the node is bound to a internal table in the RFM which I called in the R/3 system. Who can give me some advice to achive it?Thank you!!
Hi,
To get the data from the node:
wdContext.node[your node name].current[node name]_InputElement().get[specific element in the node];
or you van use:
wdContext.current[your node]Element().get[your element in the node];
examples:
wdContext.nodeZ_Mepro_Po_Detail_Stock_Distri_Input().currentZ_Mepro_Po_Detail_Stock_Distri_InputElement().getUcpd_Flag();
wdContext.currentT_Delv_ReqsElement().getShelflife();
regards, -
How do I access data from another class?
I have a class RailNetwork which extends Datastore. DataStore contains a vector filelines which I need to access from RailNetwork. How do I do this? What do I put infront of filelines.get(i); ?
public abstract class DataStore
{ Vector<String> fileLines = new Vector<String>(); }
public class RailNetwork extends DataStore
{ ...main(){ .......filelines.get(i);....... }
}This is the code from RailNetwork class:
public static void main(String[] args) {
String templine;
int i = 0;
int vectorlength = super.filelines.size();
for( i = 0 ; i < vectorlength ; i++ )
templine = (String) super.filelines.get(i);
setStations(templine); }The errors (for both lines, only 1 shown):
RailNetwork.java:49: non-static variable super cannot be referenced from a static context
templine = (String) super.filelines.get(i);
^
RailNetwork.java:49: cannot find symbol
symbol : variable filelines
location: class DataStore
templine = (String) super.filelines.get(i);
^ -
How can we read data from spread sheet using RowSet Object ??
Please give some sample code for this...
Urgent requirement....please....http://java.sun.com/developer/Books/JDBCTutorial/chapter5.html
�I sense many useless updates in you... Useless updates lead to defragmentation... Defragmentation leads to downtime...Downtime leads to suffering..Defragmentation is the path to the darkside.. DBCC INDEXDEFRAG and DBCC DBREINDEX are the force...May the force be with you" --
http://sqlservercode.blogspot.com/ -
How can I migrate data from SQL Server 6,5 to Oracle 8?
We have a web site based on Microsoft SQL Server 6.5.Now we plan
to migrate the database to Oracle 8.
We have redesigned the tables structure and created tables under
Oracle 8, so we only need to migrate data from SQL Server.
We've exported data from SQL Server to text files.
How can we import data from files and restore to Oracle tables.
Is there a solution which let us to import data for particular
table columns,not all columns?
We'll be appreciated if somene can give suggestions.
Regards
Michael
nullThank you for your reply.
I'll try the Oracle sqlloader utility first.
Regards
Micahel
Oracle Migration Workbench Team wrote:
: Michael,
: Oracle sqlloader is user for this sort of operation, see
: Oracle8i Utilities
: Release 8.1.5
: A67792-01
: available online through Oracle Technology Network.
: The Oracle Migration Workbench can be used to create bcp and
: sqlloader scripts, though since you have altered the schema
these
: scripts would need to be altered by hand after generation.
: Some thought has been put into redesigning table structures in
: the Oracle Migration Workbench, but currently it looks like
this
: reengineering will be left to be done by other tools, eg
Oracle
: Designer, once the SQLServer database has been duplicated with
as
: little change as possible onto Oracle.
: Hope that helps,
: Turloch
: Oracle Migration Workbench Team
: Michael (guest) wrote:
: : We have a web site based on Microsoft SQL Server 6.5.Now we
: plan
: : to migrate the database to Oracle 8.
: : We have redesigned the tables structure and created tables
: under
: : Oracle 8, so we only need to migrate data from SQL Server.
: : We've exported data from SQL Server to text files.
: : How can we import data from files and restore to Oracle
tables.
: : Is there a solution which let us to import data for
particular
: : table columns,not all columns?
: : We'll be appreciated if somene can give suggestions.
: : Regards
: : Michael
: Oracle Technology Network
: http://technet.oracle.com
null -
How to insert select columns from one internal table to another
Hi,
How to insert select columns from one internal table to another based on condition as we do from a standart table to internal table.
regards,
SriramHi,
If your question is for copying data from 1 int table to other ;
we can use
APPEND LINES OF it_1 TO it_2.
or if they have different columns then:
loop at it_1 into wa_it1.
move wa_it1-data to wa_it2-d1.
apped wa_it2 to it_2.
clear wa_it2.
endloop.
thnxz -
How can I Move data from one column to another in my access table?
I have two columns, one that stores current month’s data and one that stores last month’s data. Every month data from column 2 (this month’s data) needs to be moved to column 1 that holds last month’s data. I then null out column 2 so I can accumulates this month’s data.
I understand how to drop a column or add a column, how do I transfer data from one column to another.
Here is my trial code:
<cfquery name="qQueryChangeColumnName" datasource="#dsn#">
ALTER TABLE leaderboard
UPDATE leaderboard SET points2 = points3
</cfquery>
Unfortunately, I get the following error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Syntax error in ALTER TABLE statement.
How can I transfer my data with the alter table method?I looked up the Access SQL reference (which is probably a
good place to start when having issues with Access SQL), and
it suggests you probably need a WHERE clause in there.
I agree the documentation is a good place to start. But you should not need a WHERE clause here.
Too few parameters. Expected 1.
If you run the SQL directly in Access, what are the results? At the very least, it should provide a more informative error message.. -
How do i transfer data from one internal tabe to another.
Hi All,
How do i transfer data from one internal tabe to another.
Can i do it ebven if he tables are different in structure.
Please Advice.
Thanks in advance.Hi Saket Tiwari,
I hope the earlier post by kashyap is good enough an answer. anywas in addition to it let me give a detailed
explanation of how you can populate an internal table.
1) Append data line by line.
Syntax : APPEND [<wa> TO / INITIAL LINE TO] <itab>.
this appends new line to internal table <itab>.
2) Using COLLECT statement.
COLLECT is another form of statement used for populating the internal tables. Generally COLLECT is used while inserting lines into an internal table with unique standard key. The syntax for COLLECT statement is as shown
Syntax : COLLECT [<wa> INTO] <itab>.
3) Using INSERT statement
Syntax INSERT [<wa> INTO / INITIAL LINE INTO] <itab> [index <idx>].
INSERT statement adds a line/work area to the internal table. You can specify the position at which the new line is to be added by using the INDEX clause with the INSERT statement.
Now coming to your request..
To append part or all of an internal table
Syntax
APPEND LINES OF <itab1> [FROM <n1>] [TO <n2>] TO <itab2>.
* Note:
Without the FROM and TO options, this statement appends the entire table <itab1> to <itab2>.*
b) To insert part or all of an internal table into another internal table
Syntax
INSERT LINES OF <itab1> [FROM <n1>] [TO <n2>]
INTO <itab2> [INDEX <idx>].
c) Using Move statement.
To copy entire contents of one table into another in one execution
Syntax MOVE <itab1> To <itab2>.
OR
<itab1> = <itab2>.
but u hav to be careful because he contents of itab2 will eb overwritten on the execution of this statement.
These copy the contents of ITAB1 to ITAB2. Incase of internal tables with header line we have to use [] inorder to distinguish from work area. So, to copy contents of internal tables with header line the syntax becomes,
ITAB1[] = ITAB2[].
Coming to the letter part of your question, Yes, we can copy values between tables having different structures.
for this we use
MOVE-CORRESPONDING <itab1> TO <itab2>
this executes the statement for their header lines. Searches for the sub-fields which occur both in itab1 and itab2 and then generates, for all relevant field pairs which correspond to the
sub-fields ni , statements of the form MOVE itab1-ni TO itab2-ni. The other fields remain unchanged.
I hope the information provided has been of your help.
Reward if useful.
Regards,
Jose -
How to retrieve multiple data from table and represent it in jsp page
Hi
The below JavaScript code is used to add row in the table when I want to add multiple row data into table for single entry no field.
<html> function addRow()
i++;
var newRow = document.all("tblGrid").insertRow();
var oCell = newRow.insertCell();
oCell.innerHTML = "<input name='srno"+i+"' type='text' id='srno"+i+"' size=10>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='itmcd"+i+"' type='text' id='itmcd"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='itmnm"+i+"' type='text' id='itmnm"+i+"' size='15'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='indentqty"+i+"' type='text' id='indentqty"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='uom"+i+"' type='text' id='uom"+i+"' size='10'><input type='hidden' name='mcode"+i+"'id='mcode"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='packqty"+i+"' type='text' id='packqty"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='packuom"+i+"' type='text' id='packuom"+i+"' size='10'><input type='hidden' name='pack"+i+"' id='pack"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='rate"+i+"' type='text' id='rate"+i+"' size='10'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='dor"+i+"' type='text' id='dor"+i+"' size='0' onClick='"+putdate(this.name)+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='bccode"+i+"' type='text' id='bccode"+i+"' size='10'></td><input type='hidden' name='bcc"+i+"' id='bcc"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='cccode"+i+"' type='text' id='cccode"+i+"' size='10'></td><input type='hidden' name='ccc"+i+"' id='ccc"+i+"'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input name='remark2"+i+"' type='text' id='remark2"+i+"' size='20'>";
oCell = newRow.insertCell();
oCell.innerHTML = "<input type='button' value='Delete' onclick='removeRow(this);' />";
// oCell = newRow.insertCell();
// oCell.innerHTML = "<input type='button' value='Clear' onclick='clearRow(this);' />";
}<html> Then this data are send to the next Servlet for adding into two table.
My header portion data are added into one table which added only one row in table. while footer section data are added into the no of rows in another table dependent on No. of
Rows added into jsp page.
Here is an code for that logic.
<html>
ArrayList<String> mucode = new ArrayList<String>();
ArrayList<Integer> serials = new ArrayList<Integer>();
ArrayList<Integer> apxrate = new ArrayList<Integer>();
ArrayList<Integer> srname = new ArrayList<Integer>();
ArrayList<String> itcode = new ArrayList<String>();
ArrayList<String> itname = new ArrayList<String>();
ArrayList<Integer> iqnty = new ArrayList<Integer>();
ArrayList<String> iuom = new ArrayList<String>();
ArrayList<Integer> pqnty = new ArrayList<Integer>();
ArrayList<String> puom1 = new ArrayList<String>();
ArrayList<Integer> arate = new ArrayList<Integer>();
ArrayList<String> rdate = new ArrayList<String>();
ArrayList<String> bcs = new ArrayList<String>();
ArrayList<String> ccs = new ArrayList<String>();
ArrayList<String> remarkss = new ArrayList<String>();
//ArrayList<Integer> qtyrecs = new ArrayList<Integer>();
//ArrayList<String> dors = new ArrayList<String>();
//ArrayList<String> remarks = new ArrayList<String>();
String entryn = request.getParameter("entryno");
String rows = request.getParameter("rows");
out.println(rows);
//String Entryno = request.getParameter("entryno");
// out.println(Entryno);
int entryno = 0,reqqty = 0,srno = 0,deprequest = 0,rowcount = 0;
if(!Entryno.equals("")){
entryno = Integer.valueOf(Entryno);
if(!rows.equals("")){
rowcount = Integer.valueOf(rows);
for(int i=1;i<=rowcount;i++){
if(request.getParameter("srno"+i)!=null){
serials.add(Integer.valueOf(request.getParameter("srno"+i).trim()));
out.println(serials.size());
for(int i=1;i<=rowcount;i++){
if(request.getParameter("srno"+i)!=null){
srname.add(Integer.valueOf(request.getParameter("srno"+i).trim()));
out.println(srname.get(0));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("itmcd"+i)!=null){
itcode.add(request.getParameter("itmcd"+i).trim());
} //out.println(itcode.get(i));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("itmnm"+i)!=null){
itname.add(request.getParameter("itmnm"+i).trim());
}//out.println(itname.get(i));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("indentqty"+i)!=null){
iqnty.add(Integer.valueOf(request.getParameter("indentqty"+i).trim()));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("uom"+i)!=null){
iuom.add(request.getParameter("uom"+i).trim());
}//out.println(iuom.get(i));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("mcode"+i)!=null){
mucode.add(request.getParameter("mcode"+i).trim());
for(int i=1;i<=rowcount;i++){
if(request.getParameter("packqty"+i).equals("")){
pqnty.add(0);
}else
pqnty.add(Integer.valueOf(request.getParameter("packqty"+i).trim()));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("pack"+i)!=null){
puom1.add(request.getParameter("pack"+i).trim());
}else
puom1.add("");
for(int i=1;i<=rowcount;i++){
if(request.getParameter("rate"+i).equals("")){
arate.add(0);
}else
arate.add(Integer.valueOf(request.getParameter("rate"+i).trim()));
/* for(int i=1;i<=rowcount;i++){
if(request.getParameter("rate"+i)!=null){
arate.add(Integer.valueOf(request.getParameter("rate"+i).trim()));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("dor"+i)!=null){
try{
rdate.add(dashdate.format(slashdate.parse(request.getParameter("dor"+i).trim())));
}catch(ParseException p){p.printStackTrace();}
}else
{ rdate.add("");}
for(int i=1;i<=rowcount;i++){
if(request.getParameter("bcc"+i)!=null){
bcs.add(request.getParameter("bcc"+i).trim());
}out.println(bcs.get(0));
for(int i=1;i<=rowcount;i++){
if(request.getParameter("ccc"+i)!=null){
ccs.add(request.getParameter("ccc"+i).trim());
}out.println(ccs.get(0));
for(int i=1;i<=rowcount;i++){
out.println("remark2");
if(request.getParameter("remark2"+i)!=null){
remarkss.add(request.getParameter("remark2"+i).trim());
}out.println(remarkss.get(0));
ArrayList<String> Idate = new ArrayList<String>();
for(int i=1;i<=rowcount;i++){
if(request.getParameter("dateindent"+i)!=null){
try{
Idate.add(dashdate.format(dashdate.parse(request.getParameter("dateindent"+i).trim())));
}catch(ParseException p){p.printStackTrace();}
String Rdate = dashdate.format(new java.util.Date());
String tdate = dashdate.format(new java.util.Date());
// String Indentdate = dashdate.format(new java.util.Date());
// String ApprovedT1 = dashdate.format(new java.util.Date());
// String ApprovedT2 = dashdate.format(new java.util.Date());
// String ApprovedT1=" ";
//String ApprovedT2="";*/
String ApprovedT1= dashdate.format(new java.util.Date());
out.println (ApprovedT1);
String ApprovedT2=dashdate.format(new java.util.Date());
out.println(ApprovedT2);
String Indentdate=(dashdate.format(slashdate.parse(request.getParameter("dateindent").trim())));
out.println(Indentdate);
String Cocode ="BML001";
out.println(Cocode);
String Deptcode = request.getParameter("dept1");
out.println(Deptcode);
String Empcode = request.getParameter("emp");
out.println(Empcode);
String Refno =request.getParameter("rtype");
out.println(Refno);
String Divcode = request.getParameter("todiv1");
out.println(Divcode);
String Usercode = "CIRIUS";
String Whcode = request.getParameter("stor");
out.println(Whcode);
// String Itemgroupcode = request.getParameter("");
String Itemgroupcode ="120000";
out.println(Itemgroupcode);
String Supplytypecode = request.getParameter("stype");
out.println(Supplytypecode);
String Delcode = request.getParameter("deliverycode");
out.println(Delcode);
String Itemclass="WS";
out.println(Itemclass);
// String Itemclass = request.getParameter("iclass");
// out.println(Itemclass);
String unitcode = request.getParameter("uni");
out.println(unitcode);
String Todivcode = request.getParameter("todiv1");
out.println(Todivcode);
String Appxrate = request.getParameter("rate");
out.println(Appxrate);
String Srno = request.getParameter("srno");
out.println(Srno);
/* String Indqty = request.getParameter("indentqty");
out.println(Indqty);*/
String Itemcode = request.getParameter("itmcd");
out.println(Itemcode);
String Othersp = request.getParameter("remark1");
out.println(Othersp);
String Reqdt = request.getParameter("dor");
out.println(Reqdt);
String Munitcode = request.getParameter("mcode");
out.println(Munitcode);
String Packqty = request.getParameter("packqty");
out.println(Packqty);
String Packuom = request.getParameter("pack");
out.println(Packuom);
String Remark2 = request.getParameter("remark2");
out.println(Remark2);
String BC = request.getParameter("bcc");
out.println(BC);
String CC = request.getParameter("ccc");
out.println(CC);
try{
st=connection.createStatement();
connection.setAutoCommit(false);
String sql="INSERT INTO PTXNINDHDR(COCODE,DEPTCODE,EMPCODE,APPROVEDT1,APPROVEDT2,INDDT,ENTRYNO,REFNO,REMARKS,DIVCODE,USERCODE,WHCODE,ITEMGROUPCODE,SUPTYPECODE,DELCODE,UNITCODE,TODIVCODE,ITEMCLASS)VALUES('"+Cocode+"','"+Deptcode+"','"+Empcode+"','"+ApprovedT1+"','"+ApprovedT2+"','"+Indentdate+"',"+Entryno+",'"+Refno+"','"+Othersp+"','"+Divcode+"','"+Usercode+"','"+Whcode+"','"+Itemgroupcode+"','"+Supplytypecode+"','"+Delcode+"','"+unitcode+"','"+Todivcode+"','"+Itemclass+"')";
out.println(sql);
st.addBatch(sql);
for(int i=0;i<serials.size();i++){
out.println("Inside the Statement");
String query3="test query for u";
out.println(query3);
String queryx="Insert into PTXNINDDTL(APXRATE,ENTRYNO,BRKNO,INDQTY,ITEMCODE,OTHERSPFCS,MUNITCODE,PACKQTY,PACKUOM,REMARKS,DIMSUBGRPCODE,DIMCODE,REQDT)VALUES("+arate.get(i)+","+entryno+","+srname.get(i)+","+iqnty.get(i)+","+itcode.get(i)+",'"+Othersp+"','"+mucode.get(i)+"',"+pqnty.get(i)+",'"+puom1.get(i)+"','"+remarkss.get(i)+"','"+bcs.get(i)+"','"+ccs.get(i)+"','"+rdate.get(i)+"')";
out.println(queryx);
st.addBatch(queryx);
int[] result=st.executeBatch();
connection.commit();
for(int k=0;k<result.length;k++)
out.println("rows updated by "+(k+1)+"insert sta:"+result[k]+"");
catch(BatchUpdateException bue)
out.println("error1;"+bue+"");
catch(SQLException sql)
out.println("error2;"+sql+"");
catch(Exception l)
out.println("error3;"+l+"");
</html>
Now I looking for to retrieve this footer section data available in multiple rows from footer table and present it in jsp page .
I am finding difficulties in how to show this multiple row data for dynamic no of rows .i.e. variable no. of rows.
I have able to show the data in Header portions of page in this ways
here i am adding the part of code which shows the data from header part of table i.e from Header table
<html>
<h2 align="center"><b>Indent Preparation</b></h2>
<div align="left">
<table width="849" border="0" cellspacing="3" cellpadding="3" align="center">
<tr>
<td ><div align="left"><b>Indent No.</b></div></td>
<td ><label>
<input name="indentno" type="text" id="indentno" size="15" value="" /><input type="hidden" name="no" id="no">
</label></td>
<td ><div align="center"><strong>Indent Date</strong></div></td>
<td ><label>
<div align="center">
<input name="dateindent" type="text" id="dateindent"value="<%=date1%>"/><input type="hidden" name="no" id="no">
</div>
</label></td>
<td> </td>
<td><div align="right"><strong>Entry No.</strong></div></td>
<%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
<td><input type="text" value="<%=hdrcode.get(3)%>" size="10"></td>
<%}else{%>
<td><input type="text" name="entryno" id="entryno" value="<%=entryNo%>"/></td>
<%}%>
<div align="right"></div>
</tr>
<tr>
<td><b>Division</b></td>
<%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
<td><input type="text" value="<%=hdrdetails.get(9)%>" size="20"</td>
<td><input type="hidden" name="div1" id="div1" value='<%=hdrcode.get(10)%>'></td>
<%}else{%>
<td><input type="text" name="div" id="div" /></td>
<td><input type="hidden" name="div1" id="div1" /> </td>
<%}%>
<td> </td>
<td> </td>
<td><div align="right"><strong>Unit</strong></div></td>
<%if(oper!=null && oper.equals("view") && hdrcode!=null && hdrdetails!=null){%>
<td><input type="text" value="<%=hdrdetails.get(14)%>" size="20"</td>
<td><input type="hidden" name="uni" id="uni" value='<%=hdrcode.get(12)%>'></td>
<%}else{%>
<td><input type="text" name="unit" id="unit" /></td>
<td><input type="hidden" name="uni" id="uni" /> </td>
<%}%>
</tr>
<tr>
</html>
Any suggestion on any above works is highly appreciated.
Thanks and regards
harshalToo much code. It's also not well intented nor formatted. I don't see a question either or it got lost in that heap of unformatted code.
I will only answer the question in the thread's subject:
How to retrieve multiple data from table and represent it in jsp pageTo retrieve, make use of HttpServletRequest#getParameterValues() and/or #getParameter().
To display, make use of JSTL's c:forEach. -
How to display data from a recordset based on data from another recordset
How to display data from a recordset based on data from
another recordset.
What I would like to do is as follows:
I have a fantasy hockey league website. For each team I have
a team page (clubhouse) which is generated using PHP/MySQL. The one
area I would like to clean up is the displaying of the divisional
standings on the right side. As of right now, I use a URL variable
(division = id2) to grab the needed data, which works ok. What I
want to do is clean up the url abit.
So far the url is
clubhouse.php?team=Wings&id=DET&id2=Pacific, in the end all
I want is clubhouse.php?team=Wings.
I have a separate table, that has the teams entire
information (full team name, short team, abbreviation, conference,
division, etc. so I was thinking if I could somehow do this:
Recordset Team Info is filtered using URL variable team
(short team). Based on what team equals, it would then insert this
variable into the Divisional Standings recordset.
So example: If I type in clubhouse.php?team=Wings, the Team
Info recordset would bring up the Pacific division. Then 'Pacific'
would be inserted into the Divisional Standings recordset to
display the Pacific Division Standings.
Basically I want this
SELECT *
FROM standings
WHERE division = <teaminfo.division>
ORDER BY pts DESC
Could someone help me, thank you.Assuming two tables- teamtable and standings:
teamtable - which has entire info about the team and has a
field called
"div" which has the division name say "pacific" and you want
to use this
name to get corresponding details from the other table.
standings - which has a field called "division" which you
want to use to
give the standings
SELECT * FROM standings AS st, teamtable AS t
WHERE st.division = t.div
ORDER BY pts DESC
Instead of * you could be specific on what fields you want to
select ..
something like
SELECT st.id AS id, st.position AS position, st.teamname AS
team
You cannot lose until you give up !!!
"Leburn98" <[email protected]> wrote in
message
news:[email protected]...
> How to display data from a recordset based on data from
another recordset.
>
> What I would like to do is as follows:
>
> I have a fantasy hockey league website. For each team I
have a team page
> (clubhouse) which is generated using PHP/MySQL. The one
area I would like
> to
> clean up is the displaying of the divisional standings
on the right side.
> As of
> right now, I use a URL variable (division = id2) to grab
the needed data,
> which
> works ok. What I want to do is clean up the url abit.
>
> So far the url is
clubhouse.php?team=Wings&id=DET&id2=Pacific, in the end
> all
> I want is clubhouse.php?team=Wings.
>
> I have a separate table, that has the teams entire
information (full team
> name, short team, abbreviation, conference, division,
etc. so I was
> thinking if
> I could somehow do this:
>
> Recordset Team Info is filtered using URL variable team
(short team).
> Based on
> what team equals, it would then insert this variable
into the Divisional
> Standings recordset.
>
> So example: If I type in clubhouse.php?team=Wings, the
Team Info recordset
> would bring up the Pacific division. Then 'Pacific'
would be inserted into
> the
> Divisional Standings recordset to display the Pacific
Division Standings.
>
> Basically I want this
>
> SELECT *
> FROM standings
> WHERE division = <teaminfo.division>
> ORDER BY pts DESC
>
> Could someone help me, thank you.
>
Maybe you are looking for
-
The Clock on my N95 cannot be relied upon to keep accurate time. Sometimes it looses a few minuits or even an hour. It does not matter whether I activate the Network Operator Auto-Update. The SIM in my N95 is quite new Vodafone contract SIM. I am usi
-
The new keyboard/mouse pane in Tiger's System Preferences now allows one to change application shortcuts. I am left-handed and wish to change the 'Back' and 'Forward' menu commands to the left and right arrow keys in selected applications. I was able
-
Maybe if I phrase this a different way... Is there an API I can use for real-time updates of HR Employees status. I would like the HR module to update my internal custom application and expire user access if the employee terminates or changes job res
-
Dear All, i want to display a message like MESSAGE 'say something' TYPE 'S'. during a abap report is running. But messages like this are only displayed at the next screen. So how can i show them at the time when the command MESSAGE is processed? I on
-
Even though I checked the keep me signed in box, I have to sign in to get to my home page
I have the keep me signed in box checked but I have to sign in to get to my home page. It comes up with the set up your home page.