Problem in Awk

I have the following code in a awk script.

-------------------------------------------------
command= "sqlplus -s userid/password@database @test.sql CHICAGO"

while (command | getline)
{
var = $1
}
close(command)
---------------------------------------------------

Baically, i want to get some value from the database using a sql with an input parameter.

The query test.sql takes an input parameter and returns some value based on the input.

In more than 95% of the cases the query test.sql returns a value
and in very few cases, it returns nothing.

The problem is that when the command does not return any output(query returns 'no rows selected'), the script does not proceed past the line
while (command | getline)
and waits indefinitely for the input from the user.
When i press "Enter" , then it proceeds and prints the value of var as "Enter"

I want to make the script proceed further even if the command returns nothing.

Please suggest me as to what exactly i need to do?

Thanks in advance,
raju

if i understand this right, your problem exist when the query does not return a value.
In this case you can set a default value on 'var', like

while (command | getline)
{
var = 0 // or a other default value
var = $1
}
close(command)

Actually, when the query does not return anything , the script execution enters a pause state.

Suppose if i had just the code like
-------------------------------------
while (command | getline)
{
print "reached this point"
}

print "reached after while"
-------------------------------------

Since the command(query returned nothing), the script is expecting some input and waits indefinitely and does not even enter the loop and hence does not print "reached this point".Also, it neither prints "reached after while"

Instead, if i press "Enter" the script proceeds and prints "reached this point" .Also, it prints "reached after while"

I think getline expects something to be returned by command.And if command does not return anything, it hangs waiting until something is input by the user.

Does the control enter the loop irrespective of whether command returns anything or not?