Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Enqueue from C++ Application

355939Oct 16 2002
I am trying to write a C++ application that will perform an enqueue operation. I am very new to AQ so as a first step I am trying to get one of the examples to work. I have included the code and error message below. Can anyone help get me started...

#ifndef DEMO_ORACLE
#define DEMO_ORACLE

#ifndef OCI_ORACLE
#include <oci.h>
#endif

typedef OCIRef message_typ_ref;

struct message_typ
{
OCIString * subject;
OCIString * text;
};

typedef struct message_typ messageType;

struct message_typ_ind
{
OCIInd _atomic;
OCIInd subject;
OCIInd text;
};

typedef struct message_typ_ind message_typ_ind;

#endif



#include <stdio.h>
#include <string.h>
#include <sqlca.h>
#include <sql2oci.h>

EXEC SQL INCLUDE demo.h;

void sql_error(char * msg)
{
EXEC SQL WHENEVER SQLERROR CONTINUE;
printf("%s\n", msg);
printf("\n% .800s \n", sqlca.sqlerrm.sqlerrmc);
EXEC SQL ROLLBACK WORK RELEASE;
exit(1);
}

int main()
{
EXEC SQL BEGIN DECLARE SECTION;

message_typ * message; // payload
char user[60] = "twaqmgr/twaqmgr@rt1"; // user logon password
char subject[30]; // components of the
char txt[80]; // payload type

EXEC SQL END DECLARE SECTION;

// ENQUEUE and DEQUEUE to an OBJECT QUEUE

// Connect to database
EXEC SQL CONNECT :user;

// On an oracle error print the error number
EXEC SQL WHENEVER SQLERROR DO sql_error("Oracle Error :");

// Allocate memory for the host variable from the object cache
EXEC SQL ALLOCATE :message;

// ENQUEUE

strcpy(subject, "NORMAL ENQUEUE");
strcpy(txt, "The Enqueue was done through PLSQL embedded in PROC");

// Initialize the components of message
EXEC SQL OBJECT SET subject, text OF :message TO :subject, :txt;

// Embedded PLSQL call to the AQ enqueue procedure
EXEC SQL EXECUTE

DECLARE
message_properties dbms_aq.message_properties_t;
enqueue_options dbms_aq.enqueue_options_t;
msgid RAW(16);

BEGIN

// Bind the host variable 'message' to the payload
dbms_aq.enqueue(queue_name => 'queue1',
message_properties => message_properties,
enqueue_options => enqueue_options,
payload => :message,
msgid => msgid);
END;
END-EXEC;

// Commit work

EXEC SQL COMMIT;

printf("Enqueued Message \n");
printf("Subject :%s\n",subject);
printf("Text :%s\n",txt);
}


Syntax error at line 21, column 2, file test1.pc:
Error at line 21, column 2 in file test1.pc
message_typ * message; // payload
.1
PCC-S-02201, Encountered the symbol "message_typ" when expecting one of the foll
owing:

auto, char, const, double, enum, extern, float, int, long,
ulong_varchar, OCIBFileLocator OCIBlobLocator,
OCIClobLocator, OCIDateTime, OCIExtProcContext, OCIInterval,
OCIRowid, OCIDate, OCINumber, OCIRaw, OCIString, register,
short, signed, sql_context, sql_cursor, static, struct,
typedef, union, unsigned, utext, uvarchar, varchar, void,
volatile, a typedef name, a precompiled header, exec oracle,
exec oracle begin, exec, exec sql, exec sql begin,
exec sql end, exec sql type, exec sql var, exec sql include,
The symbol "enum," was substituted for "message_typ" to continue.

Error at line 0, column 0 in file test1.pc
PCC-F-02102, Fatal error while doing C preprocessing
*** Error exit code 1
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 25 2002
Added on Oct 16 2002
1 comment
618 views