Hello everybody,
i create a stored producedure in Oracle that will get the user name who connect to Oracle database.
For exemple, i declare a variable "o_user" and i want to assign the value of the query (select user from dual) to the variable.
It's possible?
i know that it's possible to do by this statement "select user into o_user from dual". But i want to know if we have another way to do by using the operation ( := ) to assign.
So thanks before hand, and sorry for my poor english.
Trakal
7 18154
Hello everybody,
i create a stored producedure in Oracle that will get the user name who connect to Oracle database.
For exemple, i declare a variable "o_user" and i want to assign the value of the query (select user from dual) to the variable.
It's possible?
i know that it's possible to do by this statement "select user into o_user from dual". But i want to know if we have another way to do by using the operation ( := ) to assign.
So thanks before hand, and sorry for my poor english.
Trakal
make use of a CURSOR if u want to use assignment operator: - DECLARE
-
o_user VARCHAR2(10);
-
CURSOR C1 IS SELECT USER FROM DUAL;
-
BEGIN
-
FOR I IN C1 LOOP
-
IF(C1%FOUND) THEN
-
o_user := I.user;
-
END IF;
-
END LOOP;
-
END;
Hello amitpatel66 and everybody,
So thanks for your quickly answer. this answer is useful for me.
But if you don't mind me, can i ask you another question because this code is look complicated for my programme.
I don't know if you know SQL Server.
Let see this example in SQL Server
CREATE PROCEDURE [dbo].[test]
( @username[nvarchar] (64) = NULL)
AS
IF@username IS NULL
BEGIN
SELECT DISTINCT @username = SYSTEM_USER
END....
This is the extrait of a procedure that let to assign directly the name of database's user. The procedure have a user name as a parameter. it verify if this parameter is null or not, if it's null, it will assign the name of user to this parameter.
I want to use the operator assign (:=) because i hope that it has a query look like the one in SQL Server. it's maybe simplier for generate.
(if you don't understand my question, please let me know, i'll reforme my question)
thanks in advance.
Hello amitpatel66 and everybody,
So thanks for your quickly answer. this answer is useful for me.
But if you don't mind me, can i ask you another question because this code is look complicated for my programme.
I don't know if you know SQL Server.
Let see this example in SQL Server
CREATE PROCEDURE [dbo].[test]
( @username[nvarchar] (64) = NULL)
AS
IF@username IS NULL
BEGIN
SELECT DISTINCT @username = SYSTEM_USER
END....
This is the extrait of a procedure that let to assign directly the name of database's user. The procedure have a user name as a parameter. it verify if this parameter is null or not, if it's null, it will assign the name of user to this parameter.
I want to use the operator assign (:=) because i hope that it has a query look like the one in SQL Server. it's maybe simplier for generate.
(if you don't understand my question, please let me know, i'll reforme my question)
thanks in advance.
Hi,
In PLSQL, you can assign a value to a variable either using INTO clause or using an explicit cursor as I have shown above.
good morning,
Thanks alot for your answer.
Have a nice day
Saii 145
Recognized Expert New Member
USER can be simply assigned to a variable just like sysdate. You dont need to do select ....from dual;
<variable>:=USE R;
USER can be simply assigned to a variable just like sysdate. You dont need to do select ....from dual;
<variable>:=USE R;
can i do something like SQL Server?
For exemple: SELECT DISTINCT o_user := USER FROM DUAL;
I think that it's impossible. But i just try to ask you all if you already see this problem and solve it.
Thank.
Saii 145
Recognized Expert New Member
can i do something like SQL Server?
For exemple: SELECT DISTINCT o_user := USER FROM DUAL;
I think that it's impossible. But i just try to ask you all if you already see this problem and solve it.
Thank.
I am not sure about the SQL Server.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: rickcheney |
last post by:
I just changed my Access 2002 database to a SQL Server ADP project. I
had a form where the user entered a value into a text box and when a
command button on the form was clicked a Report was opened. The reports
record source is a query. The query uses the value from the form text
box to restrict the query.
Table name = EggsTable
one of the columns in the table is named: EggColor
Form name = EggColorForm
Form text box name = ColorTextBox
|
by: Omar K |
last post by:
Hi, I am quite new to frontpage and SQL but I have a Stock Control
access database / frontpage to set up. My last problem deals with the
automatic updating of the total quantity of stock with parts move in or
out of the warehouse. The following shows my page layout
(i posted this on the frontpage group, but I think their level is too
high for my skills, since i use the DRR most of the time)
I have form.htm that asks the user for two...
|
by: MLH |
last post by:
Suppose I have this simple SQL string...
SELECT tblDrivers.DriverID, tblDrivers.DName
FROM tblDrivers
WHERE (((tblDrivers.DName) Like "N*"))
ORDER BY tblDrivers.DriverID;
And suppose that its not a saved querydef -
just an SQL string that I cooked up in code
and assigned to a global var strMySQL.
|
by: devx777 |
last post by:
Hello,
I am trying to find some information or an example on how to build a
dynamic query in DB2 that would allow me to join a table which its name
is stored as a field value on another table.
I have done this in the past in SQL server, but DB2 is not as easy...
Anyone out there that can help me?
Your help will be much appreciated.
|
by: woollymammoth |
last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be an easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record is named "Try". The VB script function accessing the record value is running on a web hosting server with ASP.Net 2.0 on a web page. Result always is it "can't convert from a Field to type 'String'". Printing out the SQL variable results in...
| |
by: woollymammoth |
last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be a really easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that record is named "Try". The VB script function accessing the record value is running on a web hosting server with ASP.Net 2.0 on a web page. Result always is it "can't convert from a Field to type 'String'". Printing out the SQL variable results...
|
by: Tony K |
last post by:
How would I assign the result of a SQL query to a variable. The result of
the following statement will ALWAYS result in 1 row returned.
SELECT ProductDescription, ProductID
FROM Products
WHERE (ProductIDNumber = ?)
How do I assign the...say, ProductDescription to a variable called prodDesc?
Thanks,
|
by: Peter Nurse |
last post by:
Two (almost) identical SQL Server databases (DB1 backed up and
restored to DB2 yesterday). DB2.dbo.GetSchPaymentsTD took 1.5 seconds
(!) to execute DB1.dbo.GetSchPaymentsTD took less than a millisecond
with identical code and data.
I'm guessing this is some sort of indexing issue and the code is below
but I'm not sure it's relevant because . . .
.. . . I dropped DB2.dbo.GetSchPaymentsTD and then recreated it (with
identical code)...
|
by: RachH |
last post by:
I am using Access 2003 and need some guidance on the correct way to reference a variable in two different procedures when the variable's value is based on a SQL query.
The database form has a button that, when clicked, will send an email, summarizing in the subject line the $ amount sold so far for the day. This email may be sent several times per day as needed, depending on the pricing volume. Then at the end of the day when all the pricing...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |