4GL Query problem !
Posted in 1999
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL, Server Administration
Hi all,
I have a silly question, but wasnt able to figure out what is happening
and how is it happening.
Here is a query statement that is written in a 4gl program.
SELECT insp_periodicity
INTO g_insp_periodicity
FROM smm_insp_period
WHERE @insp_autho = gr_smrpm01.sti_iii_cd
Please notice there is a "@" sign before field "insp_autho"
now if this "@" sign is there then this query gives status = 0
and if i remove this then it gives status = 100.
What does this "@" sign means and how does this affect the query.
BTW, I wrote a dummy program with the same query. There it works in both
the cases...means...with or without "@" sign, i get status = 0.
But when i run the same query in dbaccess, i get a syntax error at "@"
sign.
Cant figure out.
TIA,
With Regards
Nayan Jain !
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ye Lamhe, Ye pal ham baraso yaad karenge ...
Hi Nayan,
Just check to see whether you have a variable defined with the same name. It
is always better to prefix a column name with the table name or the @.
Gopi
NayAn JaiN <nayan.jain@tatainfotech.com> wrote in message
news:7n3l0u$7e7$1@news.xmission.com...
>
> Hi all,
>
> I have a silly question, but wasnt able to figure out what is happening
> and how is it happening.
>
> Here is a query statement that is written in a 4gl program.
>
> SELECT insp_periodicity
> INTO g_insp_periodicity
> FROM smm_insp_period
> WHERE @insp_autho = gr_smrpm01.sti_iii_cd>
> Please notice there is a "@" sign before field "insp_autho"
>
> now if this "@" sign is there then this query gives status = 0
> and if i remove this then it gives status = 100.
>
> What does this "@" sign means and how does this affect the query.
>
> BTW, I wrote a dummy program with the same query. There it works in both
> the cases...means...with or without "@" sign, i get status = 0.
>
> But when i run the same query in dbaccess, i get a syntax error at "@"
> sign.
>
> Cant figure out.
>
> TIA,
>
> With Regards
> Nayan Jain !
>
>
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> Ye Lamhe, Ye pal ham baraso yaad karenge ...
>
Ramdas Gopinath wrote:
>
> Hi Nayan,
> Just check to see whether you have a variable defined with the same name. It
> is always better to prefix a column name with the table name or the @.
Correct. Just a note, using the tablename will not save you from the
confusion that the @ is there to resolve if, as is common practice,
you have structures with the same names as the table declared 'LIKE
<tablename>' so it is alwasy good practive in 4GL to prefix column
names in where clauses with the at sign (@) or to religiously avoid
naming program objects after the database objects they map.
Art S. Kagel
> Gopi
>
> NayAn JaiN <nayan.jain@tatainfotech.com> wrote in message
> news:7n3l0u$7e7$1@news.xmission.com...
> >
> > Hi all,
> >
> > I have a silly question, but wasnt able to figure out what is happening
> > and how is it happening.
> >
> > Here is a query statement that is written in a 4gl program.
> >
> > SELECT insp_periodicity
> > INTO g_insp_periodicity
> > FROM smm_insp_period
> > WHERE @insp_autho = gr_smrpm01.sti_iii_cd> >
> > Please notice there is a "@" sign before field "insp_autho"
> >
> > now if this "@" sign is there then this query gives status = 0
> > and if i remove this then it gives status = 100.
> >
> > What does this "@" sign means and how does this affect the query.
> >
> > BTW, I wrote a dummy program with the same query. There it works in both
> > the cases...means...with or without "@" sign, i get status = 0.
> >
> > But when i run the same query in dbaccess, i get a syntax error at "@"
> > sign.
> >
> > Cant figure out.
> >
> > TIA,
> >
> > With Regards
> > Nayan Jain !
> >
> >
> >
> > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> > Ye Lamhe, Ye pal ham baraso yaad karenge ...
> >
A good naming convention within 4GL is to prefix everything with a letter
indicating the scope of the variable, e.g. l_myvar for local, m_myvar for
modular etc. It makes the code easier to read and as an after effect
prevents you ever having to consider this type of ambiguity in SQL
statements, well at least so long as you don't name your columns l_colname
;o).
--
---------------------------------------
Tony Flaherty aef@mfs.misys.co.uk
Analyst Programmer
Misys Financial Systems
All statements and opinions are my own,
Misys don't pay me enough to have opinions
on their behalf
.
Art S. Kagel wrote in message <3795FCA9.E7D2CE90@bloomberg.net>...
>Ramdas Gopinath wrote:
>>
>> Hi Nayan,
>> Just check to see whether you have a variable defined with the same name.
It
>> is always better to prefix a column name with the table name or the @.
>
>Correct. Just a note, using the tablename will not save you from the
>confusion that the @ is there to resolve if, as is common practice,
>you have structures with the same names as the table declared 'LIKE
><tablename>' so it is alwasy good practive in 4GL to prefix column
>names in where clauses with the at sign (@) or to religiously avoid
>naming program objects after the database objects they map.
>
>Art S. Kagel
>
>> Gopi
>>
>> NayAn JaiN <nayan.jain@tatainfotech.com> wrote in message
>> news:7n3l0u$7e7$1@news.xmission.com...
>> >
>> > Hi all,
>> >
>> > I have a silly question, but wasnt able to figure out what is happening
>> > and how is it happening.
>> >
>> > Here is a query statement that is written in a 4gl program.
>> >
>> > SELECT insp_periodicity
>> > INTO g_insp_periodicity
>> > FROM smm_insp_period
>> > WHERE @insp_autho = gr_smrpm01.sti_iii_cd>> >
>> > Please notice there is a "@" sign before field "insp_autho"
>> >
>> > now if this "@" sign is there then this query gives status = 0
>> > and if i remove this then it gives status = 100.
>> >
>> > What does this "@" sign means and how does this affect the query.
>> >
>> > BTW, I wrote a dummy program with the same query. There it works in
both
>> > the cases...means...with or without "@" sign, i get status = 0.
>> >
>> > But when i run the same query in dbaccess, i get a syntax error at "@"
>> > sign.
>> >
>> > Cant figure out.
>> >
>> > TIA,
>> >
>> > With Regards
>> > Nayan Jain !
>> >
>> >
>> >
>> > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>> > Ye Lamhe, Ye pal ham baraso yaad karenge ...
>> >
You might think its good but personally I find it just a bit dumb. If you
can't read it then its probably over complicated. Also , I think global /
modular variables are a no no unless there is no other way , everything
should be parameters. Arrays are the obvious exception.
Tony Flaherty <aef@mfs.misys.co.uk> wrote in message
news:932635496.21678.0.nnrp-01.c1ed1f69@news.demon.co.uk...
> A good naming convention within 4GL is to prefix everything with a letter
> indicating the scope of the variable, e.g. l_myvar for local, m_myvar for
> modular etc. It makes the code easier to read and as an after effect
> prevents you ever having to consider this type of ambiguity in SQL
> statements, well at least so long as you don't name your columns l_colname
> ;o).
>
>
> --
> ---------------------------------------
> Tony Flaherty aef@mfs.misys.co.uk
> Analyst Programmer
> Misys Financial Systems
> All statements and opinions are my own,
> Misys don't pay me enough to have opinions
> on their behalf
>
> .
> Art S. Kagel wrote in message <3795FCA9.E7D2CE90@bloomberg.net>...
> >Ramdas Gopinath wrote:
> >>
> >> Hi Nayan,
> >> Just check to see whether you have a variable defined with the same
name.
> It
> >> is always better to prefix a column name with the table name or the @.
> >
> >Correct. Just a note, using the tablename will not save you from the
> >confusion that the @ is there to resolve if, as is common practice,
> >you have structures with the same names as the table declared 'LIKE
> ><tablename>' so it is alwasy good practive in 4GL to prefix column
> >names in where clauses with the at sign (@) or to religiously avoid
> >naming program objects after the database objects they map.
> >
> >Art S. Kagel
> >
> >> Gopi
> >>
> >> NayAn JaiN <nayan.jain@tatainfotech.com> wrote in message
> >> news:7n3l0u$7e7$1@news.xmission.com...
> >> >
> >> > Hi all,
> >> >
> >> > I have a silly question, but wasnt able to figure out what is
happening
> >> > and how is it happening.
> >> >
> >> > Here is a query statement that is written in a 4gl program.
> >> >
> >> > SELECT insp_periodicity
> >> > INTO g_insp_periodicity
> >> > FROM smm_insp_period
> >> > WHERE @insp_autho = gr_smrpm01.sti_iii_cd> >> >
> >> > Please notice there is a "@" sign before field "insp_autho"
> >> >
> >> > now if this "@" sign is there then this query gives status = 0
> >> > and if i remove this then it gives status = 100.
> >> >
> >> > What does this "@" sign means and how does this affect the query.
> >> >
> >> > BTW, I wrote a dummy program with the same query. There it works in
> both
> >> > the cases...means...with or without "@" sign, i get status = 0.
> >> >
> >> > But when i run the same query in dbaccess, i get a syntax error at
"@"
> >> > sign.
> >> >
> >> > Cant figure out.
> >> >
> >> > TIA,
> >> >
> >> > With Regards
> >> > Nayan Jain !
> >> >
> >> >
> >> >
> >> > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
> >> > Ye Lamhe, Ye pal ham baraso yaad karenge ...
> >> >
>
Well! Worms and Cans come to mind! I certainly was not espousing the use of
Globals or excessive use of modular variables. As people have said people
have different styles, this does not mean that any one is the only one. As
programmers we all want to produce easily maintainable efficient code. As
long as you can achieve this and follow "house" standards/guidelines then I
guess you're on your way to doing a good job.
--
---------------------------------------
Tony Flaherty aef@mfs.misys.co.uk
Analyst Programmer
Misys Financial Systems
All statements and opinions are my own,
Misys don't pay me enough to have opinions
on their behalf
.
Tony Flaherty wrote in message
<932635496.21678.0.nnrp-01.c1ed1f69@news.demon.co.uk>...
>A good naming convention within 4GL is to prefix everything with a letter
>indicating the scope of the variable, e.g. l_myvar for local, m_myvar for
>modular etc. It makes the code easier to read and as an after effect
>prevents you ever having to consider this type of ambiguity in SQL
>statements, well at least so long as you don't name your columns l_colname
>;o).
>
>
>--
>---------------------------------------
>Tony Flaherty aef@mfs.misys.co.uk
>Analyst Programmer
>Misys Financial Systems
>All statements and opinions are my own,
>Misys don't pay me enough to have opinions
>on their behalf
>
>.
>Art S. Kagel wrote in message <3795FCA9.E7D2CE90@bloomberg.net>...
>>Ramdas Gopinath wrote:
>>>
>>> Hi Nayan,
>>> Just check to see whether you have a variable defined with the same
name.
>It
>>> is always better to prefix a column name with the table name or the @.
>>
>>Correct. Just a note, using the tablename will not save you from the
>>confusion that the @ is there to resolve if, as is common practice,
>>you have structures with the same names as the table declared 'LIKE
>><tablename>' so it is alwasy good practive in 4GL to prefix column
>>names in where clauses with the at sign (@) or to religiously avoid
>>naming program objects after the database objects they map.
>>
>>Art S. Kagel
>>
>>> Gopi
>>>
>>> NayAn JaiN <nayan.jain@tatainfotech.com> wrote in message
>>> news:7n3l0u$7e7$1@news.xmission.com...
>>> >
>>> > Hi all,
>>> >
>>> > I have a silly question, but wasnt able to figure out what is
happening
>>> > and how is it happening.
>>> >
>>> > Here is a query statement that is written in a 4gl program.
>>> >
>>> > SELECT insp_periodicity
>>> > INTO g_insp_periodicity
>>> > FROM smm_insp_period
>>> > WHERE @insp_autho = gr_smrpm01.sti_iii_cd>>> >
>>> > Please notice there is a "@" sign before field "insp_autho"
>>> >
>>> > now if this "@" sign is there then this query gives status = 0
>>> > and if i remove this then it gives status = 100.
>>> >
>>> > What does this "@" sign means and how does this affect the query.
>>> >
>>> > BTW, I wrote a dummy program with the same query. There it works in
>both
>>> > the cases...means...with or without "@" sign, i get status = 0.
>>> >
>>> > But when i run the same query in dbaccess, i get a syntax error at "@"
>>> > sign.
>>> >
>>> > Cant figure out.
>>> >
>>> > TIA,
>>> >
>>> > With Regards
>>> > Nayan Jain !
>>> >
>>> >
>>> >
>>> > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>>> > Ye Lamhe, Ye pal ham baraso yaad karenge ...
>>> >
>