×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

In the following lines of codes, I

In the following lines of codes, I

In the following lines of codes, I

(OP)
In the following lines of codes, I tried to insert some records of a table into another. There is a cursor witch has an ORDER BY clause on the field N_RIB. The insert comes after some work.
Just a example of what's going wrong :

Source Table N_RIB : 2, 3, 1
Program Insert Work : 1, 2, 3
Result Table N_RIB : 2, 3, 1

So the order by clause doesn't affect how records are ordered.

Here is some of my code :


void InsertionRibs( char N_PMP[11], char N_EXT_PMP[11] )
{
int n_rib;
char c_cle_rib[5];
int n_cle_rib;
char c_bq[6], c_gu[6], c_cpt[12];
char ribOK[3];
char domiciliation[61];

EXEC SQL WHENEVER SQLERROR DO sql_error( "Erreur ORACLE" );

EXEC SQL DECLARE sel_ribs CURSOR FOR
SELECT n_rib,
l_banq_cpt_princ,
l_guich_cpt_princ,
l_cpt_princ
FROM bol_ribs
WHERE PMP_N_PMP = :N_PMP
ORDER BY N_RIB;
EXEC SQL OPEN sel_ribs;

for( ; ; )
{
EXEC SQL FETCH sel_ribs INTO :n_rib, :c_bq, :c_gu, :c_cpt;

if( sqlca.sqlcode == ORA_NOTFOUND ) break;
if( sqlca.sqlcode > 0 )
{
printf( "Erreur Fatale: %s", sqlca.sqlerrm.sqlerrmc );
break;
}
if( sqlca.sqlcode < 0 )
printf( "Erreur : %s", sqlca.sqlerrm.sqlerrmc );

n_cle_rib = CalculCleRib(c_bq, c_gu, c_cpt);
sprintf( c_cle_rib, "%02d", n_cle_rib );


strcpy( domiciliation, "" );

EXEC SQL INSERT INTO TAB_RIBS ( SELECT
:n_rib,
PMP_N_PMP,
PMP_N_EXT_PMP,
L_PREPO_VIL_BQ,
L_RIB_LIBELLE,
C_PAYS_CPT_PRINC,
L_BANQ_CPT_PRINC,
L_GUICH_CPT_PRINC,
L_CPT_PRINC,
:c_cle_rib,
to_date(D_DEB_UTIL,'YYYYMMDD'),
to_date(D_FIN_UTIL,'YYYYMMDD'),
L_PHONE_RESP_CPT,
L_VILLE,
:domiciliation,
C_REF_ANT,
L_NOM_RESP_CPTE,
C_TYPE_RIB
FROM BOL_RIBS
WHERE PMP_N_PMP = :N_PMP
AND N_RIB = :n_rib );
EXEC SQL COMMIT;
}
EXEC SQL CLOSE sel_ribs;
}


Thanks in advance.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close