ORDER BY 高级用法之CASE WHEN

今天在公司查看一段sql SP代码,发现了一段比较奇怪的代码。

大概长这样子:

Select * from tableA
 ORDER BY ColA ,
                CASE 
                     WHEN  type = 5 
                          THEN 200  
                      WHEN  type = 6 
                          THEN 300  
                END                  

 

小弟才疏学浅,咋一看到代码以为这样的:

Select * from tableA
WHERE type=5
ORDER BY ColA ,200
               

但是执行报错,同时也忘记了 order by 后面加数字是什么意思了。。。

果断查了一下:

示例1:
SELECT last_name, salary , hire_date
FROM EMPLOYEES
ORDER BY salary DESC;
示例2:
SELECT last_name, salary , hire_date
FROM EMPLOYEES
ORDER BY 2 DESC;
以上两个示例结果相同。
因为ORDER BY salary DESC==ORDER BY 2 DESC
salary是第二个元素,所以可以使用2来代替。
但是数字不可以使用0,也不可以超出查询的列。
例如:select * from employers
order by x;
如果employers表有九个字段,那个X的范围就是1---9
不能是0,也不能是10.

原来order by后面跟数字是代表以第几列排序的意思。

但是SP 中 用的是200...甚至300....没这么多列啊。。。

事实证明 order by 后面用case when 并不等于 order by 数字

查了相关资料,并且找个一个表来测试,

无 CASE WHEN

ORDER BY 后面不使用 CASE WHEN

测试sql代码

SELECT  [ServerId]
      ,[ServerCode]
      ,[InBound]
      ,[OutBound]
      ,[IP]
      ,[PhoneArea]
      ,[Valid]
  FROM [ServerInfo] with(nolock)
  ORDER BY Location

 

查询结果

我们可以看到IP 为192.168.130.81 的排在第一位

 

一个CASE WHEN

加上 CASE WHEN 当IP 为  192.168.130.85 时,我们返回100,其他返回1000.

代码如下

SELECT  [ServerId]
      ,[ServerCode]
      ,[InBound]
      ,[OutBound]
      ,[IP]
      ,[PhoneArea]
      ,[Valid]
  FROM [ServerInfo] with(nolock)
  ORDER BY Location
  ,CASE
    WHEN  IP='192.168.130.85'
    THEN 100
    ELSE 1000
   END

 

执行结果

我们可以看到IP 为192.168.130.81 的已经不再第一位了,192.168.130.85 的被排在了第一位。

因为IP等于192.168.130.85的我们返回了100 ,不等于192.168.130.85 的我们返回了1000

100比1000小,所以192.168.130.85 的被排在了第一位。

 

两个CASE WHEN

我们在加一个 CASE WHEN  当IP等于192.168.130.87 时,我们返回2,其他返回10.

代码如下

SELECT  [ServerId]
      ,[ServerCode]
      ,[InBound]
      ,[OutBound]
      ,[IP]
      ,[PhoneArea]
      ,[Valid]
  FROM [ServerInfo] with(nolock)
  ORDER BY Location
  ,CASE
    WHEN  IP='192.168.130.85'
    THEN 100
    ELSE 1000
   END
 ,CASE
    WHEN  IP='192.168.130.87'
    THEN 2
    ELSE 10
   END

我们可以猜一下执行结果。

第一个CASE WHEN 当IP等于192.168.130.85的我们返回了100 ,不等于192.168.130.85 的我们返回了1000

第二个CASE WHEN 当IP等于192.168.130.87的我们返回了2 ,不等于192.168.130.87 的我们返回了10

结果应该 192.168.130.87 被排在第一 ,因为第一个case when返回1000 但是被第二个CASE WHEN返回是2覆盖掉了,2最小的,所以排在第一。

 

哈哈哈。。。就是这样。。。

其实,执行结果是这样的。

 

我们可以看到192.168.130.85 被排在第一,

192.168.130.87被排在第二。

其实两个CASE WHEN是相互不影响的。

其实两个CASE WHEN的sql 结果等价于下面的sql

 

SELECT  [ServerId]
      ,[ServerCode]
      ,[InBound]
      ,[OutBound]
      ,[IP]
      ,[PhoneArea]
      ,[Valid]
     ,CASE
          WHEN  IP='192.168.130.85'
          THEN 100
          ELSE 1000
      END AS MYORDER1
      ,CASE
          WHEN  IP='192.168.130.87'
          THEN 2
          ELSE 10
       END AS MYORDER2
  FROM [ServerInfo] with(nolock)
  ORDER BY Location , MYORDER1,MYORDER2

 

