Translating with DrWatson… this can take a few seconds the first time.
This is a genuine, complex translation. DrWatson protects commands, error codes, and log output while naturally translating the surrounding text. It’s translated once and saved.
944: Cannot use "first" in this context.
Answered: amber (solid confidence) — Error 944 (SELECT FIRST not usable in SPL) is correctly diagnosed by all three responders, who converge on two working fixes: a cursor/loop, or (more elegantly for this query) an aggregate MIN().
Henry got error 944 'Cannot use first in this context' with SELECT FIRST 1 inside a stored procedure. Carsten Haese and Rodrigo Oliveira said to use a cursor or a loop with an exit instead. Art Kagel suggested select min(sales_emp_key), min(end_customer) if the values are the same for the order. No reply from Henry.
Auto-generated by Claude from the posts below — may be imperfect; read the full thread.
Hello,
In my stored procedure, there is a sql:
select first 1 sales_emp_key, end_customer into t_sales_emp_key,t_end_customer
from delivery_fact
where order_number = t_order_number and
item_number = t_del_item_num;
which caused problem. Below is the error message that was returned:
944: Cannot use "first" in this context.
Please help me. Thanks for your help.
I was trying to get only 1 sales_emp_key and end_customer_value for
each order's item.
Please let me know if there is a better way. Thanks again.
On Tue, 2006-12-26 at 07:03 -0800, Henry wrote:
> Hello,
>
> In my stored procedure, there is a sql:
>
> select first 1 sales_emp_key, end_customer into t_sales_emp_key,> t_end_customer
> from delivery_fact
> where order_number = t_order_number and
> item_number = t_del_item_num;
>
> which caused problem. Below is the error message that was returned:
>
> 944: Cannot use "first" in this context.>
> Please help me. Thanks for your help.
> I was trying to get only 1 sales_emp_key and end_customer_value for
> each order's item.
> Please let me know if there is a better way. Thanks again.
Declare a cursor and fetch one row from the cursor. Details left as an
exercise for the reader.
-Carsten
Yopu can't to use FIRTS, LOAD, UNLOAD and other statements into the stored
procedure.
In this case, you can to create a CURSOR or a LOOP with BREAK.
Regards.
Rodrigo.
26 Dec 2006 07:03:31 -0800, Henry <ggk517@gmail.com>:
>
> Hello,
>
> In my stored procedure, there is a sql:
>
> select first 1 sales_emp_key, end_customer into t_sales_emp_key,> t_end_customer
> from delivery_fact
> where order_number = t_order_number and
> item_number = t_del_item_num;
>
> which caused problem. Below is the error message that was returned:
>
> 944: Cannot use "first" in this context.>
> Please help me. Thanks for your help.
> I was trying to get only 1 sales_emp_key and end_customer_value for
> each order's item.
> Please let me know if there is a better way. Thanks again.
>
> _______________________________________________
> Informix-list mailing list
> Informix-list@iiug.org
> http://www.iiug.org/mailman/listinfo/informix-list
>
--
Rodrigo Alexandre de Oliveira
rodrigo.alexandre2006@gmail.com
61 - 8411-2002
↪ replying to Henry
Art S. Kagel — — source: Usenet: comp.databases.informix
Henry wrote:
> Hello,
>
> In my stored procedure, there is a sql:
Assuming that all of the sales_emp_key and end_customer values are the same
for the order, how about:
select min(sales_emp_key), min(end_customer)
into t_sales_emp_key, t_end_customer
from delivery_fact
where order_number = t_order_number and
item_number = t_del_item_num
;
Art S. Kagel
> select first 1 sales_emp_key, end_customer into t_sales_emp_key,> t_end_customer
> from delivery_fact
> where order_number = t_order_number and
> item_number = t_del_item_num;
>
> which caused problem. Below is the error message that was returned:
>
> 944: Cannot use "first" in this context.>
> Please help me. Thanks for your help.
> I was trying to get only 1 sales_emp_key and end_customer_value for
> each order's item.
> Please let me know if there is a better way. Thanks again.
>
We use strictly necessary cookies to make this site work. With your
consent we’d also use optional cookies for analytics and marketing. You can accept all,
reject all, or choose. Read our Cookie Policy.