Subject | Re: [ib-support] Again SP Questions from a NewBie |
---|---|
Author | Helen Borrie |
Post date | 2001-11-19T13:16:52Z |
At 02:03 PM 19-11-01 +0200, you wrote:
However...the rule that works for me goes something like this:
Omit the colon if
- the variable is on the left-hand side of an assignment statement, e.g. MYVAR = 99;
- you are using the variable as an operand in a calculation AND it is not a self-reassignment, e.g. SOMEVAR = MYVAR / YOURVAR
The colon must be there if
- a value is being assigned from it, e.g. update mytable set afield = :MYVAR;
- the variable is getting a new value calculated from its old value, e.g.
MYVAR = :MYVAR + 1
- it is an operand in a DML expression involving a column of the same name,
e.g. update mytable set MYCOL = :MYCOL; (same rule as for parameters)
Also, this should work too:
SOMEVAR = :MYVAR / :YOURVAR
but, again, it will cause problems if you have a parameter and/or a column with the same name, so I don't do it any more.
But it's a perfectly valid way of bringing a singleton row of one or more columns back into a procedure, provided you always test to make sure that you got something back.
cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________
>Thanks HelenNot sure what this means...but nobody seems to have come up with a rule that everyone agrees to about this variable prefix.
>
> Can we say that we use colons before our variables only parametrical
>cases ??
However...the rule that works for me goes something like this:
Omit the colon if
- the variable is on the left-hand side of an assignment statement, e.g. MYVAR = 99;
- you are using the variable as an operand in a calculation AND it is not a self-reassignment, e.g. SOMEVAR = MYVAR / YOURVAR
The colon must be there if
- a value is being assigned from it, e.g. update mytable set afield = :MYVAR;
- the variable is getting a new value calculated from its old value, e.g.
MYVAR = :MYVAR + 1
- it is an operand in a DML expression involving a column of the same name,
e.g. update mytable set MYCOL = :MYCOL; (same rule as for parameters)
Also, this should work too:
SOMEVAR = :MYVAR / :YOURVAR
but, again, it will cause problems if you have a parameter and/or a column with the same name, so I don't do it any more.
> If statement's last "end" can end with a semicolon??No, in this language, only statements end with a semicolon. BEGIN and END are block markers.
> If our statement will return some value, than we have to use suspend inSuspend should be used only when you are going to call the procedure with SELECT. It is normally used at the end of an iteration of a FOR...SELECT...INTO...DO loop and its purpose is to output the row generated by the current iteration of the loop. It is this particular construct in Firebird procedure language that allow us to design procedures that output multiple rows. In other p/ls you have to do icky things like processing a cursor and sending its output to a temporary file. Know it and love it like I do. <g>
>SP's??
But it's a perfectly valid way of bringing a singleton row of one or more columns back into a procedure, provided you always test to make sure that you got something back.
> Using Select into for procedures : I have never seen a doc about this.InterBase Language Reference manual?
cheers,
Helen
All for Open and Open for All
InterBase Developer Initiative ยท http://www.interbase2000.org
_______________________________________________________