Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

faculty.cfc 1.2 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  1. component {
  2. // Function to read all students
  3. function getAllStudents() {
  4. var students = [];
  5. // Define the query
  6. var allQuery = new query(datasource="task");
  7. allQuery.setSQL("SELECT * FROM student");
  8. // Execute the query
  9. var result = allQuery.execute();
  10. // Check if the query executed successfully
  11. if (isQuery(result)) {
  12. // Loop through the query result
  13. while (result.next()) {
  14. var student = {
  15. "sid": result.sid,
  16. "sname": result.sname,
  17. "major": result.major,
  18. "level": result.level,
  19. "byear": result.byear
  20. };
  21. // Append the student to the students array
  22. arrayAppend(students, student);
  23. }
  24. // Close the query result
  25. result.close();
  26. } else {
  27. // Log an error or handle the case when the query execution fails
  28. writeLog(file="application", text="Failed to execute query: #allQuery.getSql()#");
  29. }
  30. // Return the array of students
  31. return students;
  32. }
  33. }
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...