PLSQL FOR LOOP IMPLICIT CURSORThere are 2 tables EMPLOYEES and DEPARTMENTS with departmentid as primary key for DEPARTMENTS and foreign key on EMPLOYEES.I want to print all the employee names that belong to a particular department.I know it can be easily achieved by JOINS or EXPLICIT cursors.I thought why not try with FOR loop and a IMPLICIT cursors.My question is if it is syntactically correct to write INTO like this.If so why is not assigning any values DECLARE.TYPE.TYPE. emplastname employees.TYPE.TYPE. deptdeptname departments.TYPE.DEFAULT 0.PLSQL Cursors Learn PLSQL programming in simple and easy steps starting with PLSQL syntax, Environment Setup, Operators, Transactions, Date and Time, data types.Download Game Brothers In Arms Art Of War 320 X 240 Resolution Example '>Download Game Brothers In Arms Art Of War 320 X 240 Resolution Example .FOR i IN SELECT DISTINCT departmentid, departmentname.INTO deptdeptid, deptdeptname.FROM departments.COUNT vCOUNT 1.DBMSOUTPUT.PUTLINEHELLOdeptdeptid deptdeptname.FOR j IN SELECT employeeid, lastname.INTO empempid, emplastname.FROM employees.WHERE departmentiddeptdeptid.For Update Cursor In Pl Sql' title='For Update Cursor In Pl Sql' />DBMSOUTPUT.PUTLINEempempid emplastname.COUNT vCOUNT 1.END LOOP.DBMSOUTPUT.PUTLINEvCOUNT.PLSQL Static SQLStatic SQL is a PLSQL feature that allows SQL syntax directly in a PLSQL statement.This chapter describes static SQL and explains how to use it.Description of Static SQLStatic SQL has the same syntax as SQL, except as noted.Topics.Statements.These are the PLSQL static SQL statements, which have the same syntax as the corresponding SQL statements, except as noted SELECT this statement is also called a queryFor the PLSQL syntax, see SELECT INTO Statement.Data manipulation language DML statements Transaction control language TCL statements LOCKTABLE for syntax, see Oracle Database SQL Language ReferenceA PLSQL static SQL statement can have a PLSQL identifier wherever its SQL counterpart can have a placeholder for a bind variable.The PLSQL identifier must identify either a variable or a formal parameter.In Example 6 1, a PLSQL anonymous block declares three PLSQL variables and uses them in the static SQL statements INSERT, UPDATE, DELETE.The block also uses the static SQL statement COMMIT.Example 6 1 Static SQL Statements.DROP TABLE employeestemp.CREATE TABLE employeestemp AS.SELECT employeeid, firstname, lastname.FROM employees.For Update Cursor In Pl Sql' title='For Update Cursor In Pl Sql' />
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
November 2017
Categories |