Question
How to assign query results to variables?

Answers

If you want to assign results from SELECT statements to variables, you can use the INTO clause, which an extension of SELECT statements for PL/SQL. The sample code below shows some good example on INTO clause:

DECLARE
total NUMBER;
now DATE;
fname VARCHAR2(10);
lname VARCHAR2(10);
BEGIN
SELECT COUNT(*) INTO total FROM employees;
DBMS_OUTPUT.PUT_LINE('Count = ' || TO_CHAR(total));
SELECT SYSDATE INTO now FROM DUAL;
DBMS_OUTPUT.PUT_LINE('Now = ' || TO_CHAR(now, 'SSSSS'));
SELECT first_name, last_name INTO fname, lname
FROM employees
WHERE employee_id = 100;
DBMS_OUTPUT.PUT_LINE('Name = ' || fname || ' ' || lname);
END;
/
Count = 107
Now = 82375
Name = Steven King   Your Comment




More Software Questions..
What is the inputsplit in map reduce software?

What is software configuration management?

What Is Java Api For Xml-based Rpc (jax-rpc)?

How can you implement fine-grained auditing?

What is IBM’s simple explanation for Big Data’s four critical features?

What is static synchronized method in JDBC API? Give an example?

What does the NULLIF function do?

What happens if a start method is not invoked and the run method is directly invoked?

Should we override finalize method

what is the difference between mysql_fetch_array and mysql_fetch_object?

How will XML affect my document links?

Why to use Style Sheets?

What are Filters in MVC?

Can you explain Application layer in OSI model?

How to define new testplan attributes?

What are the minimum system requirements to run Photoshop? Is it possible to run Photoshop over linux?

Which oracle package is used to manage the oracle lock management services?

What is Latch Up? Explain Latch Up with cross section of a CMOS Inverter. How do you avoid Latch Up?

What is marker interface?

What types of partitioning are there for BW?



Search
Can you Answer!!
  • Q What are the pros and cons of graph database?
  • Q What is the differentiate between tailor made homemade and readymade?
  • Q Different types in LO's?
  • Q O.P. Jindal Global University (JGU) is in which state?
  • Q Who was the son of Chandragupta Maurya?
  • Q MySQL - Speed of SELECT Queries
  • Q Which feature now common in mobile phones gets its name from a tenth-century Danish king?
  • Q What is drx in gsm technology?
  • Q How can i use forms for pull-down navigation menus?
  • Q In the text, which of the following challenger will first time supervisors most likely face as they transition to their new job responsibilities? (A)Accepting criticism for unintentional mistakes made by their employees (B)Dealing with individuals who harbor a grudge because they were not chosen for the supervisory position (C)Resisting the urge to perform work assigned to employees reporting directly to them (D)Supporting management when they disagree with management's decisions (E)All of the above
  • Q What jobs have you held ?