Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default SQL query problem

    I have a problem.
    I try to execute SQL command which return more than 9 columns by DBD:PgPP
    and DBI (module).
    The procedure return error:
    Can't call method "fetch" on an undefined value at
    c:/per/site/lib/DBD.PgPP.pm line 330.
    If I execute less than 9 collumn is OK.
    How I can resolve this problem

    Robson
    [email]r.wyka@interia.pl[/email]
    POLAND


    news.tpi.pl Guest

  2. Similar Questions and Discussions

    1. Query problem, please help.
      mysql Ver 12.22 Distrib 4.0.24, for pc-linux-gnu (i386) gives me: The following database Error occured: You have an error in your SQL syntax....
    2. ***Sql Query problem
      Randy Webb wrote: SELECT DISTINCT OrderID FROM trans WHERE Trans_ID = 1 AND OrderID NOT IN (SELECT DISTINCT OrderID FROM trans WHERE Trans_ID =...
    3. Query of Query problem
      Error Executing Database Query. Query Of Queries runtime error. Table named "DATA" was not found in Memory. It is misspelled, or the table is...
    4. Query on Query and CF casting problem
      I am using a custom tag in MX7 that was working fine in 5 that renders a table. The input to the custom tag is a query and it's columns along with...
    5. query problem
      SELECT top5.PRODID, p.PRODNAME FROM ( SELECT TOP 5 SALES = COUNT(*), PRODID FROM SALES GROUP BY PRODID ORDER BY SALES DESC ) AS top5 INNER JOIN...
  3. #2

    Default SQL query problem



    news.tpi.pl Guest

  4. #3

    Default SQL query problem

    I have a problem.
    I try to execute SQL command which return more than 9 columns by DBD:PgPP
    and DBI (module).
    The procedure return error:
    Can't call method "fetch" on an undefined value at
    c:/per/site/lib/DBD.PgPP.pm line 330.
    If I execute less than 9 collumn is OK.
    How I can resolve this problem

    Robson
    [email]r.wyka@interia.pl[/email]
    POLAND


    news.tpi.pl Guest

  5. #4

    Default Re: SQL query problem

    In article <bfm09b$5b6$1@atlantis.news.tpi.pl>,
    "news.tpi.pl" <mareks1@poczta.onet.pl> wrote:
    > I have a problem.
    > I try to execute SQL command which return more than 9 columns by DBD:PgPP
    > and DBI (module).
    > The procedure return error:
    > Can't call method "fetch" on an undefined value at
    > c:/per/site/lib/DBD.PgPP.pm line 330.
    > If I execute less than 9 collumn is OK.
    > How I can resolve this problem
    >
    > Robson
    > [email]r.wyka@interia.pl[/email]
    > POLAND
    >
    >
    pls post the pertinent code leading up to and including the 'fetch' part.

    --
    Michael Budash
    Michael Budash Guest

  6. #5

    Default Re: SQL query problem

    At some point in time, "news.tpi.pl" <mareks1@poczta.onet.pl> wrote:
    >I have a problem.
    >I try to execute SQL command which return more than 9 columns by DBD:PgPP
    >and DBI (module).
    >The procedure return error:
    >Can't call method "fetch" on an undefined value at
    >c:/per/site/lib/DBD.PgPP.pm line 330.
    Hmm, that looks like the statement didn't parse properly. Please post code.


    Jeff Boes Guest

  7. #6

    Default Re: SQL query problem

    WINDOWS XP + perl v5.80
    I create table:
    table
    id_odb1 int4 primary key,
    id_odb2 int4 not null references
    ilosc int2,
    stan int2,
    rok char(4),
    moc char(8),
    uwagi char(40),
    id_typ int2 not null references,
    adapt char(4),

    $sth = $conn->prepare("SELECT * from table");
    $sth->execute();
    my @RAD=$sth->fetchrow_array();
    or
    $sth = $conn->prepare("SELECT id_odb1,
    id_odb2,ilosc,stan,rok,moc,uwagi,id_typ,adapt from tabela");
    $sth->execute();
    IS ERROR
    Can't call method "fetch" on an undefined value at
    Unknown message type: ' ' at:c:/per/site/lib/DBD.PgPP.pm line 634.
    Can,t call method "fetch" on an undefined value at
    c:/per/site/lib/DBD.PgPP.pm line 330.


    news.tpi.pl Guest

  8. #7

    Default Re: SQL query problem

    news.tpi.pl <mareks1@poczta.onet.pl> wrote:
    > I create table:
    > table
    > id_odb1 int4 primary key,
    > id_odb2 int4 not null references
    > ilosc int2,
    [...]
    > Can,t call method "fetch" on an undefined value at
    > c:/per/site/lib/DBD.PgPP.pm line 330.
    You appear to be using Postgres (well, you're using the PgPP driver). INT2
    isn't a valid data type. What is your exact table definition?

    Chris
    --
    @s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
    until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
    news@roaima.freeserve.co.uk Guest

  9. #8

    Default Re: SQL query problem

    news.tpi.pl <mareks1@poczta.onet.pl> wrote:
    > I have a problem.
    ....which is also separately described in comp.lang.perl.modules. Please
    don't multi-post as it splits up the separate threads of discussion.

    I've already responded there so I won't repeat myself here.

    Cheers,
    Chris
    --
    @s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
    until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
    news@roaima.freeserve.co.uk Guest

  10. #9

    Default Re: SQL query problem

    Main code:



    $database="bpsimple";
    $host= "10.10.35.96";
    $username="postgres";
    $password="";
    $conn = DBI->connect("dbi:PgPP:dbname=$database;host=$host;por t=5432",
    $username, $password);

    doSQL($conn, "DROP TABLE odbiorniki");
    doSQL($conn, "CREATE TABLE odbiorniki ( id_odbiornika int4 primary key,
    id_odbiorcy int4 not null references odbiorcy (id_odbiorcy),id_producenta
    int2 not null references sl_prod (id_producenta), ilosc int2,stan int2, rok
    char(4), piek_moc char(8),uwagi char(40), odb_typ int2 not null references
    sl_typy (id_typ), adapt char(3))");
    open (dat,"dane.txt");
    foreach(<dat>){
    s/^\s+//; s/\s+$//; chomp ($_);
    my
    ($dat_id,$dat_id_odb,$dat_prod,$dat_szt,$dat_stan, $dat_rok,$dat_piek,$dat_uw
    agi,$dat_idtyp)=split(/\;/,$_);
    $dat_idtyp =~ s/\s+$//; chomp ($dat_idtyp);
    doSQL($conn, "INSERT INTO odbiorniki
    (id_odbiornika,id_odbiorcy,id_producenta,ilosc,sta n,rok,piek_moc,uwagi,odb_t
    yp,adapt) values
    ($dat_id,$dat_id_odb,$dat_prod,$dat_szt,$dat_stan, \'$dat_rok\',\'$dat_piek\'
    ,\'$dat_uwagi\',$dat_idtyp,\'NIE\')");
    } close(dat);
    sub doSQL
    {
    open(blad,">>blad_odb.txt");

    my ($conn, $command) = @_;
    #print $command, "\r";
    my $sth = $conn->prepare($command);
    my $nrows = $sth->execute;
    print "status is ", $DBI::err, "\n" if $DBI::err;
    print "#rows affected is ", $nrows, "\n";
    print blad "error message: ", $DBI::errstr,"$_", "\n" if $DBI::err;
    close(blad);

    }

    $conn->disconnect;



    sub sprawdz_indeks{
    if ($index == 0){open(blad,">>blad_odb.txt");
    print blad " Nie znaleziono indeksu odbiornika dla
    rekordu:\n";
    print blad " $_\n";
    close(blad);
    }}






    news.tpi.pl Guest

  11. #10

    Default Re: SQL query problem


    doSQL($conn, "CREATE TABLE odbiorniki ( id_odbiornika int4 primary key,
    id_odbiorcy int4 not null references odbiorcy (id_odbiorcy),id_producenta
    int2 not null references sl_prod (id_producenta), ilosc int2,stan int2, rok
    char(4), piek_moc char(8),uwagi char(40), odb_typ int2 not null references
    sl_typy (id_typ), adapt char(3))");

    doSQL($conn, "INSERT INTO odbiorcy (
    id_odbiorcy,nazwa_odbiorcy,adres_odbiorcy)
    values($odb_ewid,\'$odb_nazwa\',\'$odb_adres\')");



    sub doSQL
    {
    open(blad,">>blad_odb.txt");

    my ($conn, $command) = @_;
    #print $command, "\r";
    my $sth = $conn->prepare($command);
    my $nrows = $sth->execute;
    print "status is ", $DBI::err, "\n" if $DBI::err;
    print "#rows affected is ", $nrows, "\n";
    print blad "error message: ", $DBI::errstr,"$_", "\n" if $DBI::err;
    close(blad);

    }


    news.tpi.pl Guest

  12. #11

    Default Re: SQL query problem

    Main create table "odbiorniki" code:
    -----------------------------------------------
    doSQL($conn, "DROP TABLE odbiorniki");
    doSQL($conn, "CREATE TABLE odbiorniki ( id_odbiornika int4 primary key,
    id_odbiorcy int4 not null references odbiorcy (id_odbiorcy),id_producenta
    int2 not null references sl_prod (id_producenta), ilosc int2,stan int2, rok
    char(4), piek_moc char(8),uwagi char(40), odb_typ int2 not null references
    sl_typy (id_typ), adapt char(3))");

    open (dat,"dane.txt");
    foreach(<dat>){
    my
    ($dat_id,$dat_id_odb,$dat_prod,$dat_szt,$dat_stan, $dat_rok,$dat_piek,$dat_uw
    agi,$dat_idtyp)=split(/\;/,$_);
    $dat_idtyp =~ s/\s+$//; chomp ($dat_idtyp);
    doSQL($conn, "INSERT INTO odbiorniki
    (id_odbiornika,id_odbiorcy,id_producenta,ilosc,sta n,rok,piek_moc,uwagi,odb_t
    yp,adapt) values
    ($dat_id,$dat_id_odb,$dat_prod,$dat_szt,$dat_stan, \'$dat_rok\',\'$dat_piek\'
    ,\'$dat_uwagi\',$dat_idtyp,\'NIE\')");
    } close(dat);

    ------------------------



    news.tpi.pl Guest

  13. #12

    Default SQL query problem

    Hi,
    My search query should look for two tables for the matching record. If the record doesn't in table1 look into table2. How to write a query for this example.

    Thanks.
    navee Guest

  14. #13

    Default Re: SQL query problem

    select col1, col2, tablename = 'tablea' from tablea where x = #somevalue# UNION
    select acol as col1, bcol as col2, tablename = 'tableb' from tableb where y =
    #somevalue# The column names for Unions must match up, hence the aliasing i
    put in for the cols in the second table. Also Union returns distinct record
    sets, so if the same record exists in both tables, it would only return one
    row. I added the last col in case you needed to know what table the data came
    from. This is how I would do it for MS Sql Server.

    byron1021 Guest

  15. #14

    Default Re: SQL query problem

    Thanks. It's working. I appreciate your help.
    navee Guest

  16. #15

    Default SQL query problem

    Can some please take a look at the SQL in this statement and tell me why it
    wont work.
    The same statement works in MSSQL with hardcoded values instead of the '" &
    Replace(MM_valUsername,"'","''" etc.

    MM_rsUser.Source = "SELECT dbo.tbMembers.MemberId,
    dbo.tbMembers.MemberPass, dbo.tbMembers.email,
    MAX(dbo.tbMemberAccessLvl.AccessLvl) AS AccessLvl"

    If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source &
    "," & MM_fldUserAuthorization

    MM_rsUser.Source = MM_rsUser.Source & " FROM dbo.tbMembers INNER JOIN
    dbo.tbMemberAccessLvl ON tbMembers.MemberId = tbMemberAccessLvl.MemberID
    WHERE (dbo.tbMembers.MemberId='" & Replace(MM_valUsername,"'","''") &"' OR
    dbo.tbMembers.email='" & Replace(MM_valUsername,"'","''") &"') AND
    dbo.tbMembers.MemberPass='" & Replace(Request.Form("password"),"'","''") &
    "' GROUP BY dbo.tbMembers.MemberId, dbo.tbMembers.MemberPass,
    dbo.tbMembers.email"


    Tim Mannah Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139