Caché Database Learning notes (3)

Source: Internet
Author: User
Tags terminates server port

Directory

Query function and its test

Rebuilding the Index Table

Management Portal Introduction

Remote Access Ensemble

===================================================

===================================================

Query function and its test:

How Query works:

. CLS section:

First, set the function name, incoming variable, and outgoing variable list containing three Classmethod:execute, Fetch, Close, based on the query incoming data to create an index table IDXA (need to build in portal) to declare query

Execute sets the basis for finding data, including all primary keys and indexes, stored in the Qhandle array

Fetch as principal, incoming lookup basis (Qhandle), Row (required list), AtEnd (0 can proceed, 1 terminates)

Set initial value: AtEnd = 1 (terminates if no data is found), row is empty, lookup is set back to variable by array function, call routine, assign return value to individual variable, prepare for Next loop

Query Getplan (Status as%integer, StartDate as%integer) as%query (Rowspec = "planno:%string,patientid:%string,startdate :%integer,enddate:%integer,module:%string,status:%integer,doctorid:%string ") [Sqlproc]{}ClassMethod Getplanexecute (ByRef qhandle as%binary, Status as%integer, StartDate as%integer) as%status{Set qhandle (0) = " " ; Planno set Qhandle (1) = StartDate set Qhandle (2) = Status Quit $$ $OK}classmethod getplanclose (byre F Qhandle as%binary) as%status [placeafter = Getplanexecute]{Kill qhandle Quit $$ $OK}classmethod GETP Lanfetch (ByRef qhandle as%binary, ByRef Row as%list, byref AtEnd as%integer = 0) as%status [placeafter = Getplanexecu         Te]{Set AtEnd = 1 Set Row = "" Set Planno = Qhandle (0) Set startdate = Qhandle (1) Set Status = Qhandle (2) Set Data = $ $GetPlan ^         Ps.plan (Planno, StartDate, Status)Set AtEnd = $ListGet (data,1) Set Row = $ListGet (data,2) set Qhandle (0) = $Li Stget (data,3) set Qhandle (1) = $ListGet (data,4) set Qhandle (2) = $ListGet (data,5) Quit $$ $OK}

. mac File section:

Query logic:

Start: Incoming startdate and Status,planno are empty, according to status and Idxa to find the first data after the startdate into the while loop: The purpose is not to jump out of the fetch without the valid data

Process: Determine whether the startdate meet the conditions, if not meet jump and stop fetch according to IDXA, Status, StartDate find a data and set Planno judge Planno not empty time, to find and outgoing data Otherwise, follow the previous method to find the next data and enter the loop again the outgoing atend value (0 can continue into the fetch,1 stop fetch), Row (returned list), Planno, Status, StartDate based on the three to find the next piece of data

Getplan (Planno, StartDate, Status) public{If (Planno ' = "") {Goto Next}//-1 means looking forward from the back, since the purpose of the function is to find the time closest, so looking backwards from the back will avoid a lot of problems Set StartDate = $Order (@[email protected] ("IDXA", Sta Tus, StartDate),-1) while (startdate ' = "") {If (S Tartdate<20150926) {Goto Exit}next Set Planno= $Order (@[email protected] ("IDXA",Status, StartDate, Planno),-1) If (Planno '= "") {Set Data= $Get (@[email protected] (Planno))Set Patientid= $ListGet (Data,$$ $PsPlanPatientId) Set StartDate= $ListGet (Data,$$ $PsPlanStartDate) Set EndDate= $ListGet (Data,$$ $PsPlanEndDate) Set Module= $ListGet (Data,$$ $PsPlanModule) Set Status= $ListGet (Data,$$ $PsPlanStatus) Set Doctorid= $ListGet (Data,$$ $PsPlanDoctorId) Set Row= $ListBuild (Planno,Patientid, StartDate, EndDate, Module, Status, Doctorid) Set AtEnd= 0Goto Exit} Set StartDate= $Order (@[email protected] ("IDXA",Status, StartDate),-1)} Exit Set Ret= $ListBuild (AtEnd,Row, Planno, StartDate, Status) Quit Ret}

The test method for Query is written in routine,

Do Testgetplan^ps.plan () Testgetplan () public{         Set rs = # #Class (%resultset).%new ("Ps.Plan:GetPlan") do         Rs. Execute (4, 20160926) while         Rs. Next ()         {                   w "Planno" _rs. GetData (1) _ "StartDate" _rs. GetData (3) _ "Status" _rs. GetData (6),!         }         Do Rs. Close ()         Kill rs         Quit}

Note that when an attribute of a non-primary key is indexed, lowercase in the I table is automatically converted to uppercase, a non-required attribute is indexed, and a space is automatically prepended to the I table. My own speculation here is that at index time, the non-required properties may be empty, and in routine, they are indexed according to this property, to prevent potentially empty data from being indexed and automatically preceded by a space. Therefore, when writing query routine, pay attention to the space match when coding, while in test, pay attention to the problem of case and space.

===================================================

Rebuild Index Table:

When the data is entered normally, the data is stored in the D table, and query uses the index table (i table) when it finds the data. The I table is based on the settings in the D table and the CLS file.

Management Portal/system Explorer/sql

Change the namespace, open the tables drop-down bar on the left to find the name of the table you need to rebuild

On the right you can see the basic information, find the above action/rebuild indices can establish I table

In addition, open table can view all the contents of the current table, at the bottom of the current page can adjust the number of bars to display data

==========================================================

Management Portal Introduction:

In addition to the above system Explorer/sql, the system explorer/globals is commonly used for importing and viewing tables, system operation configuration, System Administration for management, etc.

==========================================================

Remote Access Ensemble:

The firewall must first be shut down for remote access by other servers.

When accessing other servers, configure them first.

Left-right corner icon, prefered server/addedit ...

LocalHost this line can see its own Port/web server port configuration situation, click Add added additional server IP address, port and network port to save

View prefered server again to see the current preferred server, in remote system access you can open any remote to the server studio/terminal/management portal/ Documentation

Caché Database Learning notes (3)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.