in reply to Re: DBD::Sybase + MS SQL server problem
in thread DBD::Sybase + MS SQL server problem

Thanks for your response.
In the original code, assigning
$sql
was done by a subroutine:
sub build_sql { #process args; return $sql_block; } $sql = build_sql ( \@layout, \%myfilter );
However, in the interests of testing, I simpy did it like this:
$sql = qq { set quoted_identifier on use "smdb"; set TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT "_SMDBA_"."_TELMASTE_".SEQUENCE AS "Problem #", "_SMDBA_"."_CUSTOMER_".FNAME + ' ' + "_SMDBA_"."_CUSTOMER_".NAME AS "N +ame", "_SMDBA_"."_CUSTOMER_".EXT AS "Cl. Ext", "_SMDBA_"."_TELMASTE_"."DESCRIPTION" AS "Problem Description", "_SMDBA_"."_TELMASTE_"."DATE OPEN" AS "Opened", "_SMDBA_"."_PERSONNEL_".CODE AS "Assigned To" FROM "_SMDBA_"."_CUSTOMER_","_SMDBA_"."_TELMASTE_","_SMDBA_"."_PERSONN +EL_" WHERE "_SMDBA_"."_TELMASTE_"."SENT TO" = "_SMDBA_"."_PERSONNEL_".SEQUE +NCE AND "_SMDBA_"."_TELMASTE_".CLIENT = "_SMDBA_"."_CUSTOMER_".SEQUENCE AND "_SMDBA_"."_PERSONNEL_".CODE LIKE 'MUSER' AND "_SMDBA_"."_TELMASTE_".STATUS = 'O' ORDER BY "Problem #"; };
The SQL may look a little hacky, but I didn't design the DB :) It's basically to select various fields related to open helpdesk calls from several tables. (I have tried a simpler select from a table within that database, and that fails with exactly the same problem)

Having looked at eval, and trying it, I unfortunately get almost exactly the same response: $trans_handle -> execute does not return any value. (This was at the same time as setting 'RaiseError' and 'PrintError' to 1).

Whether that means that it is only executing one of the 'set' commands (which is possible, but even when I remove them I still don't get any errors) I don't know.

I still think that 'selecting' the database, and enabling the quoted identifiers is what's failing, but I can't figure out how/why they aren't setting properly.

Replies are listed 'Best First'.
Re: Re: Re: DBD::Sybase + MS SQL server problem
by hmerrill (Friar) on Aug 30, 2002 at 13:32 UTC
    The double quotes and the dots are throwing me - I'm familiar with

        SELECT <table_name>.<column_name> AS <column_name_alias>

    But I'm not familiar with a 3rd dot(.sequence). And, why are you using double quotes within your string? I don't think(?) you need those since your string is already surrounded by qq{};

    Can you put a

       print sql = <$sql>\n";

    after the $sql = qq{ ... };

    and paste that in so that I can see what the sql looks like that will be sent to the database?
      sql = < set quoted_identifier on use "smdb"; set TRANSACTION ISOLATION LEVEL READ UNCOMMITTED; SELECT "_SMDBA_"."_TELMASTE_".SEQUENCE AS "Problem #", "_SMDBA_"."_CUSTOMER_".FNAME + ' ' + "_SMDBA_"."_CUSTOMER_".NAME AS "N +ame", "_SMDBA_"."_CUSTOMER_".EXT AS "Cl. Ext", "_SMDBA_"."_TELMASTE_"."DESCRIPTION" AS "Problem Description", "_SMDBA_"."_TELMASTE_"."DATE OPEN" AS "Opened", "_SMDBA_"."_PERSONNEL_".CODE AS "Assigned To" FROM "_SMDBA_"."_CUSTOMER_","_SMDBA_"."_TELMASTE_","_SMDBA_"."_PERSONN +EL_" WHERE "_SMDBA_"."_TELMASTE_"."SENT TO" = "_SMDBA_"."_PERSONNEL_".SEQUE +NCE AND "_SMDBA_"."_TELMASTE_".CLIENT = "_SMDBA_"."_CUSTOMER_".SEQUENCE AND "_SMDBA_"."_TELMASTE_".STATUS = 'O' AND "_SMDBA_"."_PERSONNEL_".CODE LIKE 'EROLISON' ORDER BY "Problem #"; >
      To clarify a little "_SMDBA_"."_TELMASTE_" is the name of one of the tables (similar for subject, personnel and customer). Which is why you get "_SMDBA_"."_TELMASTE_".SEQUENCE

      The reason I'm using the double quotes within the string, is that when using SQSH, it doesn't work without them.

      These queries I'm more or less reverse engineering out of our existing helpdesk system (yes, it does use such icky table names, which is why the quotes are needed).

      If I copy/paste this text into SQSH, it works, and produces the desired output. (A listing of currently open calls assigned to me).
      Thanks for the patience, and apologies if the SQL is slightly different :) (And if you are anywhere near Coventry, UK, I'll have to arrange a beer or two).
      It also looks like I've run out of friday, so that's me for the weekend. Maybe having another look on monday will allow me to see the bit I've been missing.