好了,就这样!!!

 

转载于:https://www.cnblogs.com/178mz/p/6428958.html

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
{****************************************************************************** * * * PROJECT : EOS Digital Software Development Kit EDSDK * * NAME : EDSDKApi.pas * * * * Description: This is the Sample code to show the usage of EDSDK. * * * * * ******************************************************************************* * * * Written and developed by Camera Design Dept.53 * * Copyright Canon Inc. 2006 All Rights Reserved * * * ******************************************************************************* * File Update Information: * * DATE Identify Comment * * ----------------------------------------------------------------------- * * 06-03-22 F-001 create first version. * * * ******************************************************************************} unit EDSDKApi; interface uses EDSDKType, EDSDKError; const edsdk = 'EDSDK.DLL'; { ****************************************************************************** ********************* Initialize / Terminate Function ************************ ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsInitializeSDK Description : Initializes the libraries. When using the EDSDK libraries, you must call this API once before using EDSDK APIs. Parameters: In: None Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ------------------------------------------------------------------------------- } function EdsInitializeSDK( ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsTerminateSDK Description : Terminates use of the libraries. Calling this function releases all resources allocated by the libraries. This function delete all the reference or list objects that user has forgotten to delete. Parameters: In: None Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ------------------------------------------------------------------------------- } function EdsTerminateSDK( ) : EdsError ; stdcall; external edsdk; { ****************************************************************************** *********************** Referense Count Function ***************************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsRetain Description: Increments the reference counter of existing objects. Parameters: In: inRef - The reference for the object item. Out: None Returns: Returns a reference counter if successful. For errors, returns $FFFFFFFF. ------------------------------------------------------------------------------- } function EdsRetain( inRef : EdsBaseRef ) : EdsUInt32 ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsRelease Description: Decrements the reference counter to an object. When the reference counter reaches 0, the object is released. Parameters: In: inRef - The reference of the object item. Out: None Returns: Returns a reference counter if successful. For errors, returns $FFFFFFFF. ----------------------------------------------------------------------------- } function EdsRelease( inRef : EdsBaseRef ) : EdsUInt32 ; stdcall; external edsdk; { ****************************************************************************** ************************** Item Tree Handling Function *********************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsGetChildCount Description: Gets the number of child objects of the designated object. Parameters: In: inBaseRef - The reference of the list. Out: outCount - Number of elements in this list. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ------------------------------------------------------------------------------- } function EdsGetChildCount( inRef : EdsBaseRef; var outCount : EdsUInt32 ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsGetChildAtIndex Description: Gets an indexed child object of the designated object. Parameters: In: inRef - The reference of the item. inIndex - The index that is passed in, is zero based. Out: outBaseRef - The pointer which receives reference of the specified index. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ------------------------------------------------------------------------------ } function EdsGetChildAtIndex( inRef : EdsBaseRef ; inIndex : EdsInt32 ; var outBaseRef : EdsBaseRef ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsGetParent Description: Get the parent object. Parameters: In: inRef - The reference of the item. Out: outParentRef - The pointer which receives reference. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ------------------------------------------------------------------------------ } function EdsGetParent( inRef : EdsBaseRef; var outParentRef : EdsBaseRef ) : EdsError ; stdcall; external edsdk; { ****************************************************************************** ******************************* Property Function **************************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsGetPropertySize Description: Gets the byte size and data type of a designated property from a camera object or image object. Parameters: In: inRef - The reference of the item. inPropertyID - The ProprtyID inParam - Additional information of property. We use this parameter in order to specify an index in case there are two or more values over the same ID. Out: outType - Pointer to the buffer that is to receive the property type data. outSize - Pointer to the buffer that is to receive the property size. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ------------------------------------------------------------------------------ } function EdsGetPropertySize( inRef : EdsBaseRef; inPropertyID : EdsPropertyID; inParam : EdsInt32; var outDataType : EdsDataType; var outSize : EdsUInt32 ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsGetPropertyData Description: Gets property information from the object designated in inRef. Parameters: In: inRef - The reference of the item. inPropertyID - The ProprtyID inParam - Additional information of property. We use this parameter in order to specify an index in case there are two or more values over the same ID. inPropertySize - The number of bytes of the prepared buffer for receive property-value. Out: outPropertyData - The buffer pointer to receive property-value. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetPropertyData( inRef : EdsBaseRef; inPropertyID : EdsPropertyID; inParam : EdsInt32; inPropertySize : EdsUInt32; // var outPropertyData : EdsUInt32 ) : EdsError ; stdcall; external edsdk; var outPropertyData : Pointer ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsSetPropertyData Description: Sets property data for the object designated in inRef. Parameters: In: inRef - The reference of the item. inPropertyID - The ProprtyID inParam - Additional information of property. inPropertySize - The number of bytes of the prepared buffer for set property-value. InPropertyData - The buffer pointer to set property-value. Out: none Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsSetPropertyData( inRef : EdsBaseRef; inPropertyID : EdsPropertyID; inParam : EdsInt32; inPropertySize : EdsUInt32; InPropertyData : Pointer ) : EdsError; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsGetPropertyDesc Description: Gets a list of property data that can be set for the object designated in inRef, as well as maximum and minimum values. This API is intended for only some shooting-related properties. Parameters: In: inRef - The reference of the camera. inPropertyID - The Property ID. inPropertySize - The number of bytes of the prepared buffer for receive property-value. Out: outPropertyDesc - Array of the value which can be set up. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. EDS_ERR_INVALID_PARAMETER is returned if a property ID is designated in inPropertyID that cannot be used with GetPropertyDesc. -----------------------------------------------------------------------------} function EdsGetPropertyDesc( inRef : EdsBaseRef; inPropertyID : EdsPropertyID; var outPropertyDesc : EdsPropertyDesc ) : EdsError; stdcall; external edsdk; { ****************************************************************************** ******************** Device List and Device Operation Function *************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsGetCameraList Description: Get the camera list objects Parameters: In: None Out: outCameraListRef - the camera-list. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetCameraList( var outCameraListRef : EdsCameraListRef ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsGetDeviceInfo Description: Get information as the device of the camera of the port number etc. Device information can be acquired before OpenSession is done. Parameters: In: inCameraRef - The reference of the camera. Out: outDeviceInfo - Information as device of camera. See EdsDeviceInfo structure in EDSDKType.pas Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetDeviceInfo( inCameraRef : EdsCameraRef; var outDeviceInfo : EdsDeviceInfo) : EdsError ; stdcall ; external edsdk; { ****************************************************************************** ************************* Camera Operation Function ************************** ****************************************************************************** } {----------------------------------------------------------------------------- Function : EdsOpenSession Description: Establishes a logical connection with a remote camera. Parameters: In: inCameraRef - The reference of the camera Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsOpenSession( inCameraRef : EdsCameraRef) : EdsError ; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsCloseSession Description: Closes a logical connection with a remote camera. Parameters: In: inCameraRef - The reference of the camera Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsCloseSession( inCameraRef : EdsCameraRef ) : EdsError ; stdcall; external edsdk; { ----------------------------------------------------------------------------- Function : EdsSendCommand Description: Send the specified command to to the camera. Parameters: In: inCameraRef - The reference of the camera which will receive the command. inCommand - Specifies the command to be sent. inParam - Specifies additional command-specific information. Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsSendCommand( inCameraRef : EdsCameraRef; inCommand : EdsCameraCommand; inParam : EdsInt32 ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsSendStatusCommand Description: Sets the remote camera state or mode. Parameters: In: inCameraRef - The reference of the camera which will receive the command. inStatusCommand - Designate the particular mode ID to set the camera to. inParam - Specifies additional command-specific information. Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSendStatusCommand( inCameraRef : EdsCameraRef; inStatusCommand : EdsCameraStateCommand; inParam : EdsInt32 ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsSetCapacity Description: Sets the remaining HDD capacity on the host computer (excluding the portion from image transfer), as calculated by subtracting the portion from the previous time. Set a reset flag initially and designate the cluster length and number of free clusters. Parameters: In: inCameraRef - The reference of the camera which will receive the command. inCapacity - Designate information regarding the host computer's hard drive capacity. Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsSetCapacity( inCameraRef : EdsCameraRef ; inCapacity : EdsCapacity ) : EdsError ; stdcall ; external edsdk; { ****************************************************************************** ************************* Volume Operation Function ************************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsGetVolumeInfo Description: Gets volume information for a memory card in the camera. Parameters: In: EdsVolumeRef - The reference of the volume to get volume information. Out: outDeviceInfo - Information of the volume. See EdsVolumeInfo structure in EDSDKType.h Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetVolumeInfo( inVolumeRef : EdsVolumeRef; var outVolumeInfo : EdsVolumeInfo ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsFormatVolume Description: Formats volumes of memory cards in a camera. Parameters: In: inVolumeRef - reference of volume . Out: none Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsFormatVolume( inVolumeRef : EdsVolumeRef ) : EdsError ; stdcall ; external edsdk; { ****************************************************************************** ********************* Directory Item Operation Function ********************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsGetDirectoryItemInfo Description: Gets information about the directory or file objects on the memory card (volume) in a remote camera. Parameters: In: inDirItemRef - The reference of the directory item. Out: outDirItemInfo - Information of the directory item. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetDirectoryItemInfo( inDirItemRef : EdsDirectoryItemRef ; var outDirItemInfo : EdsDirectoryItemInfo ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsDeleteDirectoryItem Description: Deletes a camera folder or file. If folders with subdirectories are designated, all files are deleted except protected files. EdsDirectoryItem objects deleted by means of this API are implicitly released by the EDSDK. Thus, there is no need to release them by means of EdsRelease. Parameters: In: inDirItemRef - The reference of the directory item. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsDeleteDirectoryItem( inDirItemRef : EdsDirectoryItemRef ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsDownload Description: Downloads a file on a remote camera (in the camera memory or on a memory card) to the host computer. The downloaded file is sent directly to a file stream created in advance. When dividing the file being retrieved, call this API repeatedly. Also in this case, make the data block size a multiple of 512 (bytes), excluding the final block. Parameters: In: inDirItemRef - The reference of the directory item. inReadSize - Size to read inDestStream - The reference of the stream to target. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsDownload ( inDirItemRef : EdsDirectoryItemRef; inReadSize : EdsUInt32 ; inDestStream : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsDownloadComplete Description: Must be called when downloading of directory items is complete. Executing this API makes the camera recognize that file transmission is complete. This operation need not be executed when using EdsDownloadThumbnail. Parameters: In: inDirItemRef - The reference of the directory item. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsDownloadComplete( inDirItemRef : EdsDirectoryItemRef ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsDownloadCancel Description: Must be executed when downloading of a directory item is canceled. Calling this API makes the camera cancel file transmission. It also releases resources. This operation need not be executed when using EdsDownloadThumbnail. Parameters: In: inDirItemRef - The reference of the directory item. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsDownloadCancel( inDirItemRef : EdsDirectoryItemRef ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsDownloadThumbnail Description: Extracts and downloads thumbnail information from image files in a camera. Thumbnail information in the camera's image files is downloaded to the host computer. Downloaded thumbnails are sent directly to a file stream created in advance. Parameters: In: inDirItemRef - The reference of the directory item. inDestStream - The reference of the stream to target. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsDownloadThumbnail( inDirItemRef : EdsDirectoryItemRef; inDestStream : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsGetAttribute Description: Gets attributes of files on a camera. Parameters: In: inDirItemRef - The reference of the directory item. Out: outFileAttribute - Valueables to be stored file sttributes Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetAttribute( inDirItemRef : EdsDirectoryItemRef; var outFileAttribute : EdsFileAttributes ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function: EdsSetAttribute Description: Changes attributes of files on a camera. Parameters: In: inDirItemRef - The reference of the directory item. inFileAttribute - File attributes flag to be set Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSetAttribute( inDirItemRef : EdsDirectoryItemRef; inFileAttribute : EdsFileAttributes ) : EdsError ; stdcall ; external edsdk; { ****************************************************************************** ************************ Stream Operation Function *************************** ****************************************************************************** } { ----------------------------------------------------------------------------- Function : EdsCreateFileStream Description: Creates a new file on a host computer (or opens an existing file) and creates a file stream for access to the file. If a new file is designated before executing this API, the file is actually created following the timing of writing by means of EdsWrite or the like with respect to an open stream. Parameters: In: inFileName - Pointer to a null-terminated string that specifies the file name. inCreateDisposition - Action to take on files that exist, and which action to take when files do not exist. inDesiredAccess - Access to the stream (reading, writing, or both). Out: outStream - The reference of the stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsCreateFileStream( inFileName : PChar ; inCreateDisposition : EdsFileCreateDisposition; inDesiredAccess : EdsAccess ; var outStream : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsCreateMemoryStream Description: Creates a stream in the memory of a host computer. In the case of writing in excess of the allocated buffer size, the memory is automatically extended. Parameters: In: inBufferSize - Number of bytes of the memory to allocate. Out: outStream - The reference of the stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsCreateMemoryStream( inBufferSize : EdsUInt32 ; var outStream : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; // SDK 2.7 //function EdsCreateStream( inStream : EdsIStream ; var outStreamRef : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsCreateFileStreamEx Description: An extended version of EdsCreateFileStream. Use this function when working with Unicode file names. Parameters: In: inFileName - Pointer to wide strings inCreateDisposition - Action to take on files that exist, and which action to take when files do not exist. inDesiredAccess - Access to the stream (reading, writing, or both). Out: outStream - reference of the stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsCreateFileStreamEx( inFileName : PWideChar ; inCreateDisposition : EdsFileCreateDisposition ; inDesiredAccess : EdsAccess ; var outStream : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; { ----------------------------------------------------------------------------- Function : EdsCreateMemoryStreamFromPointer Description: Creates a stream from the memory buffer you prepare. Unlike the buffer size of streams created by means of EdsCreateMemoryStream, the buffer size you prepare for streams created this way does not expand. Parameters: In: inUserBuffer - Pointer to the buffer you have prepared inBufferSize - Number of bytes of the memory to allocate. Out: outStream - The reference of the stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsCreateMemoryStreamFromPointer( inUserBuffer : Pointer; inBufferSize : EdsUInt32; var outStream : EdsStreamRef ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsGetPointer Description: Gets the pointer to the start address of memory managed by the memory stream. As the EDSDK automatically resizes the buffer, the memory stream provides you with the same access methods as for the file stream. If access is attempted that is excessive with regard to the buffer size for the stream, data before the required buffer size is allocated is copied internally, and new writing occurs. Thus, the buffer pointer might be switched on an unknown timing. Caution in use is therefore advised. Parameters: In: inStream - object to memory stream Out: outPointer - Pointer to valueable stored the pointer Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsGetPointer( inStream : EdsStreamRef; var outPointer : Pointer ) : EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsRead Description: Reads data the size of inReadSize into the outBuffer buffer, starting at the current read or write position of the stream. The size of data actually read can be designated in outReadSize. Parameters: In: inStreamRef - The reference of the stream or image. inReadSize - Number of bytes to read. Out: outBuffer - Pointer to the user-supplied buffer that is to receive the data read from the stream. outReadSize - Actual read number of bytes. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsRead( inStreamRef : EdsStreamRef; inReadSize : EdsUInt32; var outBuffer : Pointer; var outReadSize : EdsUInt32) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsWrite Description: Writes data of a designated buffer to the current read or write position of the stream. Parameters: In: inStreamRef - The reference of the stream or image. inWriteSize - Number of bytes to write. inBuffer - Pointer to the user-supplied buffer that contains the data to be written to the stream. Out: outWrittenSize - Actual written-in number of bytes. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsWrite( inStreamRef : EdsStreamRef; inWriteSize : EdsUInt32; const inBuffer : Pointer; var outWrittenSize : EdsUInt32 ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsSeek Description: Moves the read or write position of the stream (that is, the file position indicator). Parameters: In: inStreamRef - The reference of the stream or image. inSeekOffset - Number of bytes to move the pointer. inSeekOrigin - Pointer movement mode. Must be one of the following values. kEdsSeek_Cur Move the stream pointer inSeekOffset bytes from the current position in the stream. kEdsSeek_Begin Move the stream pointer inSeekOffset bytes forward from the beginning of the stream. kEdsSeek_End Move the stream pointer inSeekOffset bytes from the end of the stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSeek( inStreamRef : EdsStreamRef; inSeekOffset : EdsUInt32; inSeekOrigin : EdsSeekOrigin ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsGetPosition Description: Gets the current read or write position of the stream (that is, the file position indicator). Parameters: In: inStreamRef - The reference of the stream or image. Out: outPosition - Current stream pointer. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsGetPosition( inStreamRef : EdsStreamRef; var outPosition : EdsUInt32 ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsGetLength Description: Get the length of the stream in bytes. Parameters: In: inStreamRef - The reference of the stream or image. Out: outLength - Length of the stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsGetLength( inStreamRef : EdsStreamRef; var outLength : EdsUInt32 ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsCopyData Description: Copies data from the copy source stream to the copy destination stream. The read or write position of the data to copy is determined from the current file read or write position of the respective stream. After this API is executed, the read or write positions of the copy source and copy destination streams are moved an amount corresponding to inWriteSize in the positive direction. Parameters: In: inSrcStreamRef - The reference of the source stream. inWriteSize - number of bytes to copy. inDestStreamRef - The reference of the destination stream. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsCopyData( inSrcStreamRef : EdsStreamRef; inWriteSize : EdsUInt32; inDestStreamRef : EdsStreamRef ) : EdsError; stdcall; external edsdk; { ****************************************************************************** ************************* Setup Operation Function *************************** ****************************************************************************** } {----------------------------------------------------------------------------- Function : EdsSetProgressCallback Description: Register a progress callback function. An event is received as notification of progress during processing that takes a relatively long time, such as downloading files from a remote camera. If you register the callback function, the EDSDK calls the callback function during execution or on completion of the following APIs This timing can be used in updating on-screen progress bars, for example. APIs : EdsCopyData, EdsDownload, EdsGetImage Parameters: In: inRef - The reference of the stream or image. inProgressCallback - Pointer to a progress callback function. inProgressOption - Option about progress is specified. this must be set one of the following values. kEdsProgressOption_Done When processing is completed,a callback function is called only at once. kEdsProgressOption_Periodically A callback function is performed periodically. inContext - Specifies an application-defined value to be sent to the callback function pointed to by CallBack parameter. Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSetProgressCallback( inRef : EdsBaseRef; inProgressCallback : EdsProgressCallback; inProgressOption : EdsProgressOption; inContext : EdsUInt32 ) : EdsError; stdcall; external edsdk; { ****************************************************************************** ************************* Image Operation Function *************************** ****************************************************************************** } {----------------------------------------------------------------------------- Function : EdsCreateImageRef Description: Creates an image object from an image file. Without modification, stream objects cannot be worked with as images. Thus, when extracting images from image files, you must use this API to create image objects. The image object created this way can be used to get image information (such as the height and width, number of color components, and resolution), thumbnail image data, and the image data itself. Parameters: In: inStreamRef - The reference of the stream. Out: outImageRef - The reference of the image. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsCreateImageRef( inStreamRef : EdsStreamRef; var outImageRef : EdsImageRef ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsGetImageInfo Description: Gets image information from a designated image object. Here, image information means the image width and height, number of color components, resolution, and effective image area. See EdsImageInfo definition of EDSDKType.pas Parameters: In: inImageRef - The reference of the image. inImageSource - Specfies kind of image - thumbnail, preview, fullview Out: outImageInfo - Infomaiton of the image. Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. ----------------------------------------------------------------------------- } function EdsGetImageInfo( inImageRef : EdsImageRef; inImageSource : EdsImageSource; var outImageInfo : EdsImageInfo ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsGetImage Description: Gets designated image data from an image file, in the form of a designated rectangle. Returns uncompressed results for JPEGs and processed results in the designated pixel order (RGB, Top-down BGR, and so on) for RAW images. Additionally, by designating the input/output rectangle, it is possible to get reduced, enlarged, or partial images. However, because images corresponding to the designated output rectangle are always returned by the SDK, the SDK does not take the aspect ratio into account. To maintain the aspect ratio, you must keep the aspect ratio in mind when designating the rectangle. Parameters: In: inImageRef : The reference of image object inImageSource : Specfies kind of image - thumbnail, preview, fullview inImageType : Specifies image type ID number inSrcRect : Rectangle of the source image inDstSize : Designate the rectangle size for output. Out: outStreamRef : The reference of memory stream Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsGetImage( inImageRef : EdsImageRef; inImageSource : EdsImageSource; inImageType : EdsTargetImageType; inSrcRect : EdsRect; inDstSize : EdsSize; inStreamRef : EdsStreamRef ) : EdsError ; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsSaveImage Description: Saves as a designated image type after RAW processing. When saving with JPEG compression, the JPEG quality setting applies with respect to EdsOptionRef. Parameters: In: inImageRef : The reference of image inImageType : Specifies image format ID number inSaveOption : Specifies save option Out: outStreamRef : The reference of file stream Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSaveImage( inImageRef : EdsImageRef; inImageType : EdsTargetImageType; inSaveSetting : EdsSaveImageSetting; var outStreamRef : EdsStreamRef ): EdsError ; stdcall ; external edsdk; {----------------------------------------------------------------------------- Function : EdsCacheImage Description: Switches a setting on and off for creation of an image cache in the SDK for a designated image object during extraction (processing) of the image data. Creating the cache increases the processing speed, starting from the second time. Parameters: In: inImageRef - The reference of the image. inUseCache - Whether cache image data , If TRUE, cache image. If FALSE, the cached image data will released. Out: none Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsCacheImage( inImageRef : EdsImageRef; inUseCache : EdsBool ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsReflectImageProperty Description: Incorporates image object property changes (effected by means of EdsSetPropertyData) in the stream. Parameters: In: inImageRef - The reference of the image. Out: none Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsReflectImageProperty( inImageRef : EdsImageRef ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function: EdsCreateEvfImageRef Description: Creates an object used to get the live view image data set. Parameters: In: inStreamRef - The stream reference which opened to get EVF JPEG image. Out: outEvfImageRef - The EVFData reference. Returns: Any of the sdk errors. -----------------------------------------------------------------------------} function EdsCreateEvfImageRef ( inStreamRef : EdsStreamRef; var outEvfImageRef : EdsEvfImageRef ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function: EdsDownloadEvfImage Description: Downloads the live view image data set for a camera currently in live view mode. Live view can be started by using the property ID:kEdsPropertyID_Evf_OutputDevice and data:EdsOutputDevice_PC to call EdsSetPropertyData. In addition to image data, information such as zoom, focus position, and histogram data is included in the image data set. Image data is saved in a stream maintained by EdsEvfImageRef. EdsGetPropertyData can be used to get information such as the zoom, focus position, etc. Although the information of the zoom and focus position can be obtained from EdsEvfImageRef, settings are applied to EdsCameraRef. Parameters: In: inCameraRef - The Camera reference. In: inEvfImageRef - The EVFData reference. Returns: Any of the sdk errors. -----------------------------------------------------------------------------} function EdsDownloadEvfImage ( inCameraRef : EdsCameraRef; inEvfImageRef : EdsEvfImageRef) : EdsError; stdcall; external edsdk; { ****************************************************************************** *********************** Event Handler Setup Function ************************* ****************************************************************************** } {----------------------------------------------------------------------------- Function : EdsSetCameraAddedHandler Description: This function registers the callback function called when a camera is connected physically. Parameters: In: inCameraAddedHandler - Pointer to a callback function called when a camera is connected physically inContext - Specifies an application-defined value to be sent to the callback function pointed to by CallBack parameter. Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSetCameraAddedHandler( inCameraAddedHandler : EdsCameraAddedHandler; inContext : EdsUInt32 ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function : EdsSetPropertyEventHandler EdsSetObjectEventHandler EdsSetCamerStateEventHandler Description: This function registers the callback function called when an event occurs to the camera. EdsSetPropertyEventHandler Registers a callback function for receiving status change notification events for property states on a camera. EdsSetObjectEventHandler Registers a callback function for receiving status change notification events for objects on a remote camera. Here, object means volumes representing memory cards, files and directories, and shot images stored in memory, in particular. EdsSetCamerStateEventHandler Registers a callback function for receiving status change notification events for camera objects. Parameters: In: inCameraRef - The reference of the camera. inEvent - Event ID number ( PropertyEvent, ObjectEvent, StateEvent ) inEventHandler - Pointer to a callback function called when an event occurs to the camera. inContext - Specifies an application-defined value to be sent to the callback function pointed to by CallBack parameter. Out: None Returns: Returns EDS_ERR_OK if successful. In other cases, see EDSDKError.pas. -----------------------------------------------------------------------------} function EdsSetPropertyEventHandler( inCameraRef : EdsCameraRef; inEvent : EdsPropertyEvent; inPropertyEventHandler : Pointer; inContext : EdsUInt32 ) : EdsError; stdcall; external edsdk; function EdsSetObjectEventHandler( inCameraRef : EdsCameraRef; inEvent : EdsObjectEvent; inObjectEventHandler : Pointer; inContext : EdsUInt32 ) : EdsError; stdcall; external edsdk; function EdsSetCameraStateEventHandler( inCameraRef : EdsCameraRef; inEvent : EdsStateEvent; inStateEventHandler : Pointer; inContext : EdsUInt32 ) : EdsError; stdcall; external edsdk; {----------------------------------------------------------------------------- Function: EdsGetEvent Description: This function acquires an event. In console application, please call this function regularly to acquire the event from a camera. Parameters: In: None Out: None Returns: Any of the sdk errors. -----------------------------------------------------------------------------} function EdsGetEvent() : EdsError; stdcall; external edsdk; //27 implementation end.
Version 1.7 ----------- - ADD: Delphi/CBuilder 10.2 Tokyo now supported. - ADD: Delphi/CBuilder 10.1 Berlin now supported. - ADD: Delphi/CBuilder 10 Seattle now supported. - ADD: Delphi/CBuilder XE8 now supported. - ADD: Delphi/CBuilder XE7 now supported. - ADD: Delphi/CBuilder XE6 now supported. - ADD: Delphi/CBuilder XE5 now supported. - ADD: Delphi/CBuilder XE4 now supported. - ADD: Delphi/CBuilder XE3 now supported. - ADD: Delphi/CBuilder XE2 now supported. - ADD: Delphi/CBuilder XE now supported. - ADD: Delphi/CBuilder 2010 now supported. - ADD: Delphi/CBuilder 2009 now supported. - ADD: New demo project FlexCADImport. - FIX: The height of the TFlexRegularPolygon object incorrectly changes with its rotation. - FIX: Added division by zero protect in method TFlexControl.MovePathSegment. - FIX: The background beyond docuemnt wasn't filled when TFlexPanel.DocClipping=True. - FIX: In "Windows ClearType" font rendering mode (OS Windows mode) the "garbage" pixels can appear from the right and from the bottom sides of the painted rectangle of the TFlexText object. - FIX: The result rectangle incorrectly calculated in the TFlexText.GetRefreshRect method. - FIX: Added FPaintCache.rcPaint cleanup in the TFlexPanel.WMPaint method. Now it is possible to define is the drawing take place via WMPaint or via the PaintTo direct call (if rcPaint contain non-empty rectangle then WMPaint in progress). - FIX: The TFlexPanel.FPaintCache field moved in the protected class section. Added rcPaint field in FPaintCache that represents drawing rectangle. - ADD: In the text prcise mode (TFlexText.Precise=True) takes into account the rotation angle (TFlexText.Angle). - FIX: Removed FG_NEWTEXTROTATE directive (the TFlexText Precise mode should be used instead). - FIX: The TFlexRegularPolygon object clones incorrectly drawed in case when TFlexRegularPolygon have alternative brush (gradient, texture). - ADD: Add TFlexPanel.InvalidateControl virtual method which calls from TFle
课程目录: 第1章:Hive基本架构及环境部署 1.MapReduce分析与SQL分析对比 2.Hive的介绍及其发展 3.Hive的安装部署及启动 4.Hive的基本架构讲解 5.安装MySQL作为元数据库存储 6.配置Hive使用MySQL作为元数据库存储 7.Hive中基本命令的使用 8.Hive中常用的属性配置 9.Hive中常用的交互式命令 10Hive中数据库的管理与使用 11.Hive中表的管理与使用 12.Hive中外部表的使用 第2章:Hive 常用DML、UDF及连接方式 13.Hive中分区表的介绍 14.Hive中分区表的创建及使用 15.Hive中数据导入的6种方式及其应用场景 16.Hive中数据导出的4种方式及表的导入导出 17.Hive中HQL的基本语法(一) 18.Hive中HQL的基本语法(二) 19.Hive中order by、sort by、distribute by与cluster by的使用 20.Hive中分析函数与窗口函数 21.Hive中UDF的介绍 22.Hive中使用自定义UDF实现日期格式转换 23. HiveServer2的介绍及三种连接方式 24.Hive元数据、fetch task和严格模式的介绍 第3章:Sqoop Sqoop及用户行为分析案例 25.CDH版本框架的介绍 26. CDH版本框架的环境部署 27.Sqoop的介绍及其实现原理 28.Sqoop的安装部署及连接测试 29.Sqoop将MySQL数据导入到HDFS(一) 30.Sqoop将MySQL数据导入到HDFS(二) 31.Sqoop中的增量导入与Sqoop job 32.Sqoop将MySQL数据导入Hive表中 33.Sqoop的导出及脚本中使用的方式 34.案例分析-动态分区的实现 35.案例分析-源表的分区加载创建 36.案例分析-指标分析使用Sqoop导出 第4章:Hive复杂用户行为案例分析及优化 37.自动批量加载数据到hive 38.Hive表批量加载数据的脚本实现(一) 39.Hive表批量加载数据的脚本实现(二) 40.HIve中的case when、cast及unix_timestamp的使用 41.复杂日志分析-需求分析 42.复杂日志分析-需求字段讲解及过滤 43.复杂日志分析-字段提取及临时表的创建 44.复杂日志分析-指标结果的分析实现 45.Hive中数据文件的存储格式介绍及对比 46.常见的压缩格式及MapReduce的压缩介绍 47.Hadoop中编译配置Snappy压缩 48.Hadoop及Hive配置支持snappy压缩 49.Hive中的常见调优 50.Hive中的数据倾斜及解决方案-三种join方式 51.Hive中的数据倾斜及解决方案-group by 52.Hive中使用正则加载数据 53. Hive中使用Python脚本进行预处理 第5章:Zeus任务资源调度工具 54.资源任务调度框架介绍 55.企业中常见的任务调度框架 56.Zeus的介绍及基本实现原理 57.Zeus安装部署-基本环境配置 58.Zeus安装部署-配置文件的修改 59.Zeus安装部署-编译打包 60.Zeus平台的调度使用 61.Zeus平台实现任务调度应用(一) 62.Zeus平台实现任务调度应用(二) 63.Zeus平台实现任务调度应用(三)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值