| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.misc -> type Long in ORACLE and PRO*C
Hello,
I have a real problem with the use of the LONG datatype in PRO*C. I put the two main function that put and get the values from the database :
/*---------------------------------------------------------------------*//*#Unite*/
(
outp EXCEPTION *Ptr_Status,
inp char *Ptr_base,
inp int Ptr_cle,
outp char **contenu
)
typedef struct TAGtexte
{
long len;
char arr[100];
} texte_c;
EXEC SQL WHENEVER SQLERROR GOTO ERREUR_RECUP_TEXTE; EXEC SQL WHENEVER SQLWARNING GOTO ERREUR_RECUP_TEXTE; EXEC SQL WHENEVER NOT FOUND GOTO ERREUR_RECUP_TEXTE;
/* hote =host , cle = key */
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL TYPE texte_c IS LONG REFERENCE;
long texte;
int Hote_cle;
texte_c *text_c;
EXEC SQL END DECLARE SECTION;
if (Ptr_cle != INT_VALEUR_NON_FIXEE)
Hote_cle = Ptr_cle ;
else
{
EXC_NOTER(Ptr_Status,ORA_CHAMPS_NON_RENSEIGNE , "cle ");
return;
text_c = (texte_c *)malloc(sizeof(texte_c));
if (!strcmp(Ptr_base,"matiere_tt"))
{
EXEC SQL SELECT tt_commentaire INTO :text_c
FROM matiere_tt_texte
WHERE (tt_cle_texte = :Hote_cle) ;
}
{
EXEC SQL SELECT mat_commentaire INTO :text_c
FROM matiere_texte
WHERE (mat_cle = :Hote_cle) ;
}
*contenu = (char *)malloc(sizeof(char)*(((*text_c).len)+1));
if (*contenu == NULL)
{
EXC_NOTER(Ptr_Status,ORA_ALLOCATION_MEMOIRE,"Memoire pour
commentaire");
EXC_ABORT();
return;
free(text_c);
return ;
ERREUR_RECUP_TEXTE:
AFFICHE_ERREUR_ORACLE;
EXC_NOTER (Ptr_Status,ORA_CREATION_CLEE,sqlca.sqlerrm.sqlerrmc);
return;
}
/*---------------------------------------------------------------------*//*#Unite*/
(
outp EXCEPTION *Ptr_Status,
inp char *Ptr_base,
inp int Ptr_cle,
inp char *contenu
)
EXEC SQL WHENEVER SQLERROR GOTO ERREUR_STOCKE_TEXTE; EXEC SQL WHENEVER SQLWARNING GOTO ERREUR_STOCKE_TEXTE; EXEC SQL WHENEVER NOT FOUND GOTO ERREUR_STOCKE_TEXTE;
EXEC SQL BEGIN DECLARE SECTION;
EXEC SQL TYPE texte_c IS LONG REFERENCE;
int Hote_cle; int Hote_longueur; int Hote_existence;
EXC_NOTER(Ptr_Status,ORA_CHAMPS_NON_RENSEIGNE , "cle ");
return;
text_c = (texte_c *)malloc(sizeof(texte_c));
text_c->arr =(char *)strdup(contenu);
text_c->len = strlen(contenu);
Hote_longueur = text_c->len;
if (!strcmp(Ptr_base,"matiere_tt"))
{
EXEC SQL INSERT INTO matiere_tt_texte( tt_cle_texte, tt_commentaire ) values ( :Hote_cle, :text_c );
}
else
if (!strcmp(Ptr_base,"matiere"))
{
EXEC SQL SELECT COUNT(ROWID) INTO :Hote_existence FROM matiere_texte
WHERE (mat_cle = :Hote_cle);
if (Hote_existence!=0)
EXEC SQL UPDATE matiere_texte
set mat_commentaire = :text_c,
mat_longueur_comment = :Hote_longueur
WHERE (mat_cle = :Hote_cle) ;
else
EXEC SQL INSERT INTO matiere_texte( mat_cle, mat_commentaire,
mat_longueur_comment ) values ( :Hote_cle, :text_c, :Hote_longueur);
}
ERREUR_STOCKE_TEXTE:
AFFICHE_ERREUR_ORACLE;
EXC_NOTER (Ptr_Status,ORA_CREATION_CLEE,sqlca.sqlerrm.sqlerrmc);
return;
}
The table :
create table matiere_texte
(
mat_cle number(5),
mat_commentaire LONG,
mat_longueur_comment number(6),
CONSTRAINT cle_matiere_existante FOREIGN KEY (mat_cle)
REFERENCES matiere(mat_cle)
);
Thank you very much for any help.
David M.
![]() |
![]() |