This column started out to be an obituary for "Delvecchio," a very stylish and well-acted detective series that seemed, until this week, to be faced with a premature death on CBS because of low ratings.

But of funny thing happened to me on the way to the wake. I called Bud Grant, head of programming at CBS, and asked him about the future of "Delvecchio." Said Grant, "As of now, its future never looked brighter." The reason why the series seems to have escaped an R.I.P. sign posted over a file of dead scripts is that the last two Sunday night episodes of the series got very good ratings.

The Feb. 13 episode attracted a 35 share of the audience. The one on Feb. 20 got a 31. These figures compare to an average share of 24 before Feb. 13. Shows that do not capture a 30 or more share of the audience usually meet the fate of death at an early age.

On the set of Universal Studios earlier this month, there was a funereal air about the cast and the producers of "Delvecchio." Judd Hirsch, the star, was asked if the show ever had a chance, considering that it ran from 10-11 p.m. on Sundays.

"No," said Hirsch, "it doesn't have a chance now. Nothing would. We come on at 10 o'clock, when there is a normal drop-off of audience."

William Sackheim, the executive producer, and producers Steven Bochco and Michael Rhodes, echoed Hirsch's lament - not only about the hour that "Delvecchio" was scheduled, but also that it was up against first-run movies on ABC and the "Big Event" on NBC.

Sackheim was the creator of "The Law," which starred Hirsch, won an Emmy in 1974 on NBC and disappeared after four shows. Of "Delvecchio," he said, "We were up against 'Butch Cassidy and the Sundance Kid,' "The Way We Were,' 'Gone With the Wind' and the World Series.

"I told CBS that ABC and NBC were going to beat our brains out. But we got the usual answer, which was, 'Don't worry about the Big Event, it's going to go down the toilet, and don't worry about the ABC feature films. They'll throw two or three blockbusters at you and then they'll be out of them."

The three men realized from the start that in addition to the time slot problem, "Delvecchio" was not going to be the stereotypical cop show. "I think that all year long," said Bochco, "we have made a show that says this is not a black and white world.

"The cops are not good guys running around catching bad guys. In order to get the job done, you have to be political, you have to sometimes be a liar, you have to cut corners, you have to step on toes, you have to do the things you have to do in a bureaucratic system, to cut through the B.S.

"What you have in Delvecchio is basically a schizoid personality. A cop is trained to assume guilt. A lawyer is trained to assume innocence and we have both of those things in the same guy. (Delvecchio has graduated from night law school but has failed on two occasions to pass the bar examination because he is too busy as a cop to study for it.)

"For that reason we have always built situations for Delvecchio where he is damned if he does and damned if he doesn't. Inevitably he winds up out on a limb somewhere, and in order to get back before he's sawed off, he usually has to screw over his own system. So he lies to his bosses, he occasionally bends police procedure. He gets personally involved. He's a bleeder. I'm not sure that all this doesn't make viewers uncomfortable."

When I talked to Sackheim, Bochco and Rhodes, they seemed as low as anyone I have ever seen as they watched the apparent imminent demise of a show that they had put their guts into in the belief that they were doing something unusual on television.

But the best description of what it was like working on this show came from Charles Haid, who plays Delvecchio's sidekick, Shonski. Said Haid, on what he thought was the last day of shooting, "I'm proudto have worked with the people I worked with. I was one of the associate producers of Godspell.' I was very proud of doing that. But as far as an actor - I started late and I've only been acting 2 1/2 years - I'm damn proud of this. It's great to come out of anything you do and feel as satisfied as I do about this show. Maybe I'll never do it again." And then looking at Hirsch, he said, "But I worked with him and that's enough for me."

As I said, it was a funeral that night on the Universal lot. But as of now, all signs of Delvecchio's early death have proven to be entirely premature.