Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: PL-SQL Noobie
Chad wrote:
> Do you know how to do this T-SQL in PL-SQL, namely, move a single record
> query result columns into local variables?
>
>
>
> BEGIN
>
> DECLARE @PersonId int
>
> DECLARE @FirstName varchar(50)
>
> DECLARE @LastName varchar(50)
>
>
>
> SET @PersonId = 1
>
>
>
> --Return a single record
>
> SELECT
>
> @FirstName = ISNULL(FirstName,''),
>
> @LastName = ISNULL(LastName,''),
>
>
>
> FROM
>
> People
>
> WHERE
>
> PersonId = @PersonId
>
> END
>
>
Try this:
DECLARE
PersonID NUMBER := 1001;
FirstName VARCHAR2(50);
LastName VARCHAR2(50);
BEGIN
SELECT FirstName,LastName INTO FirstName,LastName
FROM People WHERE PersonID = PersonID;
END;
/
> Also, can someone refer me to a good source of PL-SQL documentation similar
> to MS SQL' Books Online (PL-SQL-specific stuff to learn the syntax) > >
Have you looked at the Oracle documentation? Try the following PL/SQL doc:
http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14261/toc.htm
HTH,
Brian
-- =================================================================== Brian Peasland oracle_dba_at_nospam.peasland.net http://www.peasland.net Remove the "nospam." from the email address to email me. "I can give it to you cheap, quick, and good. Now pick two out of the three" - UnknownReceived on Wed Jun 07 2006 - 10:47:30 CDT
![]() |
![]() |