Home » Developer & Programmer » Precompilers, OCI & OCCI » host variables in Create Sequence statement
icon4.gif  host variables in Create Sequence statement [message #129250] Fri, 22 July 2005 14:50
gopalad
Messages: 3
Registered: July 2005
Junior Member
Please look at the below piece of code. I am trying to get the sequence number and create a new sequence if it doesnot exists already.

For my businees logic, I need to create the sequence name dynamically and use it for select and create sequence queries.
The problem is in the create statement, I am not able to use the host variable and in the select too, it gives a compiler error.

What is the alternative way to implement?
Any ideas??


EXEC SQL INCLUDE SQLCA;
EXEC SQL BEGIN DECLARE SECTION;
double sql_nxtval;
char sql_rfid_seq[25];
EXEC SQL END DECLARE SECTION;

strncpy(rfid_seq, "RFID_",5);
strncat(rfid_seq, "ALL_",4);
strncat(rfid_seq, "ALL_",4);

DB_BNDNCPY(sql_rfid_seq, rfid_seq, 16);

EXEC SQL SELECT :sql_rfid_seq.nextval
INTO :sql_nxtval
FROM DUAL;

dm_debug();

db_status = db_status();
switch (db_status)
{
case DB_NORMAL:
*rfid_seq = sql_nxtval;
break;

/* Create a Sequence if not found */
case DB_SEQ_NOT_FOUND:
EXEC SQL CREATE SEQUENCE :sql_rfid_seq
MAXVALUE 999999999999
MINVALUE 1
NOCACHE
NOCYCLE
ORDER;
default:
break;
}
Previous Topic: PRO*C compile error
Next Topic: PRO*C BOOK
Goto Forum:
  


Current Time: Fri Oct 23 23:03:11 CDT 2020