UNIT 7 Flashcards

1
Q

______ a set of Transact-SQL (T-SQL) statements that is compiled and stored as a single database objects for later repetitive use.

A

Stored procedure

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

API

A

Application Programming Interface

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

logically, a stored procedure consists of

A

header, body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

defines the name of the stored procedure, the input and output parameters, and some miscellaneous processing options. You can think of it as an API declaration of the stored procedure.

A

header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

contains one or more Transact-SQL statements to be executed at runtime.

A

body

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

the one way to change a stored procedure

A

drop or re-create

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Two ways to prevent the error “Msg 2714, Level 16, State 3, Procedure pr_Eqipment_Get, Line 4
There is already an object named pr_Equipment_Get’ in the database.”

A

use

Drop Procedure pr_EqipmentByEqTypeID_get

go // this will say that we need to execute the next line of code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

create stored procedure for MYSQL

A

CREATE OR REPLACE PROCEDURE pr_getEquipment()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

other way to write drop and create procedure in MS SERVER

A

IF object_id(‘ pr_equipment_get’) is not null – we check if theres an object called pr_equipment_get,if it exists,delete it
begin
drop PROCEDURE pr_equipment_get
end

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

what is the other way to change a stored procedure?

A

Alter Procedure statement

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

execute a procedure in mysql

A

call pr_Get_Name ()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

execute a procedure in ms server

A

exec pr_Get_Name()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

altering procedure in ms server

A

alter procedure pr_Equipment_Get

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

altering procedure in mysql

A

create or replace procedure pr_Equipment_Get

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

When you are creating or changing a stored procedure, keep in mind the ____

A

limits

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

The name of the procedure is a standard ______________. The maximum length of any identifier is ___ characters.

A

Transact-SQL identifier

128

17
Q

Stored procedures may contain up to ________ input and output parameters.

A

2,100

18
Q

There are four ways to receive information from a stored procedure:

A
  • Returning result sets
  • Using input and output parameters
  • Using return values
  • Global cursor
19
Q

To obtain a result set from a stored procedure, insert a ____________ that returns a result set into the body of the stored procedure. The simplest way is by using a ____ statement, but you could also call another stored procedure.

A

Transact-SQL statement

Select

20
Q

An alternative way to send values from a stored procedure to the caller is to use a _________ _______

A

return value

21
Q

It is possible, however, to assign default values________ to the parameters so that the user is not required to supply them.

A

default values

@make varchar(50) = ‘%’, @model varchar(50) = ‘%’

22
Q

The procedure is designed as a ___________ that accepts T-SQL wild cards. You can execute this stored procedure with normal values:

A

small search engine

Execute ap_EqIdByMakeModel_List_6 ‘T%’ , ‘Portege%’

23
Q

You do not have to follow parameter order if you pass parameters by name. You must type the name of the parameter and then assign a value to it. The parameter name must match its definition, including the @ sign.

A

Passing Parameters by Name

24
Q

Even more important is the opportunity to create a method that makes code more ____ and ____.

A

readable and maintainable

25
Q

database objects example

A
  • Triggers
  • Views
  • User-defined functions
26
Q

stored procedure types

A
  1. User-defined
  2. System
  3. Extended
  4. Temporary
  5. Global temporary
  6. Remote
  7. CLR
27
Q

_________ stored procedures are simply plain, stored procedures assembled by administrators or developers for later use.

A

user-defined

28
Q

use_________ which returns the mnumber of affacted rows per SQL statement;

A

@@rowcount