GnuCash  4.12-404-geb24099a91
Data Structures | Functions
gnc-transaction-sql.h File Reference

load and save data to SQL More...

#include "Transaction.h"
#include "qof.h"
#include "Account.h"

Go to the source code of this file.

Data Structures

class  GncSqlTransBackend
 
class  GncSqlSplitBackend
 
struct  acct_balances_t
 

Functions

void gnc_sql_transaction_load_tx_for_account (GncSqlBackend *sql_be, Account *account)
 Loads all transactions which have splits for a specific account. More...
 

Detailed Description

load and save data to SQL

Author
Copyright (c) 2006-2008 Phil Longstaff plong.nosp@m.staf.nosp@m.f@rog.nosp@m.ers..nosp@m.com

This file implements the top-level QofBackend API for saving/ restoring data to/from an SQL database

Definition in file gnc-transaction-sql.h.

Function Documentation

◆ gnc_sql_transaction_load_tx_for_account()

void gnc_sql_transaction_load_tx_for_account ( GncSqlBackend sql_be,
Account account 
)

Loads all transactions which have splits for a specific account.

Parameters
sql_beSQL backend
accountAccount

Loads all transactions which have splits for a specific account.

Parameters
sql_beSQL backend
accountAccount

Definition at line 685 of file gnc-transaction-sql.cpp.

687 {
688  const GncGUID* guid;
689  gchar guid_buf[GUID_ENCODING_LENGTH + 1];
690  gchar* query_sql;
691 
692  g_return_if_fail (sql_be != NULL);
693  g_return_if_fail (account != NULL);
694 
695  guid = qof_instance_get_guid (QOF_INSTANCE (account));
696 
697  const std::string tpkey(tx_col_table[0]->name()); //guid
698  const std::string spkey(split_col_table[0]->name()); //guid
699  const std::string stkey(split_col_table[1]->name()); //txn_guid
700  const std::string sakey(split_col_table[2]->name()); //account_guid
701  std::string sql("(SELECT DISTINCT ");
702  sql += stkey + " FROM " SPLIT_TABLE " WHERE " + sakey + " = '";
703  sql += gnc::GUID(*guid).to_string() + "')";
704  query_transactions (sql_be, sql);
705 }
const GncGUID * qof_instance_get_guid(gconstpointer inst)
Return the GncGUID of this instance.
#define GUID_ENCODING_LENGTH
Number of characters needed to encode a guid as a string not including the null terminator.
Definition: guid.h:84
The type used to store guids in C.
Definition: guid.h:75