How to get the database owner name in T-SQL script
Hello, All!
I want to get the database ower name (in format DOMAIN\user) by through T-SQL script. But SELECT * FROM sys.databases returns only owner_sid.
Please show me a way - how to get the owner name, if you have only owner_sid. Or, may be, somebody know another way ?
Andy Mishechkin
SELECT suser_sname( owner_sid ), * FROM sys.databases
http://www.t-sql.ru
Similar Messages
-
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; -
How to get the Portal Page name from PLSQL?
Can anyone tell me how to get the portal page name from my dynamic page using plsql?
Apparently you can get the page id and work it out from there, but my calls to get the page id are not returning any values anyway.
My code for attempting to get the page id is below.
<oracle>
declare
v_pageid varchar2(30);
begin
v_pageid := wwpro_api_parameters.get_value('_pageid', '/pls/portal30');
htp.print('Page is '|| v_pageid);
end;
</oracle>
Ideally I'd actually just like to get the page name. Is there a straightforward way to do this?
Thanks in advance!
SarahFew clarifications -
1. wwpro_api_parameters cannot be used to get default portal
page parameters such as '_pageid', '_dad', '_schema' etc.,
2. Page information can be obtained through any components which
are available in that particular page. For example, in case of
dynamic page, we need to publish it as a portlet and add it to the
page. This process creates necessary packages in the DB, but we
will not have access to the portlet methods.
So, I would prefer creating a simple DB provider & portlet and access
page title from its show method as follows -
//Declare local variable l_page_id, l_page_title as varchar2
select page_id into l_page_id from wwpob_portlet_instance$ where
portlet_id = p_portlet_record.portlet_id and
provider_id = p_portlet_record.provider_id;
select name into l_page_title from wwpob_page$ where id=l_page_id;
More information on DB provider can be found at
http://portalstudio.oracle.com/pls/ops/docs/FOLDER/COMMUNITY/PDK/articles/understanding.database.providers.html
Secondly, usage of wwpro_api_parameters.get_value method is
incorrect. This method expects two arguments -
<ul>
<li><b>p_name : </b> The name of the parameter to be returned.</li>
<li><b>p_reference_path : </b> An unique identifier for a portlet instance on the current page.</li>
</ul>
p_reference_path would be something like 99_SNOOP_PORTLET_76535103 and not some type of path as its name suggests.
The following code fragment fetches all parameters available
for a portlet.
Note : Copy this code into 'show' method of your portlet.
//Declare l_names, l_values as owa.vc_arr
* Retreive all of the names of parameters for this portlet
l_names := wwpro_api_parameters.get_names(
p_reference_path=>p_portlet_record.reference_path);
* Retreive all of the values of parameters for this portlet
l_values := wwpro_api_parameters.get_values(p_names=>l_names,
p_reference_path=>p_portlet_record.reference_path);
//Loop through these arrays to get parameter information
htp.p('<center><table BORDER COLS=2 WIDTH="90%" >');
htp.p('<tr ALIGN=LEFT VALIGN=TOP>');
htp.tableData(wwui_api_portlet.portlet_heading('Name',1));
htp.tableData(wwui_api_portlet.portlet_heading('Value',1));
htp.tableRowClose;
if l_names.count = 0 then
htp.p('<tr ALIGN=LEFT VALIGN=TOP>');
htp.p('<td COLSPAN="2">'
||wwui_api_portlet.portlet_text(
'No portlet parameters were passed on the URL.',1)
||'</td>');
htp.tableRowClose;
else
for i in 1..l_names.count loop
htp.p('<tr ALIGN=LEFT VALIGN=TOP>');
htp.tableData(l_names(i));
htp.tableData(l_values(i));
htp.tableRowClose;
end loop;
end if;
htp.p('</table></center>');
Hope it helps...
-aMJAD. -
How to get the current function name in java
How to get the current function name in java.
In c it is done as
printf("%s",__func__);
Thanx in advance.j0o wrote:
System.out.println("Class Name: " + new Exception().getStackTrace()[0].getClassName() +
"/n Method Name : " + new Exception().getStackTrace()[0].getMethodName() +
"/n Line number : " + new Exception().getStackTrace()[0].getLineNumber());
I pointed the OP at this approach yesterday in one of his multi-posts. I still have not been given my Dukes! -
How to get the jsp page name in jsp?
how to get the jsp page name in jsp? how the jsp get the jsp page name dynamic.
thanks in advance.Try request.getServletPath()
-
How to get the actual font name from a font file?
Hi
I have only the font Path I have to get the font name from that path. Any idea how to get the actual font name?
Thanks,I would ask you these questions:
Why do you need to do this? What are you ultimately trying to accomplish?
Are you really asking about the InDesign SDK?
Do you really need to get the "name" of a font from an arbitrary file? Or do you want information about a font installed on the system? If so, what OS?
Do you need to be able to handle any font format?
Which font "name" do you mean?
What language do you want the name in?
(1) It's not clear what you're trying to accomplish. A bit more information about your ultimate goal would be helpful.
(2) This question is not at all specific to the InDesign SDK. Are you really trying to do something in the context of an InDesign plug-in? If so, you probably want to look at IID_IFONTFAMILY and the IFontFamily::GetFamilyName function.
(3) If you are asking more generally, Windows and Mac both have system API calls to get this information, although those tend to deal with installed system fonts, not with arbitrary font files per se.
Also, you can parse the name table from a True Type or Open Type font without using any system APIs; as True Type and Open Type are well-documented standards. I would start by reading these:
The Naming Table
Font Names Table
(4) Although there are other standards, such as Type 1 (PostScript) fonts, and True Type Collection files and other formats, especially on Mac.
(5) Also, when you start down this road, you will quickly realize that your seemingly simple question is actually ambiguous, and that the answer is kind of complicated, because a font can have many names (a family name, a full font name, a style name, a PostScript name, etc.).
(6) And not only does a font have multiple names, it can have each of those names in multiple languages and encodings.
Any clarification would make this a better question. -
How to get the Database type from weblogic Db connection
I want to use database version control in my application . that means different database type use different Sql Statement. Such as in weblogic7.0 if I create SqlServer JDBC pool then I will use some special Sqlserver sql Statement . such as some join statement. If I create Oralce JDBC pool then I have to use different Sql statement . because these two database support different Sql statement.
What my question is how to get the database type from the connection.For a normal jdbc driver you can use
Connection.getMetaData()
To get the meta data, in particular the getDatabase...() methods.
That might or might not work.
However, at the very least in the server you have access to the weblogic properties so you can parse the pool property to figure it out. -
How can get the console window name of the current form?
How can get the console window name of the current form?
Try the various get methods of the viewObject such as getQuery:
http://www.oracle.com/webapps/online-help/jdeveloper/10.1.2/state/content/navId.4/navSetId._/vtAnchor.getQuery%28%29/vtTopicFile.bc4jjavadoc%7Crt%7Coracle%7Cjbo%7CViewObject%7Ehtml/ -
How to get the report server name in Forms 10g.
How to get the report server name in Forms 10g.
I'm using the Application Server 10g 10.1.2.Hello,
I do not think that you can get this value from anywhere. A solution is to put the Reports server name in an environment variable stored in the /forms/server/default.env file, then to query it at Forms runtime with the TOOL_ENV.Getvar() built-in.
Francois -
How to get the store procedure name inside this store procedure?
how to get the store procedure name inside this store procedure?
Why cant you get the procedure name as hard code as the proc name is going to change.
Are you looking for getting the parent proc name from child proc name which is getting executed within parent proc?
Try the below:
--Parent Proc
Alter Proc sp_test
as
Begin
Declare @s varbinary(MAX) = Cast('sp_test' as Varbinary(MAX));
SET CONTEXT_INFO @s;
exec sp_test2
End
--Child proc
Alter proc sp_test2
as
SELECT Cast(CONTEXT_INFO() as varchar(100));
--Test execution
Exec sp_test
Please mark this reply as answer if it solved your issue or vote as helpful if it helped.
[Blog] -
How to get the field row name of database from a form?
Hello experts,
I am newer in OIM and developments with the API's.
I have this environment,
one resource that have the attribute department
relationship with the database row
UD_RESOURCE1_DEPARTMENT and other resource with the same attribute in, UD_RESOURCE2_DEPARTMENT
I am programing one java class that put values in the
form field through the table name, sample,
UD_RESOURCE_DEPARTMENT.
I let some code:
# Hash table with the value of Department
myMap.put("UD_RESOURCE_DEPARTMENT", value);
# and save in the resource form
tcFormInstanceOperationsIntf tcform = (tcFormInstanceOperationsIntf)tcUtilityFactory.getUtility(dataProvider,"Thor.API.Operations.tcFormInstanceOperationsIntf");
tcform.setProcessFormData(Long.parseLong(formKey), myMap);
But this solution implies know the name of the field in the database and not is a global solution.
I am interesting in know how I can obtain the name of the
row field of the database for the atribute. Does anybody know how to obtain the row field name of database from an IT Resource or through the field name of the form?
Is this the correct way to store data in a form?
Thanks in advanced.Hi,
Thank you.
I have seen this function in the OTN help, but how can i get the index number. My requirment is when saving the data, I need to save both the value and the element name into the database,
Also it is tabular block, more than one rows
Thanks again -
How to get the database table field names from program
Hi,
Can any one tell me,whether any function module is there which can get the table field name and its details ,when we pass database table name to it.
Thanks in Advance
<REMOVED BY MODERATOR>
Regards
Shibin
Edited by: Alvaro Tejada Galindo on Feb 14, 2008 12:41 PMHi,
DD02L Table contains the SAP Tables.
DD02T Table contains the SAP Table Texts.
DD01L Table contains the Domains
DD01T Table contains the Domain Texts.
DD03L Table contains the Table Fields.
DD03T Table contains the Table Field Texts. (Language Dependent)
DD04L Table contains the Data Elements.
DD04T Table contains the Data Element Texts.
DD05s Table contains the Foreign Key Fields
last words with L and T only. L->Database Fetch T-> Text
For ur question use table DD03L or DD03T.
Regards,
Chandru -
How to get the available profile names in oracle database
How we can get the available profile names in oracle 11g
Hi;
It isnt to check from dictionary ?
select * from dictionary where table_name like '%PROFILE%'
PS:Please dont forget to change thread status to answered if it possible when u belive your thread has been answered, it pretend to lose time of other forums user while they are searching open question which is not answered,thanks for understanding
Regard
Helios -
How to get the failover partner name from C++ client
Hi All,
I have configured the mirroring session for my application.
I want to modify the connection string with failover partner name.
Could any one please let me to know how to get the failover partner instance from C++ client dynamically.
Thanks,
Prasad.Are you looking for this?
http://www.connectionstrings.com/sql-server-2012/
http://stackoverflow.com/questions/25534972/auto-failover-multiple-connections-to-mirror-database-when-principal-goes-down -
How to get the pull path name from a file upload window
Hello everyone!
I have encountered the following problem with the following JSP code:
<form method="post" action="filename.jsp">
Upload JAVA program:
<input type=file size=20 name="fname" accept="java">
<input type=submit value="go">
</form>
<%
String s = "";
if (request.getParameter("fname") != null)
s = request.getParameter("fname")
%>
The value of s is alway the filename. However I want to get the full path in addition to the filename, so that I can read the file. Does anyone know how to get the pull name of the file?
thanks a lot in advance,Dear Sir,
thanks a lot for your reply. Please let me explain what I intended to do: I want to upload a file from the local machine and then read the content of the file. Therefore I need to the fullpath of the filename like /var/local/file.java instead of file.java. The latter is what I got.
The problem I have with your code is that the function like "request.getServerScheme()" is not recognized. Maybe is it because I didn't install servelet package? I only installed javax package btw. Also my application runns on Tomcat server if this could give you some information. The error message I had is as follows:
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
[javac] Compiling 1 source file
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:133: cannot resolve symbol
symbol : method getServerScheme ()
location: interface javax.servlet.http.HttpServletRequest
url = request.getServerScheme()
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:136: cannot resolve symbol
symbol : method getServerScheme ()
location: interface javax.servlet.http.HttpServletRequest
+ ((("http".equals(request.getServerScheme()) && request.getServerPort() != 80)
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:137: cannot resolve symbol
symbol : method getServerScheme ()
location: interface javax.servlet.http.HttpServletRequest
||("https".equals(request.getServerScheme()) && request.getServerPort() != 443))
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:139: cannot resolve symbol
symbol : method getServletConfig ()
location: interface javax.servlet.http.HttpServletRequest
+ "/" + request.getServletConfig().getServletName()
^
An error occurred at line: 36 in the jsp file: /addExercise.jsp
Generated servlet error:
/usr/local/jakarta-tomcat-5.0.12/work/Catalina/localhost/tutor/org/apache/jsp/addExercise_jsp.java:140: cannot resolve symbol
symbol : variable path
location: class org.apache.jsp.addExercise_jsp
+ "/" + path
^
5 errors
org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:128)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:413)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:453)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:437)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
Maybe you are looking for
-
How to grab system time in nano seconds?
Is there any way to grab the system time in nano seconds? Thanks!
-
Why are some websites displayed with added question marks inside black diamonds
Numbers are displayed with question marks inside black triangles before and following, possibly as column separators. == This happened == Every time Firefox opened == I attempted to access financial websites
-
My specs are in my sig. I'm running Windows 2000. When I built my new machine, I used a 160GB Maxtor drive that I had in my old machine. Now, my old machine suffered from the 130GB drive limit, so was used as such for a few months. It has a single
-
Pacman: Possible bug with readonly filesystems
Background info I have the following partitions on my desktop: /boot /home /opt /usr /usr/local /var /var/local Now, I normally have /, /home and /var mounted read-write and /boot, /opt, /usr, /usr/local and /var/local mounted read-only (if I crash t
-
I have two PCs connected to the router by wired and they are working fine. My laptop was working fine with the wireless until I install AVG anti virus program on it. Will a anti virus program be the cause of my problem. I cannot connect to the intern