Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #144799
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Pro*c compile and nested structure |
| Date | 2019-06-13 11:16 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <87muilkcxv.fsf@bsb.me.uk> (permalink) |
| References | <ae271cd6-e174-4882-ab14-e59dfab203e2@googlegroups.com> |
WalkeR Park <walker.ykpark@gmail.com> writes:
> Hello, I just make a code based on Pro*c of Oracle....
> but It did return strange Error.
This is probably not the best place for this sort of question (is there
are group for Oracle Pro*C?) but it happens you have a C error that can
be picked out from the Oracle stuff.
> It did not recognize topTag structure(rec),
> and In topTag structure, timestamp structure is included but
> did not recognize....
<cut>
> #### *.pc file
> ===============================================================
> EXEC SQL INCLUDE sqlca;
>
> EXEC SQL BEGIN DECLARE SECTION;
>
> typedef struct _timestamp
> {
> signed short year;
> unsigned short month;
> unsigned short day;
> unsigned short hour;
> unsigned short minute;
> unsigned short second;
> unsigned int fraction;
> } timestamp;
>
> typedef struct _top_tag
> {
> unsigned short shop_cd;
> unsigned short tag_id;
> unsigned short tag_typ_cd;
> char tag_ip_addr[40+1];
> char tag_mac_addr[20+1];
> unsigned int tag_port_num;
> char tag_bcd_val[20+1];
> char rgstr_id[30+1];
>
> struct timestamp rgst_dtm;
>
> unsigned short curr_dnload_upgr_file_ver_num;
> unsigned short curr_upgr_file_ver_num;
> char last_chgr_id[30+1];
>
> struct timestamp last_chg_dtm;
> unsigned short tag_chg_cl_cd;
> } topTag;
After the typedef you can declare an object of this type in two ways:
struct _top_tag tt1;
topTag tt2;
> EXEC SQL END DECLARE SECTION;
>
> int selectTopTag(unsigned short shop_code, unsigned short tag_id, topTag *top_tag, char *conn_name)
> {
> EXEC SQL BEGIN DECLARE SECTION;
>
> struct topTag rec;
But you can't do this. rec will be taken to have a new structure type
with an as yet unknown struct tag "topTag".
> char *H_conn_name;
>
> EXEC SQL END DECLARE SECTION;
>
> H_conn_name = conn_name;
>
> memset(&rec, 0x00, sizeof(topTag));
You can, most likely, write
topTag rec = {0};
above to declare and initialise rec to all zeros (unless Pro*c does not
support this style).
> /* SELECT */
> EXEC SQL AT :H_conn_name
> SELECT
> SHOP_CD,
> TO_NUMBER(TAG_ID),
> TO_NUMBER(TAG_TYP_CD),
> TAG_IP_ADDR,
> UPPER(TAG_MAC_ADDR),
> TAG_PORT_NUM,
> TAG_BCD_VAL,
> RGSTR_ID,
> RGST_DTM,
> CURR_DNLOAD_UPGR_FILE_VER_NUM,
> CURR_UPGR_FILE_VER_NUM,
> LAST_CHGR_ID,
> LAST_CHG_DTM,
> TO_NUMBER(TAG_CHG_CL_CD)
> INTO :rec
> FROM TOP_TAG
> WHERE SHOP_CD = :shop_code AND
> TO_NUMBER(TAG_ID) = :tag_id;
>
> if (sqlca.sqlcode == SQL_SUCCESS)
> {
> memcpy(top_tag, &rec, sizeof(topTag));
> return 1;
> }
> else if (sqlca.sqlcode == SQL_NO_DATA)
> return 0;
> else /* SQL_ERROR 또는 SQL_SUCCESS_WITH_INFO */
> return -1;
> }
> ===============================================================
>
>
> #### Result :
> ===============================================================
> Pro*C/C++: Release 12.2.0.1.0 - Production on Thu Jun 13 18:12:03 2019
>
> Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
>
> System default option values taken from: /usr/lib/oracle/12.2/client64/precomp/admin/pcscfg.cfg
>
> Semantic error at line 116, column 8, file toptag.pc:
> INTO :rec
> .......1
> PCC-S-02420, Incomplete (or missing) type specification
> Semantic error at line 118, column 19, file toptag.pc:
> WHERE SHOP_CD = :shop_code AND
> ..................1
> PCC-S-02322, found undefined identifier
> Semantic error at line 119, column 26, file toptag.pc:
> TO_NUMBER(TAG_ID) = :tag_id;
> .........................1
> PCC-S-02322, found undefined identifier
> make: *** [toptag.o] Error 1
> ===============================================================
--
Ben.
Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread
Pro*c compile and nested structure WalkeR Park <walker.ykpark@gmail.com> - 2019-06-13 02:23 -0700 Re: Pro*c compile and nested structure Ben Bacarisse <ben.usenet@bsb.me.uk> - 2019-06-13 11:16 +0100
csiph-web