How would you loop through a SQL result set stored in the CF variable named my “results” and output the result set columns named “cola” and “colb” in an html table?
<table>
<cfoutput query=”results”>
<tr>
<td>#cola#</td>
<td>#colb#</td>
</tr>
</cfoutput>
</table>
Given the url http://localhost/test.cfm?printmesg=yes How would you write an if statement which would echo the message “hello world!” if the url parameter printmesg equals “yes”.
<cfif isDefined(”url.printmesg”) and url.printmesg IS “yes”>
hellol world!
</cfif>
When is it appropriate to use <cfparam> versus <cfset>?
<cfparam> allows you to set a default parameter if that variable does not have a value bound to it.
<cfset> merely sets the value of a given variable.
Given the datasource named “mydb” and a SQL stored procedure named “mystoredproc” which takes the following two parameters one VARCHAR param and one INTEGER parameter respectively, how would you declare this using the cold fusion tags <cfstoredproc>, <cfprocparam>, and <cfprocresult>?
<cfset param1 = “this is my test string”>
<cfset param2 = 1>
<cfstoredproc datasource=”mydb” procedure=”mystoredproc”>
<cfprocparam type=”IN” cfsqltype=”CF_SQL_VARCHAR” dbvarname=”@parama”
value=”#param1#”>
<cfprocparam type=”IN” cfsqltype=”CF_SQL_INTEGER” dbvarname=”@paramb”
value=”#param1#”>
<cfprocresult name=”myprocresult”>
</cfstoredproc>
How do you call a module named “testmod.cfm” with the parameters param1=”yes” and param2=5?
<cfmodule template=”testmod.cfm”
param1=”yes”
param2=5>
When is it appropriate to use <cfinclude> versus <cfmodule>?
Given two tables:
movie
——————
| id |
|—————-|
| title |
| rating |
| length |
| country |
——————
actor
——————
| id |
|—————-|
| movie_id |
| name |
——————
How would you write a SQL statement to find the names of all the actors associated with a movie titled “fight club”?
SELECT actor.name
FROM movie INNER JOIN actor ON movie.id = actor.movie_id
WHERE movie.title = ‘Fight Club’
movie
——————
| id |
|—————-|
| title |
| rating |
| length |
| country |
——————
director
——————
| id |
|—————-|
| movie_id |
| name |
——————
How would you write a LEFT JOIN statement to return a result set of movie.title’s and director.name’s?
SELECT
movie.title,
director.name
FROM movie LEFT JOIN director ON movie.id = director.movie_id
If there are no indices defined on any of the columns in the above two tables, which columns would you index to speed up the LEFT JOIN query?
movie_id
How would you write a simple stored procedure in TSQL which takes a movie_id and returns all the directors associated with it?
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE procedure [dbo].getDirector (
@movie_id INT
)
SELECT name FROM directors WHERE movie_id = @movie_id
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
What are the advantages and disadvantages of using stored procedures versus calling SQL inline in Cold Fusion?
Stored procedures abstract database logic from server side code. They also offer performance benefits in pushing application logic to the database side.
The disadvantage is that if they are poorly written then they can hinder database performance and make development a little more obfuscated.
How would you format some text using css to be verdana and bold?
.myfontclass {
font-family: Verdana;
font-weight: bold;
}
What is the difference between absolute and relative div positioning?
Absolute is from the absolute 0,0 position in the top left corner of the browser window. Relative is relative from the positioning of where the div is declared within the html body.
How would you declare an inline css to format the table with a background color of “yellow” and give the table cell a right margin of 10 pixels?
<style>
table {
background-color: yellow;
}
td {
margin: 0 10px 0 0;
}
</style>
<table>
<tr>
<td>Hello world</td>
</tr>
</table>