[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 480
  • Last Modified:

odefin-someone knows?

I need to know what function does what
odefin does, but instead of accepting
char* as third parameter,she accept integers(from type long, in c);
0
Edy1988
Asked:
Edy1988
  • 6
  • 5
1 Solution
 
HaukeCommented:
May be this helps you.

#define  RAW_DATE_SIZE      7


int Oci_stmt_defin_c( Cda_Def *pcda, long col_num, char *c, int len, short *indp)
{
    return !odefin( pcda, col_num, c, len, SQLT_STR, -1, (sb2 *)indp, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);
}


int Oci_stmt_defin_f( Cda_Def *pcda, long col_num, float *f, short *indp)
{
    return !odefin( pcda, col_num, f, sizeof( f), SQLT_FLT, -1, (sb2 *)indp, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);
}


int Oci_stmt_defin_l( Cda_Def *pcda, long col_num, long *l, short *indp)
{
    return !odefin( pcda, col_num, l, sizeof( l), SQLT_INT, -1, (sb2 *)indp, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);
}


int Oci_stmt_defin_dt( Cda_Def *pcda, long col_num, long *dt, short *indp)
{
    return !odefin( pcda, col_num, dt, RAW_DATE_SIZE, SQLT_DAT, -1, (sb2 *)indp, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);
}
0
 
Edy1988Author Commented:
BUT HOW DO YOU USE IN THIS FUNCTIONS
AN INTEGER?LONG VARIABLE INSTEAD OF CHAR*
AS THIRD PARAM OF ODEFIN?
WHEN I TRY TO, I HAVE 2 WARNINGS.
0
 
HaukeCommented:
/*
 * OBSOLETE DEFINE CALLS-- use odefinps()
 */
sword  odefin( /*_ struct cda_def *cursor, sword pos, ub1 *buf,
                 sword bufl, sword ftype, sword scale, sb2 *indp,
                 text *fmt, sword fmtl, sword fmtt, ub2 *rlen, ub2 *rcode _*/ );


The third parameter has the type 'pointer to unsigned byte'. If you pass a long values to the function, then you receive a warning from the compiler (and an error at runtime).
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
Edy1988Author Commented:
I know that, that is why i asked for a function that is equivalent to odefin, but accept long value instead ub1.
0
 
HaukeCommented:
long value;

int ind

oparse( pcda, (text *)"select 1 from dual", (sb4)-1, DEFER_PARSE, (ub4)VERSION_7);

odefin( pcda, col_num, &value, sizeof( value), SQLT_INT, -1, (sb2 *)&ind, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);

oexec( pcda);

ofetch( pcda);

printf( "%ld\n", value);
0
 
Edy1988Author Commented:
now i have warnings about the incompatibility
of long* and "unsined char *"
0
 
HaukeCommented:
Sorry, there must be a cast.

odefin( pcda, 1, (ub1 *)&value, sizeof( value), SQLT_INT, -1, (sb2 *)&ind, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);
0
 
HaukeCommented:
Sorry, there must be a cast.

odefin( pcda, 1, (ub1 *)&value, sizeof( value), SQLT_INT, -1, (sb2 *)&ind, (text *)0, -1, -1, (ub2 *) 0, (ub2 *) 0);
0
 
Edy1988Author Commented:
Thank you very much, tell me just one last thing
doesn't it suppose to create trouble if the field in the table is of type NUMBER, and i try to bind him to a c long variable after casting his adress to an unsigned char adress?
0
 
HaukeCommented:
The parameter value SQLT_INT tells Oracle that your variable stores integer values (char, short, int ,long). The parameter value sizeof( value) (= sizeof( long) in this case) tells Oracle the precision you want to use.
If you want to retrieve a value greater than +-2^31 for c type long, then you will receive an (ORA-) error when fetching this row.
0
 
Edy1988Author Commented:
EXCELENT JOB
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now