Select from all tables in schema
hi, i am trying to x,y from tables in a schema, getting "missing expression" error, working with oracle 11g.
declare
v_sql varchar2(4000);
v_x number;
v_y number;
v_n number;
begin
for rec in (select table_name as table_name from all_tables where table_name like '%AM_%' ORDER BY 1) loop
v_sql := 'select a.idnumber, t.x, t.y, table(sdo_util.getvertices(a.geometry)) t FROM '||rec.table_name ||' a';
EXECUTE IMMEDIATE v_sql INTO v_n, v_x, v_y;
dbms_output.put_line(v_n||v_x||v_y);
end loop;
end;
hi two rows, with idnum and geometry columns...
IDNUM
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
GD8
SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(-.48230432, 51.4645609, -.47600566, 51.464582, -.47206108, 51.4645953, -.4654
6537, 51.4646174, -.46423724, 51.4646216, -.45892656, 51.4646394, -.45671873, 51
.4646468, -.45007509, 51.4646691, -.4487052, 51.4646737, -.44809122, 51.4646758,
-.44748667, 51.4646778, -.44118568, 51.4646989, -.44038184, 51.4647016, -.43534
624, 51.4647186, -.43415307, 51.4647226, -.43413338, 51.4647226, -.43410223, 51.
4647227, -.43408667, 51.4647228, -.43408688, 51.4648537, -.43408691, 51.4648694,
-.43408703, 51.4649432, -.43408705, 51.4649579, -.43408717, 51.4650319, -.4340872,
51.4650481, -.43408741, 51.465177, -.4341061, 51.4651769, -.43413411, 51.465
1768, -.43415863, 51.4651767, -.43493934, 51.4651741, -.43724392, 51.4651664, -.
4381469, 51.4651633, -.43876878, 51.4651612, -.44038073, 51.4651558, -.4409811,
51.4651538, -.44732658, 51.4651325, -.44759329, 51.4651316, -.44870078, 51.46512
79, -.45213755, 51.4651164, -.45482423, 51.4651073, -.45795448, 51.4650968, -.46
041684, 51.4650886, -.46194096, 51.4650834, -.46348669, 51.4650783, -.46492913,
51.4650734, -.46744722, 51.465065, -.47410127, 51.4650426, -.47616935, 51.465035
7, -.48152654, 51.4650177, -.48230505, 51.4650151, -.48235217, 51.4650149, -.482
35215, 51.4650018, -.48235145, 51.4645722, -.48235143, 51.4645607, -.48230432, 51.4645609))
IDNUM
GEOMETRY(SDO_GTYPE, SDO_SRID, SDO_POINT(X, Y, Z), SDO_ELEM_INFO, SDO_ORDINATES)
GD4
SDO_GEOMETRY(2003, 8307, NULL, SDO_ELEM_INFO_ARRAY(1, 1003, 1), SDO_ORDINATE_ARR
AY(-.48497261, 51.4772685, -.48209892, 51.4772786, -.48097228, 51.4772825, -.474
22571, 51.477306, -.47275437, 51.4773112, -.46898013, 51.4773243, -.46659847, 51
.4773326, -.46535204, 51.477337, -.4624971, 51.4773469, -.46135428, 51.4773509,
-.45879869, 51.4773598, -.45693251, 51.4773663, -.45570651, 51.4773706, -.453196
56, 51.4773794, -.45006644, 51.4773903, -.44747333, 51.4773993, -.44686181, 51.4774014, -.44408948,
51.4774111, -.4389499, 51.477429, -.43830451, 51.4774313, -.
4346623, 51.477444, -.43398218, 51.4774464, -.43331459, 51.4774487, -.43326608,
51.4774489, -.43326612, 51.4775874, -.43326612, 51.4776043, -.43326616, 51.47774
86, -.43326616, 51.4777641, -.43326619, 51.4779031, -.4333147, 51.4779029, -.472
655, 51.4777657, -.47413516, 51.4777605, -.48497272, 51.4777227, -.48502579, 51.
4777226, -.48502579, 51.4777106, -.48502568, 51.4772809, -.48502568, 51.4772684,
-.48497261, 51.4772685))
Similar Messages
-
hi Friends ,i need a suggestion from you on how to
insert data to all tables on a Database "A " on Test server
Select data from all tables on a Database "A" on Production Server
where id=123
Database A is same with Structures on Test and Production also all Tables will have Id column in common.
The purpose of this insert is ,as we all know Production has the latest data and i need to push to test server on request for particular ID only ( may be weekly once or twice a week )
I have a linked server setup name "LINQ"
Example for one table is below , like wise i need a script which does for 154 tables.
Insert into ABC( id, name)---insert to test server
Select Id, name from LINQ.ProdSerevrname.databasename.ABC where id = 123
Please help me ..
ThanksWhy not use export import wizard for this if you've read access to production?
Please Mark This As Answer if it solved your issue
Please Vote This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
Can we export DATA from all tables in a schema?
Hi,
I have a question; Can we export all the DATA from all the tables present in the schema to any source (eigther CSV, TXT, DAt, etc..)?
Or
Can I have a PL/SQL procedure to display DATA from all Tables in a schema?
With Best Regards,
- NaveedHi,
This is pretty much what you need.
DECLARE
V_COUNT NUMBER;
v_sql varchar2(1000);
IN_OWNER_NAME VARCHAR2(100) := 'AP' ; -- SCHEMA NAME
TYPE T_COL_NAME is table of varchar2(1000) index by binary_integer;
v_col_tbl t_col_name;
BEGIN
FOR i in
(SELECT object_name
FROM dba_objects
WHERE owner = IN_OWNER_NAME
AND object_type ='TABLE'
and rownum < 2)
LOOP
v_sql := 'SELECT COUNT(*) FROM ' || i.object_name ;
EXECUTE IMMEDIATE v_sql INTO V_COUNT;
if v_count > 0 then
v_sql := 'SELECT * FROM ' || i.object_name ;
select column_name
bulk collect
into v_col_tbl
from DBA_TAB_COLUMNS
WHERE TABLE_NAME = I.OBJECT_NAME
AND OWNER = IN_OWNER_NAME;
-- start selecting the column and exporting using the column names selected.
end if;
if v_col_tbl.count > 0 then
for i in v_col_tbl.first .. v_col_tbl.last
loop
DBMS_OUTPUT.PUT_lINE(v_col_tbl(i));
end loop;
end if;
DBMS_OUTPUT.PUT_lINE( i.object_name || '-' || v_count);
END LOOP;
END;
- Ronel -
Grant select on all table of a schema to role
Hi , is it possible to grant select on all table on a schema to a role?
To grant SELECT on all tables of the current schema to particular role or user:
SELECT 'GRANT SELECT ON '||TABLE_NAME||' TO READ_ONLY_ROLE;' COMMAND
FROM (
SELECT TABLE_NAME
FROM ALL_TABLES
WHERE OWNER = (SELECT USER FROM DUAL)
Then copy and execute the result commands, eg:
GRANT SELECT ON DEPT TO READ_ONLY_ROLE;
GRANT SELECT ON EMP TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_USERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_CUSTOMERS TO READ_ONLY_ROLE;
GRANT SELECT ON DEMO_ORDERS TO READ_ONLY_ROLE; -
Grant select on all tables of a schema
I need to grant select on all tables (over 200 tables) of a schema to other users. Are there any SQL syntax to do this?
Thanks!Execute the following script, modify it for your environment:
Script
Accept from_owner char prompt 'Grant from user:'
Accept to_user char prompt 'grant to user:'
set head off;
set lines 300;
set pages 0;
set termout off;
set feedback off;
set head off;
set verify off;
spool d:\temp\grant.sql
select 'grant select on &from_owner..'||
table_name||
' to &to_user;'
from dba_tables
where owner=upper('&&from_owner');
spool off;
set head on;
set pages 24;
set termout on;
set feedback on;
set head on;
@d:\temp\grant.sqlExecution example:
system@DBA> @d:\temp\grants.sql
Grant from user:scott
grant to user:ejemplo
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded.
Grant succeeded. -
Select from a table from other schema
Hi,
I want to make a select from a table how is into other Schema and into other instance.
form example, if I have _2 schemas (in diferent instances)_:
SCHEMA1 =
*(DESCRIPTION =*
*(ADDRESS =*
*(PROTOCOL = TCP)*
*(HOST = XXX.XXX.XXX.XX1)*
*(PORT = 1560)*
*(CONNECT_DATA =*
*(SERVER = DEDICATED)*
*(SERVICE_NAME = SCHEMA1)*
SCHEMA2 =
*(DESCRIPTION =*
*(ADDRESS =*
*(PROTOCOL = TCP)*
*(HOST = XXX.XXX.XXX.XX2)*
*(PORT = 1560)*
*(CONNECT_DATA =*
*(SERVER = DEDICATED)*
*(SERVICE_NAME = SCHEMA2)*
and into SCHEMA2 there is a table TABLE_A.
If I`m connected into SCHEMA1:
how can I do to make a select from the TABLE_A?
thanks very much.1) Referring to an entry in the tnsnames.ora file as a "schema" as you have here with schema1 and schema2 is likely to be confusing. You have multiple schemas in the same database-- in this case, you appear to be trying to query tables in a different database. If we try to answer using your TNS aliases "schema1" and "schema2", there is likely to be a great deal of confusion between schemas/ databases/ and TNS aliases. So I will assume that your tnsnames.ora file actually reads
TNS_ALIAS1 =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = HOST1)
(PORT = 1560)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB1)
TNS_ALIAS2 =
(DESCRIPTION =
(ADDRESS =
(PROTOCOL = TCP)
(HOST = HOST2)
(PORT = 1560)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = DB2)
)2) Given the TNS aliases above, assuming that we are talking about the tnsnames.ora file on HOST1, you would need to create a database link from DB1 to DB2. You can either specify a fixed username and password for the database link or you can specify that the connection happens as the current user (which assumes that the passwords are synchronized between the databases).
CREATE DATABASE LINK to_db2
CONNECT TO username_on_db2
IDENTIFIED BY password_on_db2
USING 'TNS_ALIAS2'3) Assuming the database link is in place
SELECT *
FROM schema2.table_name@to_db2Justin -
Select from 2 tables and insert same data into 2 other tables(BPEL Process)
Hi All,
Please suggest me how to select from 2 tables and insert the same data into 2 tables. I am successful in selecting data from 2 tables, but i am not able to insert the same data into 2 other tables. There is foreign key constraint between 2 tables.
Thanks in Advance,
MAHI have created DB Adapter for selecting from 2 tables and also DB adapter for insert and i have created parent child relationship between 2 tables.
I am getting this error
<Faulthttp://schemas.xmlsoap.org/soap/envelope/>
<faultcode>env:Server</faultcode>
<faultstring>com.oracle.bpel.client.delivery.ReceiveTimeOutException: Waiting for response has timed out. The conversation id is 6f3fe20c1b031057:-6cc7dfb5:11b8bf5fbe1:-7fa4. Please check the process instance for detail.</faultstring>
</Fault> -
How to do a SELECT from different tables into an internal table?
How to do a SELECT from different tables into an internal table?
I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
REPORT zinternal_table.
TABLES:
mara,
marc,
zperson.
TYPES:
BEGIN OF str_table1,
v_name LIKE zperson-zname,
v_matnr LIKE marc-matnr,
v_emarc LIKE marc-emarc,
v_werks_d LIKE marc-werks_d,
v_dstat LIKE marc-dstat,
END OF str_table,
i_table1 TYPE STANDARD TABLE OF str_table1.
DATA:
BEGIN OF str_table2,
v_mandt LIKE mara-mandt,
v_ernam LIKE mara-ernam,
v_laeda LIKE mara-laeda,
END OF str_table2,
itab_final LIKE STANDARD TABLE OF str_table2.first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
then for all the entries in that internal table retrieve data from zperson into another internal table.
then loop at one internal table
read another internal table where key equals in both the tables.
finally assign fileds if sy-subrc = 0.
gs_finaltable-matnr = gs_table-matnr
etc...
and finally append gs_finaltable to gt_finaltable.
there u go ur final table has all the data u want.
regards
Edited by: BrightSide on Apr 2, 2009 3:49 PM -
Select from nested table in a nested table security problem
please help
running Oracle 9.2.0.3.0 on RH AS 2.1
I can select the inner most nested table as the creator, but can't use the same select statement as USER2.
ORA-00942: table or view does not exist
-- begin make of objects and tables
create or replace type mydata_t as object ( x float, y float);
create or replace type mydata_tab_t as table of mydata_t;
create or replace type mid_t as object (
graphname varchar2(12),
datapoints mydata_tab_t );
create or replace type mid_tab_t as table of mid_t;
create or replace type top_t as object (
someinfo int,
more_mid mid_tab_t );
create table xyz (
xyzPK int,
mainstuff top_t )
nested table mainstuff.more_mid store as mid_nt_tab
(nested table datapoints store as mydata_nt_tab)
-- grants
grant all on mydata_t to user2;
grant all on mydata_tab_t to user2;
grant all on mid_t to user2;
grant all on mid_tab_t to user2;
grant all on top_t to user2;
grant all on xyz to user2;
-- insert
insert into xyz values (1, top_t(22,mid_tab_t(mid_t('line1',mydata_tab_t(
mydata_t(0,0),
mydata_t(15,15),
mydata_t(30,30))))));
commit;
-- select fails as user2
select * from table(select Y.datapoints as DP_TAB
from table(select X.mainstuff.more_mid as MORE_TAB
from scott.xyz X
where X.xyzPK=1) Y
where Y.graphname='line1') Z;
-- select works as user2, but i need individual lines
select Y.datapoints as DP_TAB
from table(select X.mainstuff.more_mid as MORE_TAB
from scott.xyz X
where X.xyzPK=1) Y
where Y.graphname='line1';Thank you for your reply.
I have tried
select value(t) from table t;
but it is still not working. I got almost the same answer as before.
Anyway thank you very much again.
<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by MARCELO OCHOA ([email protected]):
Originally posted by meimei wu ([email protected]):
[b]I created a nested object-relational table using REF type in oracle8i. when I tried to select * from the table, I got lots of number as the ref type values, but actually, the value in ref type should be of type varchar2 and number. The number I got looked like following code:
JARTICLE_REF_TYPE(000022020876108427C2FE0D00E0340800208FD71F76103B99B12009C0E0340800208FD71F,
Does anyone know how I can get the actual value that I inserted into the nested table?
your help is appreciated.<HR></BLOCKQUOTE>
Try this:
select value(t) from table t;
Best regards, Marcelo.
null -
How to avoid ORA-3113 when selecting from XMLTYPE table
Hi,
If I register an XML-schema, Oracle automatically creates a table xxxxxx_tab of XMLTYPE. (I use Oracle 9.2.0.1)
When I do a DESCRIBE or a SELECT from this table I get the error: 'ORA-03113:
end-of-file on communication channel' and my connection is dropped.
I opened a TAR for this and Oracle says: 'It is an internal bug so cannot be viewed in metalink. This is fixed in release 10i.' (do they mean oracle DB rel 10i, or a new version of XDK?)
I saw an example in Oracle Magazine (Jan
2003) "Make XML Native and Relative" about Oracle 9i Rel 2 and XML. As you can see in codeListing 7, the author also does a select from such a
table (CD331_tab): Why doesn't he have any problems?
Is there a workaround for this bug? What's the purpose of being able to automatically upload XML-data to a registered schema if you can't do a select of the data?
Thank you!It appears that the XML Schema is not entirely valid. Specifically, the definition of element "DeviceCategory" has two definitions of element "Audio" appearing within a <choice> model i.e. something like :
<element name="DeviceCategory">
<choice>
<sequence>
<element name="Audio">
</sequence>
<sequence>
<element name="Audio">
</sequence>
</choice>
This is disallowed by XML Schema spec per. the Unique Particle Attribution Constraint. The general idea is that a XML Schema describes a determinstic content model i.e. schema processor can always unambiguosly determine the matching declaration when it encounters an element. However that's not the case with the declaration above. On encoutering "Audio", it could match either the first or the second declaration of the element. Hence the error.
You will have to rework the schema to avoid this constraint. One mechanism could be to define complexType and their restrictions.
- Ravi -
Export specific records from all table? Please help me with my query
hi
there are around 200 tables, I want to take a export of all tables of xyz schema.
My requirement is just a few records of primary key and their relevant records from other tables to be exported by using exp or expdp utility.Hi Toni...
Thanks for your reply.
Could you please help me understand how to user this expdp query...
and what exactly should i mention in the parfile. I want all relevant records from all tables of primary key. please help me to write a query accordingly. -
Selecting from multiple tables, into one internal table
Hi,
What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
Thanks,
John
Points will be rewarded and all responses will be highly appreciated.I have simple example :
First one - Join 5 tables
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 4 or 5 tables join.
get run time field f2.
f3 = f2 - f1 ( Total time).
Second one - joins 3 table and use for all entries
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 3 tables join and use for all entries
get run time field f2.
f3 = f2 - f1. ( Total time )
Finally you can have time diffrence between the both sql statement. -
I have a db, call it xyz.mdb
It suddenly is that SSMS is not listing the table objects nor the Views. SELECT * FROM sys.Tables and SELECT * FROM sys.Views work very fine. But when I click on the tables node, on Objects Explorer, Only the Systems Tables and File Tables folders
show.
Other DBs on same SQL instance do not show same problem. They are all working very fine.
I have backed up and restored this db on other computers and the behaviour is the same. Incidentally right-clicking the db and clicking Properties throws up this error message.
-------------------------------------------------------------------------Error!
Cannot show requested dialog.
Property Size is not available for Database '[Pliny E DB - NOA 2014]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights. (Microsoft.SqlServer.Smo)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft+SQL+Server&ProdVer=11.0.3000.0+((SQL11_PCU_Main).121019-1325+)&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.PropertyCannotBeRetrievedExceptionText&EvtID=Size&LinkId=20476
--------------------------------------------------------------------------------End>
When I try to Refrresh the Tables node on Object Explorer, I get this other:
------------------------------Error!
SQL Server detected a logical consistency-based I/O error: incorrect checksum (expected: 0x9090d9b7; actual: 0x909001b4). It occurred during a read of page (1:1173) in database ID 21 at offset 0x0000000092a000 in file 'c:\Databases\Clients\NOA\Pliny E DB -
NOA 2014.mdf'. Additional messages in the SQL Server error log or system event log may provide more detail. This is a severe error condition that threatens database integrity and must be corrected immediately. Complete a full database consistency check
(DBCC CHECKDB). This error can be caused by many factors; for more information, see SQL Server Books Online. (Microsoft SQL Server, Error: 824)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=824&LinkId=20476
------------------------------End>
The Help link of course is not valid any more.
Many thanks
Vie
@Abuja
VieYour database is corrupted and you need to run.
DBCC CHECKDB
You already have a backup so do it...
This link will provide you with more information:
http://msdn.microsoft.com/en-us/library/ms176064.aspx -
PL/SQL: ORA-22992: cannot use LOB locators selected from remote tables
Dear ALL,
My O/S is Redhatlinux 5.2 and i had Migrated my Oracle databse to 11g2. But after that while i am retrieving records through dblinks from one of my other Oracle 9.2.0.8 databse it's throwing the error : PL/SQL: ORA-22992: cannot use LOB locators selected from remote tables.* This error i am getting in TOAD as well as SQL Developer.
Can anybody tell me how to fix this error ? Because am not able to get the records.
Also am getting another error during retrieving data from some of my tables after migrating i.e the table which having CLOB data type while am accessing to retrieve the records using select query it's throwing the error :
+(The following error has occurred:+
A query with LOB's requires OCI8 mode, but OCI7 mode is used.)
If anyone having any idea kindly share.
Thanks and Regards
BiswaHi,
Ya what u sent that is fine. But already am using one procudure which is accessing LOB data from another databse through DBlink and working fine. But there Both the databse are 9.2.0.8.
But while am executing the same procedure in oracle 11g where the Dblink accessing the data from Oracle 9i , there am getting this error.
Kindly tell if u know any resolution.
Thanks -
Select from multiple tables without join statement
Hey Gurus,
I would like to make a select from a multiple tables to check if there is any reference to my data. I would like to do it with some elegancy, but I don't know how.
Is in abap sql possible to do it only with the select statement?
Or I was also think about a solution that I should fill some data structure with all of the tables which I want to select from and then just loop that data structure and do the select seperately from all of the tables. I just need to check if it founds some results, so no need to store it. If this solution would be fine what data structure should I use?
Or can tell me what would be the best for this?
My code for select from one table, which I want to make for multiple tables:
SELECT SINGLE id_kniznice FROM zbr_t_autori INTO wa_id
WHERE id_kniznice EQ ls_extract-zview-id_kniznice.
IF sy-dbcnt > 0.
MESSAGE i000(zbr_msgc_lib).
ls_extract-flags-vim_mark = '*'.
MODIFY extract FROM ls_extract.
ENDIF.
Thank you for any posts.
Regards,
RobertAnd there we go again...
Read this topic:
For All Entries is NOT better than INNER JOIN in most cases
And this one:
inner join vs for all entries
Also that one:
Re: LOOP AT vs INNER JOIN
JOINs are really better than for all entries in most cases. Problem is people tend to ignore basic things like using pks or indexes while making them.
Maybe you are looking for
-
Assign a Position in CRM to an Organization Unit at a higher level.
Hi, While configuring the Organizational Management in CRM 5.1, I have copied the sales areas created in ECC to CRM. The resulting structure is a freely definable Org Unit at the top level called Sales Area (as is was created in ECC) and under that a
-
SBS 2011 - High CPU usage - Help me Microsoft forums! You're my only hope!
My company supports a client that has a SBS 2011 server. For about the past year, we've been fighting a recurring issue with performance on this server. There are about ten local users and four remote users. The server's CPU idles at about 60%-80%
-
ALE using HRMDA message type - Comit not perform in receiving system
Hi, I want to use ALE to transfer HR master data between two ECC instances. I have set-up all the configuration; distribution profile, filter etc... I tried to transfer the master data using standard SAP report RHALEINI. The iDoc is generated and tra
-
My name for my icloud is not correct, how do I get it corrected?
My name for my icloud is not correct, how do I get it corrected?
-
Is there a way or setting to delete one without deleteing the other? I have gone to RECENTS hit ALL and hit clear and it also clears all MISSED calls and vice versa. This is very frustrating. If anyone knows of a solution this would be great.