Pas d'inquiétude, avec PBAdonf, c'est dans la poche ! ^^

Le forum (ô combien francophone) des utilisateurs de Powerbuilder.

Recherche rapide

Annonce

Certaines rubriques, dont des cours, sont uniquement visibles par les membres du forum ^^.
Dans la rubrique Liens & Références, vous avez accès à un sommaire de téléchargement, profitez-en !
Il existe maintenant un nouveau TOPIC "Votre CV en Ligne" accessible uniquement par demande.

#1 25-08-2009 09:31:01

Chrnico  
N2I Power
Award: bf
Lieu: Vanves
Date d'inscription: 05-06-2007
Messages: 1206
Pépites: 12,884,901,943
Banque: 9,223,372,036,854,776,000
Site web

PB11.5 et paramètre tinyint dans le DynamicDescriptionArea

Bonjour à tous,

Lors de l'utilisation de l'objet DynamicDescriptionArea avec une procédure Sybase ASE 15, si un paramètre output est de type Tinyint, la propriété outParmType de l'objet DynamicDescriptionArea n'est pas renseignée (même pas à TypeUnkown!) alors que cela fonctionne en PB10/ASE12.5 et PB10/ASE15 avec le client 12.5

Petit rappel sur le DynamicDescriptionArea :

Description

Use this format to execute a SQL statement that produces a result set in which the number of input parameters, or the number of result-set columns, or both, are unknown at compile time.

Syntax

DECLARE Cursor | Procedure
    DYNAMIC CURSOR | PROCEDURE
    FOR DynamicStagingArea ;

PREPARE DynamicStagingArea FROM SQLStatement
    {USING TransactionObject} ;

DESCRIBE DynamicStagingArea
    INTO DynamicDescriptionArea ;

OPEN DYNAMIC Cursor
    USING DESCRIPTOR DynamicDescriptionArea ;

EXECUTE DYNAMIC Procedure
    USING DESCRIPTOR DynamicDescriptionArea ;

FETCH Cursor | Procedure
    USING DESCRIPTOR DynamicDescriptionArea ;

CLOSE Cursor | Procedure ;

Parameter    Description
Cursor or Procedure    The name of the cursor or procedure you want to use.
DynamicStagingArea    The name of the DynamicStagingArea (usually SQLSA).If you need a DynamicStagingArea variable other than SQLSA, you must declare it and instantiate it with the CREATE statement before using it.
SQLStatement    A string containing a valid SQL SELECT statement. The string can be a string constant or a PowerBuilder variable preceded by a colon (such as :mysql). The string must be contained on one line and cannot contain expressions.Enter a question mark (?) for each parameter in the statement. Value substitution is positional; reserved word substitution is not allowed.
TransactionObject
(optional)    The name of the transaction object that identifies the database.
DynamicDescriptionArea    The name of the DynamicDescriptionArea (usually SQLDA).If you need a DynamicDescriptionArea variable other than SQLDA, you must declare it and instantiate it with the CREATE statement before using it.
Usage

The DECLARE statement is not executable and can be defined globally.
If your DBMS supports formats of FETCH other than the customary (and default) FETCH NEXT, you can specify FETCH FIRST, FETCH PRIOR, or FETCH LAST.
To declare a local cursor or procedure, open the script in the Script view and select Paste SQL from the PainterBar or the Edit>Paste Special menu. To declare a global, instance, or shared cursor or procedure, select Declare from the first drop-down list in the Script view and Global Variables, Instance Variables, or Shared Variables from the second drop-down list, then select Paste SQL.

For information about global, instance, shared, and local scope, see "Where to declare variables ".
Accessing attribute information     
When a statement is described into a DynamicDescriptionArea, this information is available to you in the attributes of that DynamicDescriptionArea variable:

Information    Attribute
Number of input parameters    NumInputs
Array of input parameter types    InParmType
Number of output parameters    NumOutputs
Array of output parameter types    OutParmType
Setting and accessing parameter values     
The array of input parameter values and the array of output parameter values are also available. You can use the SetDynamicParm function to set the values of an input parameter and the following functions to obtain the value of an output parameter:

GetDynamicDate
GetDynamicDateTime
GetDynamicDecimal
GetDynamicNumber
GetDynamicString
GetDynamicTime

For information about these functions, see GetDynamicDate, GetDynamicDateTime, GetDynamicDecimal, GetDynamicNumber, GetDynamicString, and GetDynamicTime.
Parameter values     
The following enumerated datatypes are the valid values for the input and output parameter types:

TypeBoolean!
TypeByte!
TypeDate!
TypeDateTime!
TypeDecimal!
TypeDouble!
TypeInteger!
TypeLong!
TypeLongLong!
TypeReal!
TypeString!
TypeTime!
TypeUInt!
TypeULong!
TypeUnknown!

Input parameters     
You can set the type and value of each input parameter found in the PREPARE statement. PowerBuilder populates the SQLDA attribute NumInputs when the DESCRIBE is executed. You can use this value with the SetDynamicParm function to set the type and value of a specific input parameter. The input parameters are optional; but if you use them, you should fill in all the values before executing the OPEN or EXECUTE statement.

Output parameters     
You can access the type and value of each output parameter found in the PREPARE statement. If the database supports output parameter description, PowerBuilder populates the SQLDA attribute NumOutputs when the DESCRIBE is executed. If the database does not support output parameter description, PowerBuilder populates the SQLDA attribute NumOutputs when the FETCH statement is executed.
You can use the number of output parameters in the NumOutputs attribute in functions to obtain the type of a specific parameter from the output parameter type array in the OutParmType attribute. When you have the type, you can call the appropriate function after the FETCH statement to retrieve the output value.


Tu dois donc tu peux (Kant)

Tu peux donc tu dois (N2i)
www.n2i.fr

Hors ligne

 

#2 28-08-2009 06:18:23

Chrnico  
N2I Power
Award: bf
Lieu: Vanves
Date d'inscription: 05-06-2007
Messages: 1206
Pépites: 12,884,901,943
Banque: 9,223,372,036,854,776,000
Site web

Re: PB11.5 et paramètre tinyint dans le DynamicDescriptionArea

Bon je fait mon mea culpa.

Après plusieurs tests je me suis rendu compte que j'avais oublié d'essayer le nouveau type TypeByte! apparu dernièrement et non documenté dans les nouveautés.
Bien sur cela fonctionne. Un byte (ou octet) étant de 8 bits on peut coder de 0 à 255 valeurs, c'est à dire comme le tinyint de ASE.

Donc en résumé dans SQLDA :
En PB10 les tinyint et les smallint sont retournés avec un type TypeInteger!
En PB11.5 les tinyint sont retournés avec un type TypeByte! et le type TypeInteger! existe toujours pour les smallint...


Tu dois donc tu peux (Kant)

Tu peux donc tu dois (N2i)
www.n2i.fr

Hors ligne

 

Pied de page des forums

Propulsé par FluxBB 1.2.22