Select schema name. How?
Hi All,
May be a very simple question, how can I select the schema name I'm logged into. I don't carry DBA privileges.
--Sam
Thanks.
--Sam
Similar Messages
-
How to parameterize the schema name in APEX
Hi,
How to parameterize the schema name in APEX , in order to access different tables from the respective schema.
For example:-
select NAME display_value, CODE return_value
from paramSchema.DESC_LIST WHERE SELECTION_FLG = 'Y'
order by 1
in the above code, paramSchema will be replaced with the actual schema name duing runtime. I tried doing so by some hidden fields on page, but it didn't worked out.
I took the schema name from the respective server as per the IPof the server.
stored in a hidden field named as schema.
And replaced the same in place of schema name. But no luck.
select NAME display_value, CODE return_value
from :schema.DESC_LIST WHERE SELECTION_FLG = 'Y'
order by 1
Please help me in shorting it out.
Thanks,
AnuradhaHi
In order to do that, you would need to use dynamic SQL by changing the report type to PL/SQL Function Body Returning SQL Query and have code along the lines of
DECLARE
l_sql VARCHAR2(32767);
BEGIN
l_sql := 'select NAME display_value, CODE return_value
from '||:schema||'.DESC_LIST WHERE SELECTION_FLG = 'Y'
order by 1';
RETURN l_sql;
END;However, by doing this, you lose alot of flexibility. The other options would be...
To have seperate report regions that are conditional on the value of the variable.
To use a WITH clause at the tope of the query like...
WITH src_data AS
(SELECT * FROM schema1.my_table
WHERE :schema = 'schema1'
UNION ALL
SELECT * FROM schema2.my_table
WHERE :schema = 'schema2')
SELECT *
FROM src_dataOther than that you could look at using synonyms and doing something similar.
Hope this helps.
Cheers
Ben -
How to call a schema name using substitution name?
Hi All,
How to call a schema name using substitution menthod in odi?
I was trying but I got the following error..
ODI-1227: Task XXX(Procedure) fails on the source ORACLE connection YYY.
Caused By: java.sql.SQLException: Missing IN or OUT parameter at index:: 1
Here xxx procedurename.
yyy-schemaname
Please do the needful..
Thanking you in Advance.
Regards,
PP1 declare
2 sql_string varchar2(2000);
3 begin
4 sql_string := 'select ' || func_name || ' into a from dual ';
5 execute immediate sql_string;
6* end;
SQL> /
sql_string := 'select ' || func_name || ' into a from dual ';
ERROR at line 4:
ORA-06550: line 4, column 28:
PLS-00201: identifier 'FUNC_NAME' must be declared
ORA-06550: line 4, column 1:
PL/SQL: Statement ignored
1 declare
2 sql_string varchar2(2000);
3 func_name varchar2(30);
4 begin
5 func_name := 'some_func';
6 sql_string := 'select ' || func_name || ' into a from dual ';
7 execute immediate sql_string;
8* end;
SQL> /
declare
ERROR at line 1:
ORA-00904: "SOME_FUNC": invalid identifier
ORA-06512: at line 7
SQL> desc some_func;
ERROR:
ORA-04043: object some_func does not exist
1 create or replace function test_func
2 return number
3 is
4 begin
5 return 0;
6* end;
SQL> /
Function created.
1 declare
2 sql_string varchar2(2000);
3 func_name varchar2(30);
4 begin
5 func_name := 'test_func';
6 sql_string := 'select ' || func_name || ' into a from dual ';
7 execute immediate sql_string;
8* end;
SQL> /
declare
ERROR at line 1:
ORA-00905: missing keyword
ORA-06512: at line 7
SQL> Set serveroutput on
1 declare
2 sql_string varchar2(2000);
3 func_name varchar2(30);
4 return_value number;
5 begin
6 func_name := 'test_func';
7 sql_string := 'select ' || func_name || ' from dual ';
8 execute immediate sql_string into return_value;
9 dbms_output.put_line(return_value);
10* end;
SQL> /
0
PL/SQL procedure successfully completed.Hope that helps.
Regards
Raj -
How to make sure that schema name is not included with generated sqls
How to make sure that schema name is not included with generated sqls with tableadapter wizard.
What should I use? Oledb, ODT.NET, where can set that I want "pure" sqls, not schemas, not ", or anything like this
I want
"Select a,b from t1" ,not "select "a","b" from schema.t1"
Also schema name is put in all parameters, all over the place... What if schema name changes. (b1test to b1prod)
. I now manually edit XML files of dataset. It works but....
thanksThe full hardware :
Processor Intel core due 3.00 MHz
RAM:1.5GB
psu:650 Watt (but i baught i cheap one so it may be actually about 400 watt)
HD Disk:160 GB
But about the power supply if it not able to run the VGA card ,Is it will not show any screen or it will not able to run the computer?? -
How to Get the schema name that contains the current procedure?
I have try select sys_context( 'userenv', 'current_schema' ) from dual; but it returns the schema name of the login user. How to return the schema name of the procedure instead? For example, procedure A is in ControlDB, and I login as sys, when query procedure A it should return ControlDB instead of sys.
I have searched in Google but no luck to find the answer so far, please help. Thank youIt works!
I am quite confused now. I did try to use select username from user_users in GetSchemaName procedure, but it always return the login user instead of the owner of the procedure. Why it return the procedure owner if I put the query inside a function then call it from the procedure?
Is it because when the login user call the procedure and the procedure call the function, it's the procedure owner is calling the function so the user_users return the user that is calling it which is the procedure owner. And if the query is directly put inside the procedure, when the login user call the procedure, user_users return the login user directly? Does it imply that if the procedure call any function or other procedures etc, it would be the procedure's owner calling them instead of the login user?
(sys_context works as well if I move the query into the function then call the function from the procedure)
Cheers
Message was edited by:
user500168 -
How to configure the schema name dynamically based on user input.
configure the schema name dynamically based on user input.
For ex:
We have two schemas:
Schema1 - base schema having 15 tables.
Schema2 - tables which is specific to modules. Having only 10 tables which is also available in Schema1
Login to application using Schema 1
Access a particlular module and select the country. Here country selection is identified.
Based on the country selection, we need to connect the schema respectively.
If the user selects France --> It should connect Schema1
If the user selects Germeny --> It should connect schema2.
Used: EclipselinkYou may want to have a different persistence unit for each country, then you just need to switch persistence units, and can put the schema in your orm.xml file.
You may also want to investigate EclipseLink multi-tenant support,
http://www.eclipse.org/eclipselink/documentation/2.5/jpa/extensions/a_multitenant.htm
You can the schema in a persistence unit in code using a SessionCustomizer and the tableQualifier. -
How to get the current schema name
Hi,
Can anybody please tell me how to get the current schema name, there is some inbuilt function for this,but i am not getting that. Please help me.
Thanks
Jogeshok folks, I found the answer at Tom's as usual.
http://asktom.oracle.com/tkyte/who_called_me/index.html
I rewrote it into a function for kicks. just pass the results of DBMS_UTILITY.FORMAT_CALL_STACK to this function and you will get back the owner of the code making the call as well some extra goodies like the name of the code and the type of code depending on the parameter. This ignores the AUTHID CURRENT_USER issues which muddles the schemaid. Quick question, does the average user always have access to DBMS_UTILITY.FORMAT_CALL_STACK or does this get locked down on some systems?
cheers,
paul
create or replace
FUNCTION SELF_EXAM (
p_call_stack VARCHAR2,
p_type VARCHAR2 DEFAULT 'SCHEMA'
) RETURN VARCHAR2
AS
str_stack VARCHAR2(4000);
int_n PLS_INTEGER;
str_line VARCHAR2(255);
found_stack BOOLEAN DEFAULT FALSE;
int_cnt PLS_INTEGER := 0;
str_caller VARCHAR2(30);
str_name VARCHAR2(30);
str_owner VARCHAR2(30);
str_type VARCHAR2(30);
BEGIN
str_stack := p_call_stack;
-- Loop through each line of the call stack
LOOP
int_n := INSTR( str_stack, chr(10) );
EXIT WHEN int_cnt = 3 OR int_n IS NULL OR int_n = 0;
-- get the line
str_line := SUBSTR( str_stack, 1, int_n - 1 );
-- remove the line from the stack str
str_stack := substr( str_stack, int_n + 1 );
IF NOT found_stack
THEN
IF str_line like '%handle%number%name%'
THEN
found_stack := TRUE;
END IF;
ELSE
int_cnt := int_cnt + 1;
-- cnt = 1 is ME
-- cnt = 2 is MY Caller
-- cnt = 3 is Their Caller
IF int_cnt = 1
THEN
str_line := SUBSTR( str_line, 22 );
dbms_output.put_line('->' || str_line);
IF str_line LIKE 'pr%'
THEN
int_n := LENGTH('procedure ');
ELSIF str_line LIKE 'fun%'
THEN
int_n := LENGTH('function ');
ELSIF str_line LIKE 'package body%'
THEN
int_n := LENGTH('package body ');
ELSIF str_line LIKE 'pack%'
THEN
int_n := LENGTH('package ');
ELSIF str_line LIKE 'anonymous%'
THEN
int_n := LENGTH('anonymous block ');
ELSE
int_n := null;
END IF;
IF int_n IS NOT NULL
THEN
str_type := LTRIM(RTRIM(UPPER(SUBSTR( str_line, 1, int_n - 1 ))));
ELSE
str_type := 'TRIGGER';
END IF;
str_line := SUBSTR( str_line, NVL(int_n,1) );
int_n := INSTR( str_line, '.' );
str_owner := LTRIM(RTRIM(SUBSTR( str_line, 1, int_n - 1 )));
str_name := LTRIM(RTRIM(SUBSTR( str_line, int_n + 1 )));
END IF;
END IF;
END LOOP;
IF UPPER(p_type) = 'NAME'
THEN
RETURN str_name;
ELSIF UPPER(p_type) = 'SCHEMA.NAME'
OR UPPER(p_type) = 'OWNER.NAME'
THEN
RETURN str_owner || '.' || str_name;
ELSIF UPPER(p_type) = 'TYPE'
THEN
RETURN str_type;
ELSE
RETURN str_owner;
END IF;
END SELF_EXAM; -
Need to include table name,schema name in select output
I need to output the table name and schema name of the current user into a table.. I have tried including
within a select statement..
table_name,
from user_tables
where table_name='mnme';
no rows returnedHi,
Its in upper case 'MNME'
Best.
EA -
Specify schema name in select statements
Is there a way to specify the schema name for the connection so that I don't have to specify schema name with every statement?
Currently I am executing the statement:
Statement stmt = null;
ResultSet rs = null;
String getAllNames =
"SELECT NAME FROM " + schemaName +".NAMES " + schemaName +" WHERE STATUS_CODE != 12 ";
stmt = conn.createStatement();
rs = stmt.executeQuery(getAllNames);
But I have a lot of such statements, a few which uses parameters.
Is there a way I can specify the schemaName once and for all so that I don't have to perform string concat everytime the function is invoked.well I tried that, since the application runs under CICS which uses the trusted connection with DB2, all CICS application will be using the same userid and there is no way to ensure that other applications would not be using the same table name in some other application. So the only option I have is to specify the schema name with the select statements but I don't want to append the schema name with each statement.
-
How to know database name and schema name
Hi ,
Once after logging in the database,how is it possible to know the current database and schema which we r using?Is there any system table where we can get the database names and schema names?
please help me out.itz urgent.
Regards,
SravanProbably not.
If the database name is the name of the current database, it would be essentially redundant. If the database name is the name of some other database, in order to get the names of all the tables in the specified schema, you could create a database link to the remote system (which assumes you have a login and password to the remote database with appropriate privileges, that the database server's tnsnames.ora file has an entry for the remote database, etc) and query the remote data dictionary tables. Even if you could do that, however, you could not dynamically create triggers on the remote database since DDL over a database link.
In theory, you could also load an appropriate JDBC driver into the database and write a Java stored procedure that would connect to the remote database (again, with an appropriate user name & password, host name, and port number) and issue DDL against that remote database. I have a hard time believing, however, that this would be a particularly beneficial approach. It would be easier just to put the appropriate code into each database that needs triggers generated or to have a separate Java application that generates triggers for a number of different databases.
Justin -
How to know database name and schema name by providing package name?
Hi,
Could someonw will help me to get database name and schema name by providing package name ?
I have used the query : select * from all_objects where object_name='Package_name'; but it simply returns schema name where as i need DB name and username.
--Prajaktabut it simply returns schema name where as i need DB name and username.
i want to retrive the DB name for package name
Based on your questions, I wonder if you are used to working in SQL Server? (The server, database, and schema are part of the 4-part name of an object, independent of any user.)
In SQL Server, schema and username are two separate physical concepts. "Schema" is purely logical in Oracle: a user which owns objects is often called a "schema".
In Oracle, "database" is roughly equivalent to the SQL Server concept "server" (what you log in to). It is not part of the naming path to a specific object (unless there is a database link involved, but there is no indication that's what you have here). In Oracle you connect to an Instance (or Service) and people often call this the "database", but there is a fine semantic distinction there (separate topic).
Once connected in Oracle, you fully-qualify an object by only a 2-part owner and object name (possibly 3-part if a database link is involved user.object@link).
12c added another wrinkle to all of this, but I'll assume this question was more basic than that, because you likely would have mentioned if this was a 12c question. -
Selection from Another schema by default without schema name qualifier.
Hi
Oracle10g release 2, LinuxOS
i want my schema (User_1) to always select,insert, update, delete the objects from another schema (User_2) without passing full schema qualifier every time whenever i don't pass any schema name explicitly.
i.e. if i pass the following guerry
select * from table_a;
the table of user User_2.table_a (User_2.table_a) will be queried by default instead of table (User_1.table_a)
and the same implementation is also required in Functions , procedures, sequences etc.
WishesThree relatively easy options
1) Create private synonyms in User_1's schema for each object in User_2's schema, i.e.
CREATE SYNONYM table_a
FOR user_2.table_a2) Create public synonyms for each object in User_2's schema. This will make it possible for all users to query user_2's objects without specifying the schema name
CREATE PUBLIC SYNONYM table_a
FOR user_2.table_a3) Change the current schema for the session (potentially in a login trigger)
ALTER SESSION SET current_schema = USER_2There are other options that are a bit more complicated like using enterprise users with shared schemas. But most people are perfectly happy with one of these three.
Justin -
How to find the tablespace name and schema name from a dump file
Good day to all,
I recived a dump file from a client with oracle 11g, and I need do get the tablespace and schema name from the dump file. How can I do that?
Thanks.
Flávio Melo
Edited by: 933141 on 09/05/2012 07:41user12038066 wrote:
Use imp utility, it generates DDL for both tables and indexes. So you will get tablespace info for both.
Use impdp utility, it generates DDL for indexes only. So you will miss tablesapce info for tables.
Haven't found a workaround for impdp utility. Anyone knows?Are you sure you are using the impdp utility correctly? Because if you do, then sqlfile should have all gory details. -
How to prefix schema name to a called procedure?
Hi,
I have five different schemas and each and every schema has the same procedures and same set of tables.
In calling procedure, there is one IN parameter which is schema name. In this procedure I am calling another procedure. In this scenario how to prefix schema name parameter to the called procedure?
Urgent please.
Thank you.Make use of Package constants:
[list]
[*]Create a package specification in each schema called REGION.
[*]Create a Package specification constant CURRENT_SCHEMA string literal equal the owner of the REGION package.
[*]This very very simple package (with no body) will be different in each of your five schemas. You must not transport this package between schemas.
[*]For the procedures you are calling, redefine the argument of schema_name with a DEFAULT REGION.CURRENT_SCHEMA value. This should give you what you are looking to do - making all the procedure code (except for the REGION package spec) portable between the schema.
[list] -
How to exclude schema name from exported files (PL SQL Developer)
Dear all,
Just one question: I am using PL SQL Developer. My goal is to export some data (as .sql and .dmp files) from one database and to import them into the another database (both databases have identical structure - test database and production, just different database names and names of schema. In order to make it possible, I need to exclude schema name from generated export file. I believe that it is possible to do it automatically by setting up parameters of PL SQL Developer. How?
Thank you in advance,
Kindest regards,
DraganaIn the meantime, I have found the answer on my previous question:
Actually, the initial idea (how to exclude schema name from exported files) was wrong. No need for any intervention.
Trick is: Schema name can be changed during the import of exported files (PL SQL Developer during import gives possibility: From User (old schema) To User (new schema) .
Hope that this will be useful info for others.
Dragana
Maybe you are looking for
-
I have automatic upload etc. activated in Photo Stream. I just uploaded new photos from my camera to my MacBook Pro, but nothing is sowing up on my iPhones my iMacs iPad or on Apple TV. Does anyone have. Any suggestions as to what I can. Do? I am
-
I am capturing video using a Sony HDR-SR12 Handycam, converting the video using QT in a MPEG4 format, so can use the file with imovie. Once I transfer over to imovie the video quality is very bad. Playing the video out of the camera on to the TV the
-
Forcing iPad1 to full display on data projector
I read somewhere that there is possible to have full display of iPad 1 in data projector by about using some software "adaptation"... I´m not talking about jailbraking - I read it iSt absolutly legal... Anyway, I'm totaly rookie on this... Could anyo
-
I downloaded, long time ago, a free version of WhiteNoise, then the app became shareware. Today I got a message from AppStore telling me it was updated but if I try to download it, either from mac or iphone, I get the error "item is no more available
-
How can i resize a image with changing good quality?
i do not know how to resize a image and display to let the user view immediately. I hope somebody can teach me and show the completed coding