Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Show all

Named SQLDA

Updated on 2024-05-07 GMT+08:00

A named SQLDA consists of a header and one or more item descriptor areas. The header contains information concerning the entire descriptor area, and each item descriptor area describes a column in the result row.

  • Before using an SQLDA, you need to allocate it.
    EXEC SQL ALLOCATE DESCRIPTOR identifier;
  • When you no longer need the SQLDA, deallocate it in time.
    EXEC SQL DEALLOCATE DESCRIPTOR identifier;
  • To use a descriptor area, declare it using the INTO clause.
    EXEC SQL FETCH NEXT FROM mycursor INTO SQL DESCRIPTOR mydesc;

    If the result set is empty, the descriptor area still contains the metadata from the query.

  • For a prepared query that has not been executed, you can use DESCRIBE to obtain the metadata of its result set.
    EXEC SQL BEGIN DECLARE SECTION; 
        char *sql_stmt = "SELECT * FROM table1"; 
    EXEC SQL END DECLARE SECTION;  
    
        EXEC SQL PREPARE stmt1 FROM :sql_stmt; 
        EXEC SQL DESCRIBE stmt1 INTO SQL DESCRIPTOR mydesc;

    In DESCRIBE and FETCH statements, the INTO and USING keywords are used similarly: they produce a result set and metadata in a descriptor area.

  • Retrieve the value in a descriptor area from the header and store it into a host variable.
    EXEC SQL GET DESCRIPTOR name :hostvar = field;
  • Currently, only one header descriptor area COUNT is defined, which tells how many item descriptor areas exist (that is, how many columns are contained in the result). The host variable must be of the integer type. Retrieve a specific value from the item descriptor area.
    EXEC SQL GET DESCRIPTOR name VALUE num :hostvar = field;
    num can be a character integer or a host variable that contains an integer. Possible data types are as follows:
    • CARDINALITY (integer): number of rows in the result set
    • DATA: actual data item (therefore, the data type of this field depends on the query)
    • DATETIME_INTERVAL_CODE (integer): When TYPE is 9, DATETIME_INTERVAL_CODE will have a value of 1 for DATE, 2 for TIME, 3 for TIMESTAMP, 4 for TIME WITH TIME ZONE, or 5 for TIMESTAMP WITH TIME ZONE.
    • INDICATOR (integer): indicator (indicating a null value or a value truncation)
    • LENGTH (integer): data length in characters
    • NAME(string): column name
    • OCTET_LENGTH (integer): length of the character representation of the data in bytes
    • PRECISION (integer): precision (for the numeric type)
    • RETURNED_LENGTH (integer): data length in characters
    • RETURNED_OCTET_LENGTH (integer): length of the character representation of the data in bytes
    • SCALE (integer): ratio (for the numeric type)
    • TYPE (integer): numeric code of the data type of the column
  • Retrieve the column value and store it in a host variable.
    EXEC SQL GET DESCRIPTOR mydesc  VALUE num :hostvar = field
    num can be a character integer or a host variable that contains an integer. Possible columns are as follows:
    • DATA
    • Actual data item (the data type of this column depends on the query)
    • NAME(string)
    • Field name
  • Manually create a descriptor area to provide input parameters for a query or cursor.
    EXEC SQL SET DESCRIPTOR name VALUE numfield = :hostvar;
  • Retrieve multiple rows of records in a FETCH statement and use a host variable of the array type to store data.
    EXEC SQL BEGIN DECLARE SECTION; 
        int id[5]; 
    EXEC SQL END DECLARE SECTION;  
        EXEC SQL FETCH 5 FROM mycursor INTO SQL DESCRIPTOR mydesc;  
        EXEC SQL GET DESCRIPTOR mydesc VALUE 1 :id = DATA;

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback