The Mother Board

Motherboards.org forums. Free tech support, motherboard ID, and more.
It is currently Tue Sep 18, 2018 9:43 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: PL/SQL ... Anybody?
PostPosted: Mon Nov 28, 2005 11:21 pm 
Offline
Initiate
Initiate

Joined: Fri Jan 23, 2004 11:13 pm
Posts: 79
Hi

Im trying to learn some PL/SQL here and I was just wondering if anyone knew how to save the result of a query into a variable.
For example

SELECT userName FROM userTable WHERE userID = 1;

and save that into a variable called user_name

Thanks
Chris Drogaris


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Nov 28, 2005 11:47 pm 
Offline
Lead Mobo-fu Master
Lead Mobo-fu Master

Joined: Sun Dec 16, 2001 1:01 am
Posts: 14300
Location: Maine
Google is a wonderful tool.... :P

PL/SQL Tutorials
http://www.ilook.fsnet.co.uk/ora_sql/sqlmain2.htm

_________________
Compaq-Fu Master
Ctechinfo funding drive information


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Nov 29, 2005 1:36 pm 
Offline
Black Belt 2nd Degree
Black Belt 2nd Degree

Joined: Mon Aug 09, 2004 7:33 pm
Posts: 2741
Location: Milwaukee - Wisconsin
ooooyeah...this is my job. =)

SELECT userName
into user_name
FROM userTable
WHERE userID = 1;

it's actually better to use cursors, and you'll definitely want to look into those as early as you can, it makes things VERY easy later on :wink: :

Code:
declare
v_user_name varchar2(20);
cursor userName is
SELECT userName
FROM userTable
WHERE userID = 1;

begin
open userName;
fetch userName into v_user_name;
close userName;
dbms_output.put_line('User name is: ' || v_user_name);

end;
/


-Roach

_________________
Lian Li Lancool First Knight Series PC-K59W
Intel Core i7-960 Bloomfield 3.2GHz
EVGA X58 FTW3 132-GT-E768-TR
EVGA GeForce GTX 1070 FTW GAMING ACX 3.0
G.SKILL Ripjaws Series 12GB (3 x 4GB)
Crucial M4 128gb SATAIII SSD x2
Crucial M4 256gb SATAIII SSD
OCZ Saber 1000 960GB Enterprise SSD
Corsair Professional Series HX850 PSU
Dell UltraSharp U2713HM 27" w/drop ceiling mount
Logitech G930 7.1 Headset
DBPOWER RGB LED Keyboard
Logitech G402 Hyperion Fury


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group